Skip to content

Commit 7488ade

Browse files
committed
Fixed a bug in /help/state/ (bad links). Linked additional state labels in the document pages to the state descriptions under /help/state. Renamed a template file to better match its function.
- Legacy-Id: 9410
1 parent 786208e commit 7488ade

5 files changed

Lines changed: 47 additions & 10 deletions

File tree

ietf/help/tests_views.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"""
2+
This file demonstrates two different styles of tests (one doctest and one
3+
unittest). These will both pass when you run "manage.py test".
4+
5+
Replace these with more appropriate tests for your application.
6+
"""
7+
8+
from pyquery import PyQuery
9+
10+
from django.core.urlresolvers import reverse
11+
12+
import debug # pyflakes:ignore
13+
14+
from ietf.utils.test_utils import TestCase
15+
from ietf.doc.models import StateType
16+
17+
class StateHelpTest(TestCase):
18+
19+
def test_state_index(self):
20+
url = reverse('ietf.help.views.state_index')
21+
r = self.client.get(url)
22+
q = PyQuery(r.content)
23+
content = [ e.text for e in q('#content table td a ') ]
24+
names = StateType.objects.values_list('slug', flat=True)
25+
# The following doesn't cover all doc types, only a selection
26+
for name in names:
27+
if not '-' in name:
28+
self.assertIn(name, content)
29+
30+

ietf/help/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
urlpatterns = patterns('',
44
url(r'^state/(?P<doc>[-\w]+)/(?P<type>[-\w]+)/?$', 'ietf.help.views.state'),
55
url(r'^state/(?P<doc>[-\w]+)/?$', 'ietf.help.views.state'),
6-
url(r'^state/?$', 'ietf.help.views.index'),
6+
url(r'^state/?$', 'ietf.help.views.state_index'),
77
)
88

ietf/help/views.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
import debug # pyflakes:ignore
99

1010
from ietf.doc.models import State, StateType
11+
from ietf.name.models import StreamName
1112

12-
13-
def index(request):
13+
def state_index(request):
1414
types = StateType.objects.all()
1515
names = [ type.slug for type in types ]
1616
for type in types:
@@ -20,10 +20,17 @@ def index(request):
2020
groups = StateType.objects.filter(slug__startswith=type.slug)
2121
type.stategroups = [ g.slug[len(type.slug)+1:] for g in groups if not g == type ] or ""
2222

23-
return render_to_response('help/index.html', {"types": types},
23+
return render_to_response('help/state_index.html', {"types": types},
2424
context_instance=RequestContext(request))
2525

2626
def state(request, doc, type=None):
27+
if type:
28+
debug.show('type')
29+
streams = [ s.slug for s in StreamName.objects.all() ]
30+
debug.show('streams')
31+
if type in streams:
32+
type = "stream-%s" % type
33+
debug.show('type')
2734
slug = "%s-%s" % (doc,type) if type else doc
2835
statetype = get_object_or_404(StateType, slug=slug)
2936
states = State.objects.filter(used=True, type=statetype).order_by('order')

ietf/templates/doc/document_draft.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130

131131
<tr>
132132
{% if doc.stream %}
133-
<th>{{ doc.stream }} state</th>
133+
<th><a href="{% url "ietf.help.views.state" doc=doc.type.slug type=doc.stream.slug %}">{{ doc.stream }} state</th>
134134
<td class="edit">
135135
{% if doc.stream and can_edit_stream_info %}
136136
<a class="btn btn-default btn-xs" href="{% url "doc_change_stream_state" name=doc.name state_type=stream_state_type_slug %}">Edit</a>
@@ -211,7 +211,7 @@
211211
{% endif %}
212212

213213
<tr>
214-
<th><a href="{% url "state_help" "draft-iesg" %}">IESG state</a></th>
214+
<th><a href="{% url "ietf.help.views.state" doc=doc.type.slug type="iesg" %}">IESG state</a></th>
215215
<td class="edit">
216216
{% if iesg_state and can_edit %}
217217
<a class="btn btn-default btn-xs" href="{% url "doc_change_state" name=doc.name %}">Edit</a>
@@ -224,7 +224,7 @@
224224

225225
{% if iana_review_state %}
226226
<tr>
227-
<th>IANA review state</th>
227+
<th><a href="{% url "ietf.help.views.state" doc=doc.type.slug type="iana-review" %}">IANA review state</a></th>
228228
<td class="edit">
229229
{% if can_edit_iana_state %}
230230
<a class="btn btn-default btn-xs" href="{% url "doc_change_iana_state" name=doc.name state_type="iana-review" %}">Edit</a>
@@ -250,7 +250,7 @@
250250

251251
{% if rfc_editor_state %}
252252
<tr>
253-
<th>RFC Editor state</th>
253+
<th><a href="{% url "ietf.help.views.state" doc=doc.type.slug type="rfceditor" %}">RFC Editor state</a></th>
254254
<td class="edit"></td>
255255
<td><a href="//www.rfc-editor.org/queue2.html#{{ doc.name }}">{{ rfc_editor_state }}</a></td>
256256
</tr>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ <h1>Document state index</h1>
2020
{% for type in types %}
2121
{% if type.stategroups != None %}
2222
<tr>
23-
<td><a href='state/{{ type.slug }}/'>{{type.slug}}</a></td>
23+
<td><a href='{{ type.slug }}/'>{{type.slug}}</a></td>
2424
<td>
2525
{% for group in type.stategroups %}
26-
<a href='state/{{ type.slug }}/{{ group }}'>{{ group }}</a>{% if not forloop.last %}, {% endif %}
26+
<a href='{{ type.slug }}/{{ group }}'>{{ group }}</a>{% if not forloop.last %}, {% endif %}
2727
{% endfor %}
2828
</td>
2929
</tr>

0 commit comments

Comments
 (0)