Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion ietf/doc/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

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,
Expand Down Expand Up @@ -3127,3 +3127,17 @@ def test_referenced_by_rfcs_as_rfc_or_draft(self):
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)

1 change: 1 addition & 0 deletions ietf/doc/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@
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<type>[\w-]+)/$', views_help.state_help),
url(r'^help/relationships/$', views_help.relationship_help),
url(r'^help/relationships/(?P<subset>\w+)/$', views_help.relationship_help),
Expand Down
37 changes: 36 additions & 1 deletion ietf/doc/views_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@
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})
Comment thread
rjsparks marked this conversation as resolved.

def state_help(request, type=None):
slug, title = {
"draft-iesg": ("draft-iesg", "IESG States for Internet-Drafts"),
Expand All @@ -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)

Expand Down
21 changes: 0 additions & 21 deletions ietf/help/tests_views.py

This file was deleted.

4 changes: 2 additions & 2 deletions ietf/help/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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<doc>[-\w]+)/(?P<type>[-\w]+)/?$', views.state),
url(r'^state/(?P<doc>[-\w]+)/?$', views.state),
url(r'^state/?$', views.state_index),
url(r'^state/?$', RedirectView.as_view(url='/doc/help/state/', permanent=True)),
]

21 changes: 4 additions & 17 deletions ietf/help/views.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,17 @@
# 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:
streams = [ s.slug for s in StreamName.objects.all() ]
if type in streams:
type = "stream-%s" % type
slug = "%s-%s" % (doc,type) if type else doc
Comment thread
rjsparks marked this conversation as resolved.
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)

Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,17 @@ <h1>Document state index</h1>
{% if type.stategroups != None %}
<tr>
<td>
<a href="{% url 'ietf.help.views.state' doc=type.slug %}">{{ type.slug }}</a>
<a href="{% url 'ietf.doc.views_help.state_help' type=type.slug %}">{{ type.slug }}</a>
</td>
<td>
{% for group in type.stategroups %}
{# djlint:off #}
<a href="{% url 'ietf.help.views.state' doc=type.slug type=group %}">{{ group }}</a>{% if not forloop.last %},{% endif %}
{% if type.slug == "draft" %}
<a href="{% url 'ietf.doc.views_help.state_help' type=type.slug|add:'-'|add:group %}">
{% else %}
<a href="{% url 'ietf.help.views.state' doc=type.slug type=group %}">
{% endif %}
{{ group }}</a>{% if not forloop.last %},{% endif %}
{# djlint:on #}
{% endfor %}
</td>
Expand Down
38 changes: 0 additions & 38 deletions ietf/templates/help/states.html

This file was deleted.