Repository: ietf-tools/datatracker

Issue:
The AD Dashboard "Blocking positions held by..." section misses (some?) non-draft documents
This feature was requested in #2800 and implemented in https://github.com/ietf-tools/datatracker/commit/6688d37bb4b57f5f42e1ee38d4688b2788a1221e ; there are references in the code to document types of "charter" and "conflrev", but I do not believe the handling for those document types is currently functional.
In particular, I currently hold a BLOCK on charter-ietf-shmoo but it does not show up on my AD Dashboard page.


Discussion:
The blocked charter code looks for blocked charters in the internal review and IESG review states; it needs to also include charters in the External review state.

Resolving patch:
diff --git a/ietf/doc/models.py b/ietf/doc/models.py
--- a/ietf/doc/models.py
+++ b/ietf/doc/models.py
@@ -81,6 +81,8 @@ class Meta:
         ordering = ["type", "order"]
 
 IESG_BALLOT_ACTIVE_STATES = ("lc", "writeupw", "goaheadw", "iesg-eva", "defer")
+IESG_CHARTER_ACTIVE_STATES = ("intrev", "extrev", "iesgrev")
+IESG_STATCHG_CONFLREV_ACTIVE_STATES = ("iesgeval", "defer")
 IESG_SUBSTATE_TAGS = ('ad-f-up', 'need-rev', 'extpty')
 
 class DocumentInfo(models.Model):
diff --git a/ietf/doc/views_search.py b/ietf/doc/views_search.py
--- a/ietf/doc/views_search.py
+++ b/ietf/doc/views_search.py
@@ -51,7 +51,9 @@
 import debug                            # pyflakes:ignore
 
 from ietf.doc.models import ( Document, DocHistory, DocAlias, State,
-    LastCallDocEvent, NewRevisionDocEvent, IESG_SUBSTATE_TAGS, IESG_BALLOT_ACTIVE_STATES )
+    LastCallDocEvent, NewRevisionDocEvent, IESG_SUBSTATE_TAGS,
+    IESG_BALLOT_ACTIVE_STATES, IESG_STATCHG_CONFLREV_ACTIVE_STATES,
+    IESG_CHARTER_ACTIVE_STATES )
 from ietf.doc.fields import select2_id_doc_name_json
 from ietf.doc.utils import get_search_cache_key, augment_events_with_revision
 from ietf.group.models import Group
@@ -420,9 +422,9 @@ def docs_for_ad(request, name):
         possible_docs = Document.objects.filter(Q(states__type="draft-iesg",
                                                   states__slug__in=IESG_BALLOT_ACTIVE_STATES) |
                                                 Q(states__type="charter",
-                                                  states__slug__in=("intrev", "iesgrev")) |
+                                                  states__slug__in=IESG_CHARTER_ACTIVE_STATES) |
                                                 Q(states__type__in=("statchg", "conflrev"),
-                                                  states__slug__in=("iesgeval", "defer")),
+                                                  states__slug__in=IESG_STATCHG_CONFLREV_ACTIVE_STATES),
                                                 docevent__ballotpositiondocevent__pos__blocking=True,
                                                 docevent__ballotpositiondocevent__balloter=ad).distinct()
         for doc in possible_docs:
@@ -431,7 +433,6 @@ def docs_for_ad(request, name):
                 continue
 
             blocking_positions = [p for p in ballot.all_positions() if p.pos.blocking]
-
             if not blocking_positions or not any( p.balloter==ad for p in blocking_positions ):
                 continue
 
@@ -446,6 +447,10 @@ def docs_for_ad(request, name):
         if blocked_docs:
             blocked_docs.sort(key=lambda d: min(p.time for p in d.blocking_positions if p.balloter==ad), reverse=True)
 
+        for d in blocked_docs:
+           if d.get_base_name() == 'charter-ietf-shmoo-01-04.txt':
+              print('Is in list')
+
     return render(request, 'doc/drafts_for_ad.html', {
         'form':form, 'docs':results, 'meta':meta, 'ad_name': ad.plain_name(), 'blocked_docs': blocked_docs
     })


Test patch:
diff --git a/ietf/doc/tests.py b/ietf/doc/tests.py
--- a/ietf/doc/tests.py
+++ b/ietf/doc/tests.py
@@ -240,7 +240,7 @@ def test_docs_for_ad(self):
         conflrev.set_state(State.objects.get(type='conflrev', slug='iesgeval'))
         statchg = DocumentFactory(type_id='statchg',ad=ad)
         statchg.set_state(State.objects.get(type='statchg', slug='iesgeval'))
-        charter = CharterFactory(ad=ad)
+        charter = CharterFactory(name='charter-ietf-ames',ad=ad)
         charter.set_state(State.objects.get(type='charter', slug='iesgrev'))
 
         ballot_type = BallotType.objects.get(doc_type_id='draft',slug='approve')
@@ -248,6 +248,13 @@ def test_docs_for_ad(self):
         discuss_pos = BallotPositionName.objects.get(slug='discuss')
         discuss_other = BallotPositionDocEventFactory(ballot=ballot, doc=ballot.doc, balloter=ad, pos=discuss_pos)
 
+        blockedcharter = CharterFactory(name='charter-ietf-mars',ad=ad)
+        blockedcharter.set_state(State.objects.get(type='charter',slug='extrev'))
+        charter_ballot_type = BallotType.objects.get(doc_type_id='charter',slug='approve')
+        charterballot = BallotDocEventFactory(ballot_type=charter_ballot_type, doc__states=[('charter','extrev')])
+        block_pos = BallotPositionName.objects.get(slug='block')
+        block_other = BallotPositionDocEventFactory(ballot=charterballot, doc=ballot.doc, balloter=ad, pos=block_pos)
+
         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)
@@ -258,6 +265,7 @@ def test_docs_for_ad(self):
         self.assertContains(r, charter.name)
 
         self.assertContains(r, discuss_other.doc.name)
+        self.assertContains(r, block_other.doc.name)
 
     def test_auth48_doc_for_ad(self):
         """Docs in AUTH48 state should have a decoration"""