Skip to content

Commit 74966fa

Browse files
committed
Fix URL schema of change stream state to use the state type (to be
more in line with the IANA ones), remove debug output, link to the new change state page from the draft main page - Legacy-Id: 6295
1 parent 8c88bc5 commit 74966fa

6 files changed

Lines changed: 14 additions & 11 deletions

File tree

ietf/doc/tests_draft.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@ def test_set_tags(self):
10301030
draft.tags = DocTagName.objects.filter(slug="w-expert")
10311031
draft.group.unused_tags.add("w-refdoc")
10321032

1033-
url = urlreverse('doc_change_stream_state', kwargs=dict(name=draft.name))
1033+
url = urlreverse('doc_change_stream_state', kwargs=dict(name=draft.name, state_type="draft-stream-ietf"))
10341034
login_testing_unauthorized(self, "marschairman", url)
10351035

10361036
# get
@@ -1068,7 +1068,7 @@ def test_set_tags(self):
10681068
def test_set_state(self):
10691069
draft = make_test_data()
10701070

1071-
url = urlreverse('doc_change_stream_state', kwargs=dict(name=draft.name))
1071+
url = urlreverse('doc_change_stream_state', kwargs=dict(name=draft.name, state_type="draft-stream-ietf"))
10721072
login_testing_unauthorized(self, "marschairman", url)
10731073

10741074
# get

ietf/doc/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
url(r'^(?P<name>[A-Za-z0-9._+-]+)/edit/shepherdwriteup/$', views_draft.edit_shepherd_writeup, name='doc_edit_shepherd_writeup'),
8888
url(r'^(?P<name>[A-Za-z0-9._+-]+)/edit/requestpublication/$', views_draft.request_publication, name='doc_request_publication'),
8989
url(r'^(?P<name>[A-Za-z0-9._+-]+)/edit/adopt/$', views_draft.adopt_draft, name='doc_adopt_draft'),
90-
url(r'^(?P<name>[A-Za-z0-9._+-]+)/edit/state/stream/$', views_draft.change_stream_state, name='doc_change_stream_state'),
90+
url(r'^(?P<name>[A-Za-z0-9._+-]+)/edit/state/(?P<state_type>draft-stream-[a-z]+)/$', views_draft.change_stream_state, name='doc_change_stream_state'),
9191

9292
url(r'^(?P<name>[A-Za-z0-9._+-]+)/edit/clearballot/$', views_ballot.clear_ballot, name='doc_clear_ballot'),
9393
url(r'^(?P<name>[A-Za-z0-9._+-]+)/edit/deferballot/$', views_ballot.defer_ballot, name='doc_defer_ballot'),

ietf/doc/views_doc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,11 @@ def document_main(request, name, rev=None):
258258
resurrected_by = e.by
259259

260260
# stream info
261+
stream_state_type_slug = None
261262
stream_state = None
262263
if doc.stream:
263-
stream_state = doc.get_state("draft-stream-%s" % doc.stream_id)
264+
stream_state_type_slug = "draft-stream-%s" % doc.stream_id
265+
stream_state = doc.get_state(stream_state_type_slug)
264266
stream_tags = doc.tags.filter(slug__in=get_tags_for_stream_id(doc.stream_id))
265267

266268
shepherd_writeup = doc.latest_event(WriteupDocEvent, type="changed_protocol_writeup")
@@ -356,6 +358,7 @@ def document_main(request, name, rev=None):
356358
has_errata=doc.tags.filter(slug="errata"),
357359
published=doc.latest_event(type="published_rfc"),
358360
file_urls=file_urls,
361+
stream_state_type_slug=stream_state_type_slug,
359362
stream_state=stream_state,
360363
stream_tags=stream_tags,
361364
milestones=doc.groupmilestone_set.filter(state="active"),

ietf/doc/views_draft.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,7 +1198,7 @@ def adopt_draft(request, name):
11981198
context_instance=RequestContext(request))
11991199

12001200
class ChangeStreamStateForm(forms.Form):
1201-
new_state = forms.ModelChoiceField(queryset=State.objects.filter(used=True), label='State')
1201+
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.")
12021202
weeks = forms.IntegerField(label='Expected weeks in state',required=False)
12031203
comment = forms.CharField(widget=forms.Textarea, required=False, help_text="Optional comment for the document history")
12041204
tags = forms.ModelMultipleChoiceField(queryset=DocTagName.objects.filter(used=True), widget=forms.CheckboxSelectMultiple, required=False)
@@ -1244,15 +1244,16 @@ def next_states_for_stream_state(doc, state_type, current_state):
12441244
return next_states
12451245

12461246
@login_required
1247-
def change_stream_state(request, name):
1247+
def change_stream_state(request, name, state_type):
12481248
doc = get_object_or_404(Document, type="draft", name=name)
12491249
if not doc.stream:
12501250
raise Http404
12511251

1252+
state_type = get_object_or_404(StateType, slug=state_type)
1253+
12521254
if not is_authorized_in_doc_stream(request.user, doc):
12531255
return HttpResponseForbidden("You don't have permission to access this page")
12541256

1255-
state_type = StateType.objects.get(slug="draft-stream-%s" % doc.stream_id)
12561257
prev_state = doc.get_state(state_type.slug)
12571258
next_states = next_states_for_stream_state(doc, state_type, prev_state)
12581259

@@ -1308,7 +1309,7 @@ def change_stream_state(request, name):
13081309

13091310
return HttpResponseRedirect(doc.get_absolute_url())
13101311
else:
1311-
form = ChangeStreamStateForm(initial=dict(new_state=prev_state.pk),
1312+
form = ChangeStreamStateForm(initial=dict(new_state=prev_state.pk if prev_state else None),
13121313
doc=doc, state_type=state_type)
13131314

13141315
milestones = doc.groupmilestone_set.all()

ietf/templates/doc/document_draft.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
{% if doc.stream %}
9696
<td>{{ doc.stream }} State:</td>
9797
<td class="stream-state">
98-
<a {% if doc.stream and can_edit_stream_info %}class="editlink" href="{% url edit_state name=doc.name %}"{% endif %}>
98+
<a {% if doc.stream and can_edit_stream_info %}class="editlink" href="{% url doc_change_stream_state name=doc.name state_type=stream_state_type_slug %}"{% endif %}>
9999
{{ stream_state|default:"(None)" }}
100100
</a>
101101

ietf/templates/doc/draft/change_stream_state.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ <h1>Change {{ state_type.label }} of {{ doc }}</h1>
3232

3333
{% if next_states %}
3434
<div class="next-states">
35-
<span>Recommended next state{{next_states|pluralize}}:</span>
35+
<span>Recommended next state{{ next_states|pluralize }}:</span>
3636
{% for state in next_states %}<a tabindex="0" data-state="{{ state.pk }}">{{ state.name }}</a> {% if not forloop.last %} or {% endif %}{% endfor %}
3737
</div>
3838
{% endif %}
@@ -65,7 +65,6 @@ <h1>Change {{ state_type.label }} of {{ doc }}</h1>
6565
jQuery(".next-states a").click(function (e) {
6666
e.preventDefault();
6767
var s = jQuery(this).data("state");
68-
console.log(s)
6968
jQuery("#id_new_state").val(s);
7069
});
7170
});

0 commit comments

Comments
 (0)