diff --git a/ietf/doc/tests.py b/ietf/doc/tests.py index 7761337e3..13bffdc67 100644 --- a/ietf/doc/tests.py +++ b/ietf/doc/tests.py @@ -40,7 +40,7 @@ from ietf.doc.factories import ( DocumentFactory, DocEventFactory, CharterFactor ConflictReviewFactory, WgDraftFactory, IndividualDraftFactory, WgRfcFactory, IndividualRfcFactory, StateDocEventFactory, BallotPositionDocEventFactory, BallotDocEventFactory, DocumentAuthorFactory, NewRevisionDocEventFactory, - StatusChangeFactory, BofreqFactory, DocExtResourceFactory) + StatusChangeFactory, BofreqFactory, DocExtResourceFactory, RgDraftFactory) from ietf.doc.forms import NotifyForm from ietf.doc.fields import SearchableDocumentsField from ietf.doc.utils import create_ballot_if_not_open, uppercase_std_abbreviated_name @@ -2819,3 +2819,45 @@ class NotifyValidationTests(TestCase): self.assertFalse(f.is_valid()) self.assertTrue("Invalid addresses" in f.errors["notify"][0]) self.assertTrue("Duplicate addresses" in f.errors["notify"][0]) + +class CanRequestConflictReviewTests(TestCase): + def test_gets_request_conflict_review_action_button(self): + ise_draft = IndividualDraftFactory(stream_id="ise") + irtf_draft = RgDraftFactory() + + # This is blunt, trading off precision for time. A more thorough test would ensure + # that the text is in a button and that the correct link is absent/present as well. + + target_string = "Begin IETF conflict review" + + url = urlreverse("ietf.doc.views_doc.document_main", kwargs=dict(name=irtf_draft.name)) + r = self.client.get(url) + self.assertNotContains(r, target_string) + self.client.login(username="secretary", password="secretary+password") + r = self.client.get(url) + self.assertContains(r, target_string) + self.client.logout() + self.client.login(username="irtf-chair", password="irtf-chair+password") + r = self.client.get(url) + self.assertContains(r, target_string) + self.client.logout() + self.client.login(username="ise-chair", password="ise-chair+password") + r = self.client.get(url) + self.assertNotContains(r, target_string) + self.client.logout() + + url = urlreverse("ietf.doc.views_doc.document_main", kwargs=dict(name=ise_draft.name)) + r = self.client.get(url) + self.assertNotContains(r, target_string) + self.client.login(username="secretary", password="secretary+password") + r = self.client.get(url) + self.assertContains(r, target_string) + self.client.logout() + self.client.login(username="irtf-chair", password="irtf-chair+password") + r = self.client.get(url) + self.assertNotContains(r, target_string) + self.client.logout() + self.client.login(username="ise-chair", password="ise-chair+password") + r = self.client.get(url) + self.assertContains(r, target_string) + diff --git a/ietf/doc/views_doc.py b/ietf/doc/views_doc.py index 8f136ac21..e33a51f8b 100644 --- a/ietf/doc/views_doc.py +++ b/ietf/doc/views_doc.py @@ -427,12 +427,20 @@ def document_main(request, name, rev=None, document_html=False): urlreverse('ietf.doc.views_ballot.close_rsab_ballot', kwargs=dict(name=doc.name)) )) - if (doc.get_state_slug() not in ["rfc", "expired"] and doc.stream_id in ("ise", "irtf") - and has_role(request.user, ("Secretariat", "IRTF Chair")) and not conflict_reviews and not snapshot): - label = "Begin IETF Conflict Review" - if not doc.intended_std_level: - label += " (note that intended status is not set)" - actions.append((label, urlreverse('ietf.doc.views_conflict_review.start_review', kwargs=dict(name=doc.name)))) + if ( + doc.get_state_slug() not in ["rfc", "expired"] + and not conflict_reviews + and not snapshot + ): + if ( + doc.stream_id == "ise" and has_role(request.user, ("Secretariat", "ISE")) + ) or ( + doc.stream_id == "irtf" and has_role(request.user, ("Secretariat", "IRTF Chair")) + ): + label = "Begin IETF conflict review" # Note that the template feeds this through capfirst_allcaps + if not doc.intended_std_level: + label += " (note that intended status is not set)" + actions.append((label, urlreverse('ietf.doc.views_conflict_review.start_review', kwargs=dict(name=doc.name)))) if doc.get_state_slug() not in ["rfc", "expired"] and not snapshot: if can_request_rfc_publication(request.user, doc):