diff --git a/ietf/doc/tests.py b/ietf/doc/tests.py index f9c08d0e7..d4a650421 100644 --- a/ietf/doc/tests.py +++ b/ietf/doc/tests.py @@ -37,7 +37,7 @@ import debug # pyflakes:ignore from ietf.doc.models import ( Document, DocRelationshipName, RelatedDocument, State, DocEvent, BallotPositionDocEvent, LastCallDocEvent, WriteupDocEvent, NewRevisionDocEvent, BallotType, - EditedAuthorsDocEvent ) + EditedAuthorsDocEvent, StateType) from ietf.doc.factories import ( DocumentFactory, DocEventFactory, CharterFactory, ConflictReviewFactory, WgDraftFactory, IndividualDraftFactory, WgRfcFactory, IndividualRfcFactory, StateDocEventFactory, BallotPositionDocEventFactory, @@ -3127,3 +3127,17 @@ class DocInfoMethodsTests(TestCase): rfc.referenced_by_rfcs_as_rfc_or_draft(), draft.targets_related.filter(source__type="rfc") | rfc.targets_related.filter(source__type="rfc"), ) + +class StateIndexTests(TestCase): + + def test_state_index(self): + url = urlreverse('ietf.doc.views_help.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/doc/urls.py b/ietf/doc/urls.py index 496b2d8f3..d29fd9da1 100644 --- a/ietf/doc/urls.py +++ b/ietf/doc/urls.py @@ -163,6 +163,7 @@ urlpatterns = [ url(r'^%(name)s/edit/issueballot/rsab/$' % settings.URL_REGEXPS, views_ballot.issue_rsab_ballot), url(r'^%(name)s/edit/closeballot/rsab/$' % settings.URL_REGEXPS, views_ballot.close_rsab_ballot), + url(r'^help/state/?$', views_help.state_index), url(r'^help/state/(?P[\w-]+)/$', views_help.state_help), url(r'^help/relationships/$', views_help.relationship_help), url(r'^help/relationships/(?P\w+)/$', views_help.relationship_help), diff --git a/ietf/doc/views_help.py b/ietf/doc/views_help.py index e8e63ed8b..34d29aacc 100644 --- a/ietf/doc/views_help.py +++ b/ietf/doc/views_help.py @@ -9,6 +9,18 @@ from ietf.doc.models import State, StateType, IESG_SUBSTATE_TAGS from ietf.name.models import DocRelationshipName, DocTagName from ietf.doc.utils import get_tags_for_stream_id +def state_index(request): + types = StateType.objects.all() + names = [ type.slug for type in types ] + for type in types: + if "-" in type.slug and type.slug.split('-',1)[0] in names: + type.stategroups = None + else: + 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(request, 'doc/state_index.html', {"types": types}) + def state_help(request, type=None): slug, title = { "draft-iesg": ("draft-iesg", "IESG States for Internet-Drafts"), @@ -26,7 +38,30 @@ def state_help(request, type=None): "status-change": ("statchg", "RFC Status Change States"), "bofreq": ("bofreq", "BOF Request States"), "procmaterials": ("procmaterials", "Proceedings Materials States"), - "statement": {"statement", "Statement States"} + "statement": ("statement", "Statement States"), + "slides": ("slides", "Slides States"), + "minutes": ("minutes", "Minutes States"), + "liai-att": ("liai-att", "Liaison Attachment States"), + "recording": ("recording", "Recording States"), + "bluesheets": ("bluesheets", "Bluesheets States"), + "reuse_policy": ("reuse_policy", "Reuse Policy States"), + "review": ("review", "Review States"), + "liaison": ("liaison", "Liaison States"), + "shepwrit": ("shepwrit", "Shapherd Writeup States"), + "bofreq": ("bofreq", "BOF Request States"), + "procmaterials": ("procmaterials", "Proceedings Materials States"), + "chatlog": ("chatlog", "Chat Log States"), + "polls": ("polls", "Polls States"), + "statement": ("statement", "Statement States"), + "rfc": ("rfc", "RFC States"), + "bcp": ("bcp", "BCP States"), + "std": ("std", "STD States"), + "fyi": ("fyi", "FYI States"), + "narrativeminutes": ("narrativeminutes", "Narrative Minutes States"), + "draft": ("draft", "Draft States"), + "statchg": ("statchg", "Status Change States"), + "agenda": ("agenda", "Agenda States"), + "conflrev": ("conflrev", "Conflict Review States") }.get(type, (None, None)) state_type = get_object_or_404(StateType, slug=slug) diff --git a/ietf/help/tests_views.py b/ietf/help/tests_views.py deleted file mode 100644 index ee80dad86..000000000 --- a/ietf/help/tests_views.py +++ /dev/null @@ -1,21 +0,0 @@ -from pyquery import PyQuery - -from django.urls import reverse - -import debug # pyflakes:ignore - -from ietf.utils.test_utils import TestCase -from ietf.doc.models import StateType - -class HelpPageTests(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 f1cc625fa..90ce7e12e 100644 --- a/ietf/help/urls.py +++ b/ietf/help/urls.py @@ -2,10 +2,10 @@ from ietf.help import views from ietf.utils.urls import url +from django.views.generic import RedirectView urlpatterns = [ url(r'^state/(?P[-\w]+)/(?P[-\w]+)/?$', views.state), url(r'^state/(?P[-\w]+)/?$', views.state), - url(r'^state/?$', views.state_index), + url(r'^state/?$', RedirectView.as_view(url='/doc/help/state/', permanent=True)), ] - diff --git a/ietf/help/views.py b/ietf/help/views.py index 6b10f9f6c..493bf0dcf 100644 --- a/ietf/help/views.py +++ b/ietf/help/views.py @@ -1,23 +1,11 @@ # Copyright The IETF Trust 2007, All Rights Reserved -from django.shortcuts import get_object_or_404, render - import debug # pyflakes:ignore -from ietf.doc.models import State, StateType from ietf.name.models import StreamName +from django.shortcuts import redirect -def state_index(request): - types = StateType.objects.all() - names = [ type.slug for type in types ] - for type in types: - if "-" in type.slug and type.slug.split('-',1)[0] in names: - type.stategroups = None - else: - 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(request, 'help/state_index.html', {"types": types}) +# This is just a redirect to the new URL under /doc; can probably go away eventually. def state(request, doc, type=None): if type: @@ -25,6 +13,5 @@ def state(request, doc, type=None): if type in streams: type = "stream-%s" % 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') - return render(request, 'help/states.html', {"doc": doc, "type": statetype, "states":states} ) + return redirect('/doc/help/state/%s' % slug, permanent = True) + \ No newline at end of file diff --git a/ietf/templates/help/state_index.html b/ietf/templates/doc/state_index.html similarity index 68% rename from ietf/templates/help/state_index.html rename to ietf/templates/doc/state_index.html index 29233cca0..602d54d1c 100644 --- a/ietf/templates/help/state_index.html +++ b/ietf/templates/doc/state_index.html @@ -23,12 +23,17 @@ {% if type.stategroups != None %} - {{ type.slug }} + {{ type.slug }} {% for group in type.stategroups %} {# djlint:off #} - {{ group }}{% if not forloop.last %},{% endif %} + {% if type.slug == "draft" %} + + {% else %} + + {% endif %} + {{ group }}{% if not forloop.last %},{% endif %} {# djlint:on #} {% endfor %} diff --git a/ietf/templates/help/states.html b/ietf/templates/help/states.html deleted file mode 100644 index ccc052647..000000000 --- a/ietf/templates/help/states.html +++ /dev/null @@ -1,38 +0,0 @@ -{% extends "base.html" %} -{# Copyright The IETF Trust 2015, All Rights Reserved #} -{% load origin static ietf_filters textfilters %} -{% block pagehead %} - -{% endblock %} -{% block title %}{{ type.label|cut:"state"|cut:"state" }} states{% endblock %} -{% block content %} - {% origin %} -

{{ type.label|cut:"state"|cut:"State" }} states

- - - - - - - - - - {% for state in states %} - - - - - - {% endfor %} - -
StateDescriptionNext states
{{ state.name }}{{ state.desc|urlize_ietf_docs|linkify }} -
    - {% for s in state.next_states.all %} -
  • {{ s.name }}
  • - {% endfor %} -
-
-{% endblock %} -{% block js %} - -{% endblock %} \ No newline at end of file