Merged in [7586] from rjsparks@nostrum.com:

Fixed calculation of needed ballots for status-change documents. Added needed ballots tests for drafts and status-change docs. Fixes bug 1116.
 - Legacy-Id: 7606
Note: SVN reference [7586] has been migrated to Git commit e30ba32c78cf324f5875fcce3f89ff7e27f8453c
This commit is contained in:
Henrik Levkowetz 2014-04-13 19:36:06 +00:00
parent b448ac4da0
commit c50fccdb7e
2 changed files with 41 additions and 6 deletions

View file

@ -244,6 +244,35 @@ class DocTestCase(TestCase):
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)
# login = self.client.login(username='ad', password='ad+password')
# self.assertTrue(login)
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)
import debug
debug.debug = True
debug.show('dir(r)')
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()

View file

@ -11,7 +11,6 @@ from ietf.doc.models import DocEvent, BallotDocEvent, NewRevisionDocEvent, State
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):
@ -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
@ -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)