Skip to content

Commit e30ba32

Browse files
committed
Fixed calculation of needed ballots for status-change documents. Added needed ballots tests for drafts and status-change docs. Fixes bug 1116. Commit ready for merge
- Legacy-Id: 7586
1 parent 9b43e15 commit e30ba32

2 files changed

Lines changed: 37 additions & 6 deletions

File tree

ietf/doc/tests.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,31 @@ def test_document_ballot(self):
244244
r = self.client.get(urlreverse("ietf.doc.views_doc.ballot_popup", kwargs=dict(name=doc.name, ballot_id=ballot.pk)))
245245
self.assertEqual(r.status_code, 200)
246246

247+
def test_document_ballot_needed_positions(self):
248+
make_test_data()
249+
250+
# draft
251+
doc = Document.objects.get(name='draft-ietf-mars-test')
252+
r = self.client.get(urlreverse("ietf.doc.views_doc.document_ballot", kwargs=dict(name=doc.name)))
253+
self.assertTrue('more YES or NO' in r.content)
254+
Document.objects.filter(pk=doc.pk).update(intended_std_level='inf')
255+
r = self.client.get(urlreverse("ietf.doc.views_doc.document_ballot", kwargs=dict(name=doc.name)))
256+
self.assertFalse('more YES or NO' in r.content)
257+
258+
# status change
259+
doc = Document.objects.get(name='status-change-imaginary-mid-review')
260+
iesgeval_pk = str(State.objects.get(slug='iesgeval',type__slug='statchg').pk)
261+
self.client.login(remote_user='ad')
262+
r = self.client.post(urlreverse('ietf.doc.views_status_change.change_state',kwargs=dict(name=doc.name)),dict(new_state=iesgeval_pk))
263+
self.assertEqual(r.status_code, 302)
264+
doc.relateddocument_set.create(target=DocAlias.objects.get(name='rfc9998'),relationship_id='tohist')
265+
r = self.client.get(urlreverse("ietf.doc.views_doc.document_ballot", kwargs=dict(name=doc.name)))
266+
self.assertFalse('Needs a YES' in r.content)
267+
self.assertFalse('more YES or NO' in r.content)
268+
doc.relateddocument_set.create(target=DocAlias.objects.get(name='rfc9999'),relationship_id='tois')
269+
r = self.client.get(urlreverse("ietf.doc.views_doc.document_ballot", kwargs=dict(name=doc.name)))
270+
self.assertTrue('more YES or NO' in r.content)
271+
247272
def test_document_json(self):
248273
doc = make_test_data()
249274

ietf/doc/utils.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from ietf.name.models import DocReminderTypeName, DocRelationshipName
1212
from ietf.group.models import Role
1313
from ietf.ietfauth.utils import has_role
14-
from ietf.person.models import Person
1514
from ietf.utils import draft
1615

1716
def get_state_types(doc):
@@ -59,6 +58,12 @@ def can_adopt_draft(user, doc):
5958
group__state="active",
6059
person__user=user).exists())
6160

61+
62+
def two_thirds_rule( recused=0 ):
63+
# For standards-track, need positions from 2/3 of the non-recused current IESG.
64+
active = Role.objects.filter(name="ad",group__state="active").count()
65+
return int(math.ceil((active - recused) * 2.0/3.0))
66+
6267
def needed_ballot_positions(doc, active_positions):
6368
'''Returns text answering the question "what does this document
6469
need to pass?". The return value is only useful if the document
@@ -81,11 +86,12 @@ def needed_ballot_positions(doc, active_positions):
8186
answer.append("Has %d %ss." % (len(blocking), blocking[0].pos.name.upper()))
8287
needed = 1
8388
if doc.type_id == "draft" and doc.intended_std_level_id in ("bcp", "ps", "ds", "std"):
84-
# For standards-track, need positions from 2/3 of the
85-
# non-recused current IESG.
86-
active = len(Person.objects.filter(role__name="ad",
87-
role__group__state="active").distinct())
88-
needed = int(math.ceil((active - len(recuse)) * 2.0/3.0))
89+
needed = two_thirds_rule(recused=len(recuse))
90+
elif doc.type_id == "statchg":
91+
for rel in doc.relateddocument_set.filter(relationship__slug__in=['tops', 'tois', 'tohist', 'toinf', 'tobcp', 'toexp']):
92+
if (rel.target.document.std_level.slug in ['bcp','ps','ds','std']) or (rel.relationship.slug in ['tops','tois','tobcp']):
93+
needed = two_thirds_rule(recused=len(recuse))
94+
break
8995
else:
9096
if len(yes) < 1:
9197
return " ".join(answer)

0 commit comments

Comments
 (0)