From 06b9df10ee77b061fbde53d54acab77dab953f90 Mon Sep 17 00:00:00 2001
From: Robert Sparks
Date: Mon, 23 Sep 2024 10:09:50 -0500
Subject: [PATCH] feat: warn about materials for cancelled sessions (#7959)
* feat: warn about materials for cancelled sessions
* fix: handle viewing a DocHistory material object
---
ietf/doc/tests.py | 11 +++++++++++
ietf/doc/views_doc.py | 8 ++++++++
ietf/templates/doc/document_material.html | 3 +++
3 files changed, 22 insertions(+)
diff --git a/ietf/doc/tests.py b/ietf/doc/tests.py
index 5e5b741fe5..f5f715162d 100644
--- a/ietf/doc/tests.py
+++ b/ietf/doc/tests.py
@@ -1683,6 +1683,17 @@ def test_document_material(self):
r = self.client.get(urlreverse("ietf.doc.views_doc.document_main", kwargs=dict(name=doc.name)))
self.assertEqual(r.status_code, 200)
+ self.assertNotContains(r, "The session for this document was cancelled.")
+
+ SchedulingEvent.objects.create(
+ session=session,
+ status_id='canceled',
+ by = Person.objects.get(user__username="marschairman"),
+ )
+
+ r = self.client.get(urlreverse("ietf.doc.views_doc.document_main", kwargs=dict(name=doc.name)))
+ self.assertEqual(r.status_code, 200)
+ self.assertContains(r, "The session for this document was cancelled.")
def test_document_ballot(self):
doc = IndividualDraftFactory()
diff --git a/ietf/doc/views_doc.py b/ietf/doc/views_doc.py
index d12dd04181..aad45920c6 100644
--- a/ietf/doc/views_doc.py
+++ b/ietf/doc/views_doc.py
@@ -870,6 +870,13 @@ def document_main(request, name, rev=None, document_html=False):
and doc.group.features.has_nonsession_materials
and doc.type_id in doc.group.features.material_types
)
+
+ session_statusid = None
+ actual_doc = doc if isinstance(doc,Document) else doc.doc
+ if actual_doc.session_set.count() == 1:
+ if actual_doc.session_set.get().schedulingevent_set.exists():
+ session_statusid = actual_doc.session_set.get().schedulingevent_set.order_by("-time").first().status_id
+
return render(request, "doc/document_material.html",
dict(doc=doc,
top=top,
@@ -882,6 +889,7 @@ def document_main(request, name, rev=None, document_html=False):
can_upload = can_upload,
other_types=other_types,
presentations=presentations,
+ session_statusid=session_statusid,
))
diff --git a/ietf/templates/doc/document_material.html b/ietf/templates/doc/document_material.html
index 7537082df9..cf6dd1ab64 100644
--- a/ietf/templates/doc/document_material.html
+++ b/ietf/templates/doc/document_material.html
@@ -153,6 +153,9 @@
{% endif %}
+ {% if session_statusid == "canceled" %}
+ The session for this document was cancelled.
+ {% endif %}