From 268b99bd563090f8953ba8e1d5d8d90d20042d27 Mon Sep 17 00:00:00 2001
From: Russ Housley <housley@vigilsec.com>
Date: Sat, 23 Mar 2019 15:36:07 +0000
Subject: [PATCH] Add downward references to telechat moderator package and
 Secretariat telechat pages.  Commit ready for merge.  - Legacy-Id: 16087

---
 ietf/iesg/views.py                         |  2 ++
 ietf/secr/telechat/views.py                |  3 +++
 ietf/secr/templates/telechat/doc.html      | 21 +++++++++++++++++++--
 ietf/templates/iesg/moderator_doc.html     | 19 +++++++++++++++++++
 ietf/templates/iesg/moderator_package.html |  4 ++--
 5 files changed, 45 insertions(+), 4 deletions(-)

diff --git a/ietf/iesg/views.py b/ietf/iesg/views.py
index da3c90ec3..8fd17fdfa 100644
--- a/ietf/iesg/views.py
+++ b/ietf/iesg/views.py
@@ -257,9 +257,11 @@ def agenda_moderator_package(request, date=None):
     for num, s in sections:
         if "2" <= num < "5" and "docs" in s and s["docs"]:
             for i, d in enumerate(s["docs"], start=1):
+                downrefs = [rel for rel in d.relateddocument_set.all() if rel.is_downref() and not rel.is_approved_downref()]
                 flattened_sections.append((num, {
                             "title": s["title"] + " (%s of %s)" % (i, len(s["docs"])),
                             "doc": d,
+                            "downrefs": downrefs,
                             "parents": s["parents"],
                             }))
         else:
diff --git a/ietf/secr/telechat/views.py b/ietf/secr/telechat/views.py
index df371de9d..c845d26ed 100644
--- a/ietf/secr/telechat/views.py
+++ b/ietf/secr/telechat/views.py
@@ -202,6 +202,8 @@ def doc_detail(request, date, name):
     tags = doc.tags.filter(slug__in=TELECHAT_TAGS)
     tag = tags[0].pk if tags else None
 
+    downrefs = [rel for rel in doc.relateddocument_set.all() if rel.is_downref() and not rel.is_approved_downref()]
+
     writeup = get_doc_writeup(doc)
 
     initial_state = {'state':doc.get_state(state_type).pk,
@@ -304,6 +306,7 @@ def doc_detail(request, date, name):
         'ballot_type': ballot_type,
         'date': date,
         'document': doc,
+        'downrefs': downrefs,
         'conflictdoc': conflictdoc,
         'agenda': agenda,
         'formset': formset,
diff --git a/ietf/secr/templates/telechat/doc.html b/ietf/secr/templates/telechat/doc.html
index 3ec2422e0..d3d1c1bfe 100644
--- a/ietf/secr/templates/telechat/doc.html
+++ b/ietf/secr/templates/telechat/doc.html
@@ -21,7 +21,10 @@
     {% if conflictdoc %}References: <a href="{{ conflictdoc.get_absolute_url }}">{{ conflictdoc }}</a><br />{% endif %}
     <a href="#writeup">Ballot Writeup</a><br />
     Token: {{ document.ad.name }}<br />
-    {% if document.type_id == "draft" %}Consensus: {{ document|consensus }}<br />{% endif %}
+    {% if document.type_id == "draft" %}
+      Consensus: {{ document|consensus }}<br />
+      Has downref: {% if downrefs %}Yes{% else %}No{% endif %}<br />
+    {% endif %}
     Number of Open Positions: {{ open_positions }}<br />
     <br />
     <div>
@@ -73,7 +76,21 @@
     <pre>
 {{ writeup }}
     </pre>
-    
+
+    {% if downrefs %}
+    <a name="downrefs"><h2>Downward References</h2></a>
+    {% for ref in downrefs %}
+      <p>Add {{ref.target.document.canonical_name}}
+        ({{ref.target.document.std_level}} - {{ref.target.document.stream.desc}})
+        to downref registry.<br />
+       {% if not ref.target.document.std_level %}
+        +++ Warning: The standards level has not been set yet!!!<br />
+       {% endif %}
+       {% if not ref.target.document.stream %}
+        +++ Warning: document stream has not been set yet!!!<br />
+       {% endif %}
+    {% endfor %}</p>
+    {% endif %}
 
 {% else %}
     <h3>No Documents on the Agenda</h3>
diff --git a/ietf/templates/iesg/moderator_doc.html b/ietf/templates/iesg/moderator_doc.html
index 57529ed01..532a89282 100644
--- a/ietf/templates/iesg/moderator_doc.html
+++ b/ietf/templates/iesg/moderator_doc.html
@@ -43,6 +43,7 @@ Parts Copyright (c) 2009 The IETF Trust, all rights reserved.
   <b>
     Intended status: {{ doc.intended_std_level }}<br>
     Consensus: <a href="{% url 'ietf.doc.views_draft.edit_consensus' name=doc.name %}">{{ doc|consensus }}</a><br>
+    Has downref: {% if downrefs %}Yes{% else %}No{% endif %}<br>
     Token: {{ doc.ad.plain_name }}<br>
     {% if doc.type_id == "draft" %}
       Last call ends: {{ doc.most_recent_ietflc.expires.date|default:"(none)" }}
@@ -159,3 +160,21 @@ Parts Copyright (c) 2009 The IETF Trust, all rights reserved.
     the Do Not Publish message to the RFC Editor that includes the note
     drafted by[Name the AD].</p>
 {% endif %}
+
+{% if num|startswith:"2.1" or num|startswith:"2.2" %}
+  {% if downrefs %}
+    <p>If APPROVED - The Secretariat will add to the downref registry:<br>
+    {% for ref in downrefs %}
+      + Add {{ref.target.document.canonical_name}}
+        ({{ref.target.document.std_level}} - {{ref.target.document.stream.desc}})
+        to downref registry.<br>
+       {% if not ref.target.document.std_level %}
+         +++ Warning: The standards level has not been set yet!!!<br>
+       {% endif %}
+       {% if not ref.target.document.stream %}
+         +++ Warning: document stream has not been set yet!!!<br>
+       {% endif %}
+    {% endfor %}</p>
+  {% endif %}
+{% endif %}
+
diff --git a/ietf/templates/iesg/moderator_package.html b/ietf/templates/iesg/moderator_package.html
index 427a7e36f..c7978f8d0 100644
--- a/ietf/templates/iesg/moderator_package.html
+++ b/ietf/templates/iesg/moderator_package.html
@@ -97,11 +97,11 @@ Some parts Copyright (c) 2009 The IETF Trust, all rights reserved.
 
       {% if num >= "2" and num < "5" %}
 	{% if "doc" in section %}
-	  {% with section.doc as doc %}
+	  {% with section.doc as doc %}{% with section.downrefs as downrefs %}
 	    {% if doc.type_id == "draft" or doc.type_id == "statchg" %}{% include "iesg/moderator_doc.html" %}{% endif %}
 	    {% if doc.type_id == "conflrev" %}{% include "iesg/moderator_conflict_doc.html" %}{% endif %}
 	    {% if doc.type_id == "charter" %}{% include "iesg/moderator_charter.html" %}{% endif %}
-	  {% endwith %}
+	  {% endwith %}{% endwith %}
 	{% else %}
 	  <p>NONE</p>
 	{% endif %}