Skip to content

Commit f2fed6a

Browse files
committed
Merged in [10431] from rjsparks@nostrum.com:
Reduce confusion around how to send a document from a WG to the IESG through additional, restrictive, validation on the stream state editing form. Fixes bug ietf-tools#1418. - Legacy-Id: 10445 Note: SVN reference [10431] has been migrated to Git commit 5ee77ca
2 parents c5ad40c + 5ee77ca commit f2fed6a

2 files changed

Lines changed: 39 additions & 3 deletions

File tree

ietf/doc/tests_draft.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,6 +1232,26 @@ def test_set_state(self):
12321232
self.assertTrue("mars-chairs@ietf.org" in unicode(outbox[0]))
12331233
self.assertTrue("marsdelegate@ietf.org" in unicode(outbox[0]))
12341234

1235+
def test_pubreq_validation(self):
1236+
draft = make_test_data()
1237+
1238+
url = urlreverse('doc_change_stream_state', kwargs=dict(name=draft.name, state_type="draft-stream-ietf"))
1239+
login_testing_unauthorized(self, "marschairman", url)
1240+
1241+
old_state = draft.get_state("draft-stream-%s" % draft.stream_id )
1242+
new_state = State.objects.get(used=True, type="draft-stream-%s" % draft.stream_id, slug="sub-pub")
1243+
self.assertNotEqual(old_state, new_state)
1244+
1245+
r = self.client.post(url,
1246+
dict(new_state=new_state.pk,
1247+
comment="some comment",
1248+
weeks="10",
1249+
tags=[t.pk for t in draft.tags.filter(slug__in=get_tags_for_stream_id(draft.stream_id))],
1250+
))
1251+
self.assertEqual(r.status_code, 200)
1252+
q = PyQuery(r.content)
1253+
self.assertTrue(len(q('form .has-error')) > 0)
1254+
12351255
class ChangeReplacesTests(TestCase):
12361256
def setUp(self):
12371257

ietf/doc/views_draft.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,14 +1320,16 @@ def adopt_draft(request, name):
13201320
context_instance=RequestContext(request))
13211321

13221322
class ChangeStreamStateForm(forms.Form):
1323-
new_state = forms.ModelChoiceField(queryset=State.objects.filter(used=True), label='State', help_text=u"Only select 'Submitted to IESG for Publication' to correct errors. Use the document's main page to request publication.")
1323+
new_state = forms.ModelChoiceField(queryset=State.objects.filter(used=True), label='State' )
13241324
weeks = forms.IntegerField(label='Expected weeks in state',required=False)
13251325
comment = forms.CharField(widget=forms.Textarea, required=False, help_text="Optional comment for the document history.")
13261326
tags = forms.ModelMultipleChoiceField(queryset=DocTagName.objects.filter(used=True), widget=forms.CheckboxSelectMultiple, required=False)
13271327

13281328
def __init__(self, *args, **kwargs):
13291329
doc = kwargs.pop("doc")
13301330
state_type = kwargs.pop("state_type")
1331+
self.can_set_sub_pub = kwargs.pop("can_set_sub_pub")
1332+
self.stream = kwargs.pop("stream")
13311333
super(ChangeStreamStateForm, self).__init__(*args, **kwargs)
13321334

13331335
f = self.fields["new_state"]
@@ -1336,13 +1338,25 @@ def __init__(self, *args, **kwargs):
13361338
unused_states = doc.group.unused_states.values_list("pk", flat=True)
13371339
f.queryset = f.queryset.exclude(pk__in=unused_states)
13381340
f.label = state_type.label
1341+
if self.stream.slug == 'ietf':
1342+
if self.can_set_sub_pub:
1343+
f.help_text = u"Only select 'Submitted to IESG for Publication' to correct errors. Use the document's main page to request publication."
1344+
else:
1345+
f.help_text = u"You may not set the 'Submitted to IESG for Publication' using this form - Use the document's main page to request publication."
13391346

13401347
f = self.fields['tags']
13411348
f.queryset = f.queryset.filter(slug__in=get_tags_for_stream_id(doc.stream_id))
13421349
if doc.group:
13431350
unused_tags = doc.group.unused_tags.values_list("pk", flat=True)
13441351
f.queryset = f.queryset.exclude(pk__in=unused_tags)
13451352

1353+
def clean_new_state(self):
1354+
new_state = self.cleaned_data.get('new_state')
1355+
if new_state.slug=='sub-pub' and not self.can_set_sub_pub:
1356+
raise forms.ValidationError('You may not set the %s state using this form. Use the "Submit to IESG for publication" button on the document\'s main page instead. If that button does not appear, the document may already have IESG state. Ask your Area Director or the Secretariat for help.'%new_state.name)
1357+
return new_state
1358+
1359+
13461360
def next_states_for_stream_state(doc, state_type, current_state):
13471361
# find next states
13481362
next_states = []
@@ -1379,8 +1393,10 @@ def change_stream_state(request, name, state_type):
13791393
prev_state = doc.get_state(state_type.slug)
13801394
next_states = next_states_for_stream_state(doc, state_type, prev_state)
13811395

1396+
can_set_sub_pub = has_role(request.user,('Secretariat','Area Director')) or prev_state.slug=='sub-pub'
1397+
13821398
if request.method == 'POST':
1383-
form = ChangeStreamStateForm(request.POST, doc=doc, state_type=state_type)
1399+
form = ChangeStreamStateForm(request.POST, doc=doc, state_type=state_type,can_set_sub_pub=can_set_sub_pub,stream=doc.stream)
13841400
if form.is_valid():
13851401
by = request.user.person
13861402

@@ -1432,7 +1448,7 @@ def change_stream_state(request, name, state_type):
14321448
return HttpResponseRedirect(doc.get_absolute_url())
14331449
else:
14341450
form = ChangeStreamStateForm(initial=dict(new_state=prev_state.pk if prev_state else None, tags= doc.tags.all()),
1435-
doc=doc, state_type=state_type)
1451+
doc=doc, state_type=state_type, can_set_sub_pub = can_set_sub_pub,stream = doc.stream)
14361452

14371453
milestones = doc.groupmilestone_set.all()
14381454

0 commit comments

Comments
 (0)