Skip to content

Commit 891c0e9

Browse files
authored
refactor: Move document state help to /doc (ietf-tools#7206)
* Redirect /help/state/draft/* to /doc/help/state/draft-* * Adjust document state index to use /doc/help/state for URLs * Move all state help to /doc. Fixes ietf-tools#3802 * Move state index redirect into urls file.
1 parent c02ece3 commit 891c0e9

File tree

8 files changed

+65
-82
lines changed

8 files changed

+65
-82
lines changed

ietf/doc/tests.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
from ietf.doc.models import ( Document, DocRelationshipName, RelatedDocument, State,
3939
DocEvent, BallotPositionDocEvent, LastCallDocEvent, WriteupDocEvent, NewRevisionDocEvent, BallotType,
40-
EditedAuthorsDocEvent )
40+
EditedAuthorsDocEvent, StateType)
4141
from ietf.doc.factories import ( DocumentFactory, DocEventFactory, CharterFactory,
4242
ConflictReviewFactory, WgDraftFactory, IndividualDraftFactory, WgRfcFactory,
4343
IndividualRfcFactory, StateDocEventFactory, BallotPositionDocEventFactory,
@@ -3127,3 +3127,17 @@ def test_referenced_by_rfcs_as_rfc_or_draft(self):
31273127
rfc.referenced_by_rfcs_as_rfc_or_draft(),
31283128
draft.targets_related.filter(source__type="rfc") | rfc.targets_related.filter(source__type="rfc"),
31293129
)
3130+
3131+
class StateIndexTests(TestCase):
3132+
3133+
def test_state_index(self):
3134+
url = urlreverse('ietf.doc.views_help.state_index')
3135+
r = self.client.get(url)
3136+
q = PyQuery(r.content)
3137+
content = [ e.text for e in q('#content table td a ') ]
3138+
names = StateType.objects.values_list('slug', flat=True)
3139+
# The following doesn't cover all doc types, only a selection
3140+
for name in names:
3141+
if not '-' in name:
3142+
self.assertIn(name, content)
3143+

ietf/doc/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@
163163
url(r'^%(name)s/edit/issueballot/rsab/$' % settings.URL_REGEXPS, views_ballot.issue_rsab_ballot),
164164
url(r'^%(name)s/edit/closeballot/rsab/$' % settings.URL_REGEXPS, views_ballot.close_rsab_ballot),
165165

166+
url(r'^help/state/?$', views_help.state_index),
166167
url(r'^help/state/(?P<type>[\w-]+)/$', views_help.state_help),
167168
url(r'^help/relationships/$', views_help.relationship_help),
168169
url(r'^help/relationships/(?P<subset>\w+)/$', views_help.relationship_help),

ietf/doc/views_help.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@
99
from ietf.name.models import DocRelationshipName, DocTagName
1010
from ietf.doc.utils import get_tags_for_stream_id
1111

12+
def state_index(request):
13+
types = StateType.objects.all()
14+
names = [ type.slug for type in types ]
15+
for type in types:
16+
if "-" in type.slug and type.slug.split('-',1)[0] in names:
17+
type.stategroups = None
18+
else:
19+
groups = StateType.objects.filter(slug__startswith=type.slug)
20+
type.stategroups = [ g.slug[len(type.slug)+1:] for g in groups if not g == type ] or ""
21+
22+
return render(request, 'doc/state_index.html', {"types": types})
23+
1224
def state_help(request, type=None):
1325
slug, title = {
1426
"draft-iesg": ("draft-iesg", "IESG States for Internet-Drafts"),
@@ -26,7 +38,30 @@ def state_help(request, type=None):
2638
"status-change": ("statchg", "RFC Status Change States"),
2739
"bofreq": ("bofreq", "BOF Request States"),
2840
"procmaterials": ("procmaterials", "Proceedings Materials States"),
29-
"statement": {"statement", "Statement States"}
41+
"statement": ("statement", "Statement States"),
42+
"slides": ("slides", "Slides States"),
43+
"minutes": ("minutes", "Minutes States"),
44+
"liai-att": ("liai-att", "Liaison Attachment States"),
45+
"recording": ("recording", "Recording States"),
46+
"bluesheets": ("bluesheets", "Bluesheets States"),
47+
"reuse_policy": ("reuse_policy", "Reuse Policy States"),
48+
"review": ("review", "Review States"),
49+
"liaison": ("liaison", "Liaison States"),
50+
"shepwrit": ("shepwrit", "Shapherd Writeup States"),
51+
"bofreq": ("bofreq", "BOF Request States"),
52+
"procmaterials": ("procmaterials", "Proceedings Materials States"),
53+
"chatlog": ("chatlog", "Chat Log States"),
54+
"polls": ("polls", "Polls States"),
55+
"statement": ("statement", "Statement States"),
56+
"rfc": ("rfc", "RFC States"),
57+
"bcp": ("bcp", "BCP States"),
58+
"std": ("std", "STD States"),
59+
"fyi": ("fyi", "FYI States"),
60+
"narrativeminutes": ("narrativeminutes", "Narrative Minutes States"),
61+
"draft": ("draft", "Draft States"),
62+
"statchg": ("statchg", "Status Change States"),
63+
"agenda": ("agenda", "Agenda States"),
64+
"conflrev": ("conflrev", "Conflict Review States")
3065
}.get(type, (None, None))
3166
state_type = get_object_or_404(StateType, slug=slug)
3267

ietf/help/tests_views.py

Lines changed: 0 additions & 21 deletions
This file was deleted.

ietf/help/urls.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
from ietf.help import views
44
from ietf.utils.urls import url
5+
from django.views.generic import RedirectView
56

67
urlpatterns = [
78
url(r'^state/(?P<doc>[-\w]+)/(?P<type>[-\w]+)/?$', views.state),
89
url(r'^state/(?P<doc>[-\w]+)/?$', views.state),
9-
url(r'^state/?$', views.state_index),
10+
url(r'^state/?$', RedirectView.as_view(url='/doc/help/state/', permanent=True)),
1011
]
11-

ietf/help/views.py

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,17 @@
11
# Copyright The IETF Trust 2007, All Rights Reserved
22

3-
from django.shortcuts import get_object_or_404, render
4-
53
import debug # pyflakes:ignore
64

7-
from ietf.doc.models import State, StateType
85
from ietf.name.models import StreamName
6+
from django.shortcuts import redirect
97

10-
def state_index(request):
11-
types = StateType.objects.all()
12-
names = [ type.slug for type in types ]
13-
for type in types:
14-
if "-" in type.slug and type.slug.split('-',1)[0] in names:
15-
type.stategroups = None
16-
else:
17-
groups = StateType.objects.filter(slug__startswith=type.slug)
18-
type.stategroups = [ g.slug[len(type.slug)+1:] for g in groups if not g == type ] or ""
19-
20-
return render(request, 'help/state_index.html', {"types": types})
8+
# This is just a redirect to the new URL under /doc; can probably go away eventually.
219

2210
def state(request, doc, type=None):
2311
if type:
2412
streams = [ s.slug for s in StreamName.objects.all() ]
2513
if type in streams:
2614
type = "stream-%s" % type
2715
slug = "%s-%s" % (doc,type) if type else doc
28-
statetype = get_object_or_404(StateType, slug=slug)
29-
states = State.objects.filter(used=True, type=statetype).order_by('order')
30-
return render(request, 'help/states.html', {"doc": doc, "type": statetype, "states":states} )
16+
return redirect('/doc/help/state/%s' % slug, permanent = True)
17+

ietf/templates/help/state_index.html renamed to ietf/templates/doc/state_index.html

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,17 @@ <h1>Document state index</h1>
2323
{% if type.stategroups != None %}
2424
<tr>
2525
<td>
26-
<a href="{% url 'ietf.help.views.state' doc=type.slug %}">{{ type.slug }}</a>
26+
<a href="{% url 'ietf.doc.views_help.state_help' type=type.slug %}">{{ type.slug }}</a>
2727
</td>
2828
<td>
2929
{% for group in type.stategroups %}
3030
{# djlint:off #}
31-
<a href="{% url 'ietf.help.views.state' doc=type.slug type=group %}">{{ group }}</a>{% if not forloop.last %},{% endif %}
31+
{% if type.slug == "draft" %}
32+
<a href="{% url 'ietf.doc.views_help.state_help' type=type.slug|add:'-'|add:group %}">
33+
{% else %}
34+
<a href="{% url 'ietf.help.views.state' doc=type.slug type=group %}">
35+
{% endif %}
36+
{{ group }}</a>{% if not forloop.last %},{% endif %}
3237
{# djlint:on #}
3338
{% endfor %}
3439
</td>

ietf/templates/help/states.html

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)