Skip to content

Commit

Permalink
Fixed calculation of needed ballots for status-change documents. Adde…
Browse files Browse the repository at this point in the history
…d needed ballots tests for drafts and status-change docs. Fixes bug 1116. Commit ready for merge

 - Legacy-Id: 7586
  • Loading branch information
rjsparks committed Apr 9, 2014
1 parent 9b43e15 commit e30ba32
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 6 deletions.
25 changes: 25 additions & 0 deletions ietf/doc/tests.py
Expand Up @@ -244,6 +244,31 @@ def test_document_ballot(self):
r = self.client.get(urlreverse("ietf.doc.views_doc.ballot_popup", kwargs=dict(name=doc.name, ballot_id=ballot.pk)))
self.assertEqual(r.status_code, 200)

def test_document_ballot_needed_positions(self):
make_test_data()

# draft
doc = Document.objects.get(name='draft-ietf-mars-test')
r = self.client.get(urlreverse("ietf.doc.views_doc.document_ballot", kwargs=dict(name=doc.name)))
self.assertTrue('more YES or NO' in r.content)
Document.objects.filter(pk=doc.pk).update(intended_std_level='inf')
r = self.client.get(urlreverse("ietf.doc.views_doc.document_ballot", kwargs=dict(name=doc.name)))
self.assertFalse('more YES or NO' in r.content)

# status change
doc = Document.objects.get(name='status-change-imaginary-mid-review')
iesgeval_pk = str(State.objects.get(slug='iesgeval',type__slug='statchg').pk)
self.client.login(remote_user='ad')
r = self.client.post(urlreverse('ietf.doc.views_status_change.change_state',kwargs=dict(name=doc.name)),dict(new_state=iesgeval_pk))
self.assertEqual(r.status_code, 302)
doc.relateddocument_set.create(target=DocAlias.objects.get(name='rfc9998'),relationship_id='tohist')
r = self.client.get(urlreverse("ietf.doc.views_doc.document_ballot", kwargs=dict(name=doc.name)))
self.assertFalse('Needs a YES' in r.content)
self.assertFalse('more YES or NO' in r.content)
doc.relateddocument_set.create(target=DocAlias.objects.get(name='rfc9999'),relationship_id='tois')
r = self.client.get(urlreverse("ietf.doc.views_doc.document_ballot", kwargs=dict(name=doc.name)))
self.assertTrue('more YES or NO' in r.content)

def test_document_json(self):
doc = make_test_data()

Expand Down
18 changes: 12 additions & 6 deletions ietf/doc/utils.py
Expand Up @@ -11,7 +11,6 @@
from ietf.name.models import DocReminderTypeName, DocRelationshipName
from ietf.group.models import Role
from ietf.ietfauth.utils import has_role
from ietf.person.models import Person
from ietf.utils import draft

def get_state_types(doc):
Expand Down Expand Up @@ -59,6 +58,12 @@ def can_adopt_draft(user, doc):
group__state="active",
person__user=user).exists())


def two_thirds_rule( recused=0 ):
# For standards-track, need positions from 2/3 of the non-recused current IESG.
active = Role.objects.filter(name="ad",group__state="active").count()
return int(math.ceil((active - recused) * 2.0/3.0))

def needed_ballot_positions(doc, active_positions):
'''Returns text answering the question "what does this document
need to pass?". The return value is only useful if the document
Expand All @@ -81,11 +86,12 @@ def needed_ballot_positions(doc, active_positions):
answer.append("Has %d %ss." % (len(blocking), blocking[0].pos.name.upper()))
needed = 1
if doc.type_id == "draft" and doc.intended_std_level_id in ("bcp", "ps", "ds", "std"):
# For standards-track, need positions from 2/3 of the
# non-recused current IESG.
active = len(Person.objects.filter(role__name="ad",
role__group__state="active").distinct())
needed = int(math.ceil((active - len(recuse)) * 2.0/3.0))
needed = two_thirds_rule(recused=len(recuse))
elif doc.type_id == "statchg":
for rel in doc.relateddocument_set.filter(relationship__slug__in=['tops', 'tois', 'tohist', 'toinf', 'tobcp', 'toexp']):
if (rel.target.document.std_level.slug in ['bcp','ps','ds','std']) or (rel.relationship.slug in ['tops','tois','tobcp']):
needed = two_thirds_rule(recused=len(recuse))
break
else:
if len(yes) < 1:
return " ".join(answer)
Expand Down

0 comments on commit e30ba32

Please sign in to comment.