diff --git a/ietf/doc/templatetags/ballot_icon.py b/ietf/doc/templatetags/ballot_icon.py index 79e06f949..f44e7f3e0 100644 --- a/ietf/doc/templatetags/ballot_icon.py +++ b/ietf/doc/templatetags/ballot_icon.py @@ -218,3 +218,19 @@ def state_age_colored(doc): 's' if days != 1 else '')) else: return "" + +@register.filter +def state_alert_badge(doc): + """Return alert badge, if any, for a document""" + if doc.type_id != 'draft': + return '' + + iesg_state = doc.get_state('draft-iesg') + if iesg_state.slug != 'rfcqueue': + return '' + + rfced_state = doc.get_state('draft-rfceditor') + if rfced_state.slug == 'auth48': + return mark_safe('AUTH48') + + return '' \ No newline at end of file diff --git a/ietf/doc/templatetags/tests_ballot_icon.py b/ietf/doc/templatetags/tests_ballot_icon.py new file mode 100644 index 000000000..973014143 --- /dev/null +++ b/ietf/doc/templatetags/tests_ballot_icon.py @@ -0,0 +1,34 @@ +from ietf.doc.factories import WgDraftFactory +from ietf.doc.templatetags.ballot_icon import state_alert_badge +from ietf.utils.test_utils import TestCase + + +class BallotIconTests(TestCase): + def test_state_alert_badge_marks_auth48(self): + draft = WgDraftFactory(states=[ + ('draft','active'), + ('draft-iesg','rfcqueue'), + ('draft-rfceditor', 'auth48'), + ]) + output = state_alert_badge(draft) + self.assertIn('AUTH48', output) + + def test_state_alert_badge_ignores_others(self): + # If the state_alert_badge() method becomes more complicated, more + # sophisticated testing can be added. + # For now, just test a couple states that should not be marked. + draft = WgDraftFactory(states=[ + ('draft', 'active'), + ('draft-iesg', 'approved'), # not in rfcqueue state + ('draft-rfceditor', 'auth48'), + ]) + output = state_alert_badge(draft) + self.assertEqual('', output) + + draft = WgDraftFactory(states=[ + ('draft', 'active'), + ('draft-iesg', 'rfcqueue'), + ('draft-rfceditor', 'auth48-done'), # not in auth48 state + ]) + output = state_alert_badge(draft) + self.assertEqual('', output) diff --git a/ietf/doc/tests.py b/ietf/doc/tests.py index b38b19650..247e43d31 100644 --- a/ietf/doc/tests.py +++ b/ietf/doc/tests.py @@ -249,7 +249,19 @@ class SearchTests(TestCase): self.assertContains(r, charter.name) self.assertContains(r, discuss_other.doc.name) - + + def test_auth48_doc_for_ad(self): + """Docs in AUTH48 state should have a decoration""" + ad = RoleFactory(name_id='ad', group__type_id='area', group__state_id='active').person + draft = IndividualDraftFactory(ad=ad, + states=[('draft', 'active'), + ('draft-iesg', 'rfcqueue'), + ('draft-rfceditor', 'auth48')]) + r = self.client.get(urlreverse('ietf.doc.views_search.docs_for_ad', + kwargs=dict(name=ad.full_name_as_key()))) + self.assertEqual(r.status_code, 200) + self.assertContains(r, draft.name) + self.assertContains(r, 'title="AUTH48"') # title attribute of AUTH48 badge in state_alert_badge filter def test_drafts_in_last_call(self): draft = IndividualDraftFactory(pages=1) diff --git a/ietf/templates/doc/search/status_columns.html b/ietf/templates/doc/search/status_columns.html index 0e425c38a..b86161d0f 100644 --- a/ietf/templates/doc/search/status_columns.html +++ b/ietf/templates/doc/search/status_columns.html @@ -17,6 +17,8 @@ : {{ doc|state:"draft-rfceditor" }} {% endif %} + {{ doc|state_alert_badge }} + {{ doc|state_age_colored }} {% if doc.telechat_date %}