Skip to content

Commit 07637c2

Browse files
committed
Improve alerts when looking at non-current versions of a charter document. Fixes ietf-tools#2774. Commit ready for merge.
- Legacy-Id: 16785
1 parent f3fb0f8 commit 07637c2

3 files changed

Lines changed: 82 additions & 6 deletions

File tree

ietf/doc/templatetags/ietf_filters.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,3 +528,12 @@ def rfcbis(s):
528528
def urlize(value):
529529
raise RuntimeError("Use linkify from textfilters instead of urlize")
530530

531+
@register.filter
532+
@stringfilter
533+
def charter_major_rev(rev):
534+
return rev[:2]
535+
536+
@register.filter
537+
@stringfilter
538+
def charter_minor_rev(rev):
539+
return rev[3:5]

ietf/doc/tests_charter.py

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import debug # pyflakes:ignore
1818

19-
from ietf.doc.factories import CharterFactory
19+
from ietf.doc.factories import CharterFactory, NewRevisionDocEventFactory
2020
from ietf.doc.models import ( Document, State, BallotDocEvent, BallotType, NewRevisionDocEvent,
2121
TelechatDocEvent, WriteupDocEvent )
2222
from ietf.doc.utils_charter import ( next_revision, default_review_text, default_action_text,
@@ -30,6 +30,61 @@
3030
from ietf.utils.mail import outbox, empty_outbox, get_payload
3131
from ietf.utils.test_utils import login_testing_unauthorized
3232

33+
class ViewCharterTests(TestCase):
34+
def test_view_revisions(self):
35+
charter = CharterFactory()
36+
e = NewRevisionDocEventFactory(doc=charter,rev="01")
37+
charter.rev = e.rev
38+
charter.save_with_history([e])
39+
e = NewRevisionDocEventFactory(doc=charter,rev="01-00")
40+
charter.rev = e.rev
41+
charter.save_with_history([e])
42+
e =NewRevisionDocEventFactory(doc=charter,rev="02")
43+
charter.rev = e.rev
44+
charter.save_with_history([e])
45+
e =NewRevisionDocEventFactory(doc=charter,rev="02-00")
46+
charter.rev = e.rev
47+
charter.save_with_history([e])
48+
e = NewRevisionDocEventFactory(doc=charter,rev="02-01")
49+
charter.rev = e.rev
50+
charter.save_with_history([e])
51+
52+
url = urlreverse('ietf.doc.views_doc.document_main',kwargs={'name':charter.name})
53+
r = self.client.get(url)
54+
q = PyQuery(r.content)
55+
self.assertIn('The information below is for a proposed recharter. The current approved charter is',q('#message-row').text())
56+
57+
url = urlreverse('ietf.doc.views_doc.document_main',kwargs={'name':charter.name,'rev':'02-00'})
58+
r = self.client.get(url)
59+
q = PyQuery(r.content)
60+
self.assertIn('The information below is for an older version of the current proposed rechartering effort',q('#message-row').text())
61+
62+
url = urlreverse('ietf.doc.views_doc.document_main',kwargs={'name':charter.name,'rev':'02'})
63+
r = self.client.get(url)
64+
q = PyQuery(r.content)
65+
self.assertIn('The information below is for the currently approved charter, but newer proposed charter text exists',q('#message-row').text())
66+
67+
url = urlreverse('ietf.doc.views_doc.document_main',kwargs={'name':charter.name,'rev':'01-00'})
68+
r = self.client.get(url)
69+
q = PyQuery(r.content)
70+
self.assertIn('The information below is for an older proposed',q('#message-row').text())
71+
72+
url = urlreverse('ietf.doc.views_doc.document_main',kwargs={'name':charter.name,'rev':'01'})
73+
r = self.client.get(url)
74+
q = PyQuery(r.content)
75+
self.assertIn('The information below is for an older approved',q('#message-row').text())
76+
77+
e = NewRevisionDocEventFactory(doc=charter,rev="03")
78+
charter.rev='03'
79+
charter.save_with_history([e])
80+
81+
url = urlreverse('ietf.doc.views_doc.document_main',kwargs={'name':charter.name})
82+
r = self.client.get(url)
83+
q = PyQuery(r.content)
84+
self.assertEqual('',q('#message-row').text())
85+
86+
87+
3388
class EditCharterTests(TestCase):
3489
def setUp(self):
3590
self.charter_dir = self.tempdir('charter')

ietf/templates/doc/document_charter.html

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,23 @@
2323
<table class="table table-condensed">
2424
<thead id="message-row">
2525
<tr>
26-
{% if doc.rev != latest_rev %}
27-
<th colspan="4" class="alert-warning">The information below is for an old version of the document</th>
28-
{% else %}
29-
<th colspan="4"></th>
30-
{% endif %}
26+
{% if doc.rev|charter_major_rev != latest_rev|charter_major_rev %}
27+
<th colspan="4" class="alert-warning">The information below is for an older {% if doc.rev|charter_minor_rev %}proposed{% else %}approved{% endif %} charter</th>
28+
{% else %}
29+
{% if doc.rev != latest_rev %}
30+
{% if doc.rev|charter_minor_rev %}
31+
<th colspan="4" class="alert-warning">The information below is for an older version of the current proposed rechartering effort</th>
32+
{% else %}
33+
<th colspan="4" class="alert-info">The information below is for the currently approved charter, but newer proposed charter text exists</th>
34+
{% endif %}
35+
{% else %}
36+
{% if doc.rev|charter_minor_rev and doc.rev|charter_major_rev != '00' %}
37+
<th colspan="4" class="alert-info">The information below is for a proposed recharter. The current approved charter is version {{ doc.rev|charter_major_rev }}</th>
38+
{% else %}
39+
<th colspan="4"></th>
40+
{% endif %}
41+
{% endif %}
42+
{% endif %}
3143
</tr>
3244
</thead>
3345

0 commit comments

Comments
 (0)