Skip to content

Commit 076770b

Browse files
committed
Merged [7705] from rjsparks@nostrum.com: Corrected Document vs DocHistory mismatch when working with status-change documents. Corrected creation of BallotDocEvent timestamps. Fixes bug ietf-tools#1396.
- Legacy-Id: 7724 Note: SVN reference [7705] has been migrated to Git commit 18bfe66
2 parents 93cf098 + 18bfe66 commit 076770b

3 files changed

Lines changed: 26 additions & 4 deletions

File tree

ietf/doc/tests_status_change.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,11 @@ def test_subsequent_submission(self):
422422
with open(path,'w') as f:
423423
f.write('This is the old proposal.')
424424
f.close()
425+
# Put the old proposal into IESG review (exercises ballot tab when looking at an older revision below)
426+
state_change_url = urlreverse('status_change_change_state',kwargs=dict(name=doc.name))
427+
iesgeval_pk = str(State.objects.get(slug='iesgeval',type__slug='statchg').pk)
428+
r = self.client.post(state_change_url,dict(new_state=iesgeval_pk))
429+
self.assertEqual(r.status_code, 302)
425430

426431
# normal get
427432
r = self.client.get(url)
@@ -457,6 +462,12 @@ def test_subsequent_submission(self):
457462
q = PyQuery(r.content)
458463
self.assertTrue(q('textarea')[0].text.strip().startswith("Provide a description"))
459464

465+
# make sure we can see the old revision
466+
url = urlreverse('doc_view',kwargs=dict(name=doc.name,rev='00'))
467+
r = self.client.get(url)
468+
self.assertEqual(r.status_code,200)
469+
self.assertTrue("This is the old proposal." in r.content)
470+
460471
def setUp(self):
461472
make_test_data()
462473
self.test_dir = os.path.abspath("tmp-status-change-testdir")

ietf/doc/utils.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
import math
55

66
from django.conf import settings
7+
from django.db.models.query import EmptyQuerySet
78

89
from ietf.utils import markup_txt
10+
from ietf.doc.models import Document, DocHistory
911
from ietf.doc.models import DocAlias, RelatedDocument, BallotType, DocReminder
1012
from ietf.doc.models import DocEvent, BallotDocEvent, NewRevisionDocEvent, StateDocEvent
1113
from ietf.name.models import DocReminderTypeName, DocRelationshipName
@@ -88,7 +90,13 @@ def needed_ballot_positions(doc, active_positions):
8890
if doc.type_id == "draft" and doc.intended_std_level_id in ("bcp", "ps", "ds", "std"):
8991
needed = two_thirds_rule(recused=len(recuse))
9092
elif doc.type_id == "statchg":
91-
for rel in doc.relateddocument_set.filter(relationship__slug__in=['tops', 'tois', 'tohist', 'toinf', 'tobcp', 'toexp']):
93+
if isinstance(doc,Document):
94+
related_set = doc.relateddocument_set
95+
elif isinstance(doc,DocHistory):
96+
related_set = doc.relateddochistory_set
97+
else:
98+
related_set = EmptyQuerySet()
99+
for rel in related_set.filter(relationship__slug__in=['tops', 'tois', 'tohist', 'toinf', 'tobcp', 'toexp']):
92100
if (rel.target.document.std_level.slug in ['bcp','ps','ds','std']) or (rel.relationship.slug in ['tops','tois','tobcp']):
93101
needed = two_thirds_rule(recused=len(recuse))
94102
break
@@ -111,9 +119,12 @@ def needed_ballot_positions(doc, active_positions):
111119

112120
return " ".join(answer)
113121

114-
def create_ballot_if_not_open(doc, by, ballot_slug):
122+
def create_ballot_if_not_open(doc, by, ballot_slug, time=None):
115123
if not doc.ballot_open(ballot_slug):
116-
e = BallotDocEvent(type="created_ballot", by=by, doc=doc)
124+
if time:
125+
e = BallotDocEvent(type="created_ballot", by=by, doc=doc, time=time)
126+
else:
127+
e = BallotDocEvent(type="created_ballot", by=by, doc=doc)
117128
e.ballot_type = BallotType.objects.get(doc_type=doc.type, slug=ballot_slug)
118129
e.desc = u'Created "%s" ballot' % e.ballot_type.name
119130
e.save()

ietf/doc/views_status_change.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def change_state(request, name, option=None):
5959
status_change.save()
6060

6161
if new_state.slug == "iesgeval":
62-
create_ballot_if_not_open(status_change, login, "statchg")
62+
create_ballot_if_not_open(status_change, login, "statchg", e.time)
6363
ballot = status_change.latest_event(BallotDocEvent, type="created_ballot")
6464
if has_role(request.user, "Area Director") and not status_change.latest_event(BallotPositionDocEvent, ad=login, ballot=ballot, type="changed_ballot_position"):
6565

0 commit comments

Comments
 (0)