Corrected Document vs DocHistory mismatch when working with status-change documents. Corrected creation of BallotDocEvent timestamps. Fixes bug #1396. Commit ready for merge
- Legacy-Id: 7705
This commit is contained in:
parent
cb458b1689
commit
18bfe663d5
|
@ -422,6 +422,11 @@ class StatusChangeSubmitTests(TestCase):
|
|||
with open(path,'w') as f:
|
||||
f.write('This is the old proposal.')
|
||||
f.close()
|
||||
# Put the old proposal into IESG review (exercises ballot tab when looking at an older revision below)
|
||||
state_change_url = urlreverse('status_change_change_state',kwargs=dict(name=doc.name))
|
||||
iesgeval_pk = str(State.objects.get(slug='iesgeval',type__slug='statchg').pk)
|
||||
r = self.client.post(state_change_url,dict(new_state=iesgeval_pk))
|
||||
self.assertEqual(r.status_code, 302)
|
||||
|
||||
# normal get
|
||||
r = self.client.get(url)
|
||||
|
@ -457,6 +462,12 @@ class StatusChangeSubmitTests(TestCase):
|
|||
q = PyQuery(r.content)
|
||||
self.assertTrue(q('textarea')[0].text.strip().startswith("Provide a description"))
|
||||
|
||||
# make sure we can see the old revision
|
||||
url = urlreverse('doc_view',kwargs=dict(name=doc.name,rev='00'))
|
||||
r = self.client.get(url)
|
||||
self.assertEqual(r.status_code,200)
|
||||
self.assertTrue("This is the old proposal." in r.content)
|
||||
|
||||
def setUp(self):
|
||||
make_test_data()
|
||||
self.test_dir = os.path.abspath("tmp-status-change-testdir")
|
||||
|
|
|
@ -50,7 +50,7 @@ urlpatterns = patterns('',
|
|||
url(r'^all/$', views_search.index_all_drafts, name="index_all_drafts"),
|
||||
url(r'^active/$', views_search.index_active_drafts, name="index_active_drafts"),
|
||||
|
||||
url(r'^(?P<name>[A-Za-z0-9._+-]+)/((?P<rev>[0-9-]+)/)?$', views_doc.document_main, name="doc_view"),
|
||||
url(r'^(?P<name>[A-Za-z0-9._+-]+)/(?:(?P<rev>[0-9-]+)/)?$', views_doc.document_main, name="doc_view"),
|
||||
url(r'^(?P<name>[A-Za-z0-9._+-]+)/history/$', views_doc.document_history, name="doc_history"),
|
||||
url(r'^(?P<name>[A-Za-z0-9._+-]+)/writeup/$', views_doc.document_writeup, name="doc_writeup"),
|
||||
url(r'^(?P<name>[A-Za-z0-9._+-]+)/shepherdwriteup/$', views_doc.document_shepherd_writeup, name="doc_shepherd_writeup"),
|
||||
|
|
|
@ -4,8 +4,10 @@ import urllib
|
|||
import math
|
||||
|
||||
from django.conf import settings
|
||||
from django.db.models.query import EmptyQuerySet
|
||||
|
||||
from ietf.utils import markup_txt
|
||||
from ietf.doc.models import Document, DocHistory
|
||||
from ietf.doc.models import DocAlias, RelatedDocument, BallotType, DocReminder
|
||||
from ietf.doc.models import DocEvent, BallotDocEvent, NewRevisionDocEvent, StateDocEvent
|
||||
from ietf.name.models import DocReminderTypeName, DocRelationshipName
|
||||
|
@ -88,7 +90,13 @@ def needed_ballot_positions(doc, active_positions):
|
|||
if doc.type_id == "draft" and doc.intended_std_level_id in ("bcp", "ps", "ds", "std"):
|
||||
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 isinstance(doc,Document):
|
||||
related_set = doc.relateddocument_set
|
||||
elif isinstance(doc,DocHistory):
|
||||
related_set = doc.relateddochistory_set
|
||||
else:
|
||||
related_set = EmptyQuerySet()
|
||||
for rel in related_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
|
||||
|
@ -111,9 +119,12 @@ def needed_ballot_positions(doc, active_positions):
|
|||
|
||||
return " ".join(answer)
|
||||
|
||||
def create_ballot_if_not_open(doc, by, ballot_slug):
|
||||
def create_ballot_if_not_open(doc, by, ballot_slug, time=None):
|
||||
if not doc.ballot_open(ballot_slug):
|
||||
e = BallotDocEvent(type="created_ballot", by=by, doc=doc)
|
||||
if time:
|
||||
e = BallotDocEvent(type="created_ballot", by=by, doc=doc, time=time)
|
||||
else:
|
||||
e = BallotDocEvent(type="created_ballot", by=by, doc=doc)
|
||||
e.ballot_type = BallotType.objects.get(doc_type=doc.type, slug=ballot_slug)
|
||||
e.desc = u'Created "%s" ballot' % e.ballot_type.name
|
||||
e.save()
|
||||
|
|
|
@ -59,7 +59,7 @@ def change_state(request, name, option=None):
|
|||
status_change.save()
|
||||
|
||||
if new_state.slug == "iesgeval":
|
||||
create_ballot_if_not_open(status_change, login, "statchg")
|
||||
create_ballot_if_not_open(status_change, login, "statchg", e.time)
|
||||
ballot = status_change.latest_event(BallotDocEvent, type="created_ballot")
|
||||
if has_role(request.user, "Area Director") and not status_change.latest_event(BallotPositionDocEvent, ad=login, ballot=ballot, type="changed_ballot_position"):
|
||||
|
||||
|
|
Loading…
Reference in a new issue