diff --git a/ietf/help/tests_views.py b/ietf/help/tests_views.py new file mode 100644 index 000000000..256673eea --- /dev/null +++ b/ietf/help/tests_views.py @@ -0,0 +1,30 @@ +""" +This file demonstrates two different styles of tests (one doctest and one +unittest). These will both pass when you run "manage.py test". + +Replace these with more appropriate tests for your application. +""" + +from pyquery import PyQuery + +from django.core.urlresolvers import reverse + +import debug # pyflakes:ignore + +from ietf.utils.test_utils import TestCase +from ietf.doc.models import StateType + +class StateHelpTest(TestCase): + + def test_state_index(self): + url = reverse('ietf.help.views.state_index') + r = self.client.get(url) + q = PyQuery(r.content) + content = [ e.text for e in q('#content table td a ') ] + names = StateType.objects.values_list('slug', flat=True) + # The following doesn't cover all doc types, only a selection + for name in names: + if not '-' in name: + self.assertIn(name, content) + + diff --git a/ietf/help/urls.py b/ietf/help/urls.py index 8c6f59c69..7b1c3ad7a 100644 --- a/ietf/help/urls.py +++ b/ietf/help/urls.py @@ -3,6 +3,6 @@ from django.conf.urls import patterns, url urlpatterns = patterns('', url(r'^state/(?P[-\w]+)/(?P[-\w]+)/?$', 'ietf.help.views.state'), url(r'^state/(?P[-\w]+)/?$', 'ietf.help.views.state'), - url(r'^state/?$', 'ietf.help.views.index'), + url(r'^state/?$', 'ietf.help.views.state_index'), ) diff --git a/ietf/help/views.py b/ietf/help/views.py index 1259d18e3..ea43fce6b 100644 --- a/ietf/help/views.py +++ b/ietf/help/views.py @@ -8,9 +8,9 @@ from django.shortcuts import get_object_or_404, render_to_response import debug # pyflakes:ignore from ietf.doc.models import State, StateType +from ietf.name.models import StreamName - -def index(request): +def state_index(request): types = StateType.objects.all() names = [ type.slug for type in types ] for type in types: @@ -20,10 +20,17 @@ def index(request): groups = StateType.objects.filter(slug__startswith=type.slug) type.stategroups = [ g.slug[len(type.slug)+1:] for g in groups if not g == type ] or "" - return render_to_response('help/index.html', {"types": types}, + return render_to_response('help/state_index.html', {"types": types}, context_instance=RequestContext(request)) def state(request, doc, type=None): + if type: + debug.show('type') + streams = [ s.slug for s in StreamName.objects.all() ] + debug.show('streams') + if type in streams: + type = "stream-%s" % type + debug.show('type') slug = "%s-%s" % (doc,type) if type else doc statetype = get_object_or_404(StateType, slug=slug) states = State.objects.filter(used=True, type=statetype).order_by('order') diff --git a/ietf/templates/doc/document_draft.html b/ietf/templates/doc/document_draft.html index eca0cebcc..7a164b36f 100644 --- a/ietf/templates/doc/document_draft.html +++ b/ietf/templates/doc/document_draft.html @@ -130,7 +130,7 @@ {% if doc.stream %} - {{ doc.stream }} state + {{ doc.stream }} state {% if doc.stream and can_edit_stream_info %} Edit @@ -211,7 +211,7 @@ {% endif %} - IESG state + IESG state {% if iesg_state and can_edit %} Edit @@ -224,7 +224,7 @@ {% if iana_review_state %} - IANA review state + IANA review state {% if can_edit_iana_state %} Edit @@ -250,7 +250,7 @@ {% if rfc_editor_state %} - RFC Editor state + RFC Editor state {{ rfc_editor_state }} diff --git a/ietf/templates/help/index.html b/ietf/templates/help/state_index.html similarity index 79% rename from ietf/templates/help/index.html rename to ietf/templates/help/state_index.html index 4e9518b1f..24d8cff89 100644 --- a/ietf/templates/help/index.html +++ b/ietf/templates/help/state_index.html @@ -20,10 +20,10 @@ {% for type in types %} {% if type.stategroups != None %} - {{type.slug}} + {{type.slug}} {% for group in type.stategroups %} - {{ group }}{% if not forloop.last %}, {% endif %} + {{ group }}{% if not forloop.last %}, {% endif %} {% endfor %}