refactor: Move document state help to /doc (#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 #3802 * Move state index redirect into urls file.
This commit is contained in:
parent
c02ece3af2
commit
891c0e975d
|
@ -37,7 +37,7 @@ import debug # pyflakes:ignore
|
||||||
|
|
||||||
from ietf.doc.models import ( Document, DocRelationshipName, RelatedDocument, State,
|
from ietf.doc.models import ( Document, DocRelationshipName, RelatedDocument, State,
|
||||||
DocEvent, BallotPositionDocEvent, LastCallDocEvent, WriteupDocEvent, NewRevisionDocEvent, BallotType,
|
DocEvent, BallotPositionDocEvent, LastCallDocEvent, WriteupDocEvent, NewRevisionDocEvent, BallotType,
|
||||||
EditedAuthorsDocEvent )
|
EditedAuthorsDocEvent, StateType)
|
||||||
from ietf.doc.factories import ( DocumentFactory, DocEventFactory, CharterFactory,
|
from ietf.doc.factories import ( DocumentFactory, DocEventFactory, CharterFactory,
|
||||||
ConflictReviewFactory, WgDraftFactory, IndividualDraftFactory, WgRfcFactory,
|
ConflictReviewFactory, WgDraftFactory, IndividualDraftFactory, WgRfcFactory,
|
||||||
IndividualRfcFactory, StateDocEventFactory, BallotPositionDocEventFactory,
|
IndividualRfcFactory, StateDocEventFactory, BallotPositionDocEventFactory,
|
||||||
|
@ -3127,3 +3127,17 @@ class DocInfoMethodsTests(TestCase):
|
||||||
rfc.referenced_by_rfcs_as_rfc_or_draft(),
|
rfc.referenced_by_rfcs_as_rfc_or_draft(),
|
||||||
draft.targets_related.filter(source__type="rfc") | rfc.targets_related.filter(source__type="rfc"),
|
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)
|
||||||
|
|
||||||
|
|
|
@ -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/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'^%(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/state/(?P<type>[\w-]+)/$', views_help.state_help),
|
||||||
url(r'^help/relationships/$', views_help.relationship_help),
|
url(r'^help/relationships/$', views_help.relationship_help),
|
||||||
url(r'^help/relationships/(?P<subset>\w+)/$', views_help.relationship_help),
|
url(r'^help/relationships/(?P<subset>\w+)/$', views_help.relationship_help),
|
||||||
|
|
|
@ -9,6 +9,18 @@ from ietf.doc.models import State, StateType, IESG_SUBSTATE_TAGS
|
||||||
from ietf.name.models import DocRelationshipName, DocTagName
|
from ietf.name.models import DocRelationshipName, DocTagName
|
||||||
from ietf.doc.utils import get_tags_for_stream_id
|
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):
|
def state_help(request, type=None):
|
||||||
slug, title = {
|
slug, title = {
|
||||||
"draft-iesg": ("draft-iesg", "IESG States for Internet-Drafts"),
|
"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"),
|
"status-change": ("statchg", "RFC Status Change States"),
|
||||||
"bofreq": ("bofreq", "BOF Request States"),
|
"bofreq": ("bofreq", "BOF Request States"),
|
||||||
"procmaterials": ("procmaterials", "Proceedings Materials 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))
|
}.get(type, (None, None))
|
||||||
state_type = get_object_or_404(StateType, slug=slug)
|
state_type = get_object_or_404(StateType, slug=slug)
|
||||||
|
|
||||||
|
|
|
@ -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)
|
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
from ietf.help import views
|
from ietf.help import views
|
||||||
from ietf.utils.urls import url
|
from ietf.utils.urls import url
|
||||||
|
from django.views.generic import RedirectView
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^state/(?P<doc>[-\w]+)/(?P<type>[-\w]+)/?$', views.state),
|
url(r'^state/(?P<doc>[-\w]+)/(?P<type>[-\w]+)/?$', views.state),
|
||||||
url(r'^state/(?P<doc>[-\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)),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -1,23 +1,11 @@
|
||||||
# Copyright The IETF Trust 2007, All Rights Reserved
|
# Copyright The IETF Trust 2007, All Rights Reserved
|
||||||
|
|
||||||
from django.shortcuts import get_object_or_404, render
|
|
||||||
|
|
||||||
import debug # pyflakes:ignore
|
import debug # pyflakes:ignore
|
||||||
|
|
||||||
from ietf.doc.models import State, StateType
|
|
||||||
from ietf.name.models import StreamName
|
from ietf.name.models import StreamName
|
||||||
|
from django.shortcuts import redirect
|
||||||
|
|
||||||
def state_index(request):
|
# This is just a redirect to the new URL under /doc; can probably go away eventually.
|
||||||
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})
|
|
||||||
|
|
||||||
def state(request, doc, type=None):
|
def state(request, doc, type=None):
|
||||||
if type:
|
if type:
|
||||||
|
@ -25,6 +13,5 @@ def state(request, doc, type=None):
|
||||||
if type in streams:
|
if type in streams:
|
||||||
type = "stream-%s" % type
|
type = "stream-%s" % type
|
||||||
slug = "%s-%s" % (doc,type) if type else doc
|
slug = "%s-%s" % (doc,type) if type else doc
|
||||||
statetype = get_object_or_404(StateType, slug=slug)
|
return redirect('/doc/help/state/%s' % slug, permanent = True)
|
||||||
states = State.objects.filter(used=True, type=statetype).order_by('order')
|
|
||||||
return render(request, 'help/states.html', {"doc": doc, "type": statetype, "states":states} )
|
|
|
@ -23,12 +23,17 @@
|
||||||
{% if type.stategroups != None %}
|
{% if type.stategroups != None %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<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>
|
||||||
<td>
|
<td>
|
||||||
{% for group in type.stategroups %}
|
{% for group in type.stategroups %}
|
||||||
{# djlint:off #}
|
{# 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 #}
|
{# djlint:on #}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</td>
|
</td>
|
|
@ -1,38 +0,0 @@
|
||||||
{% extends "base.html" %}
|
|
||||||
{# Copyright The IETF Trust 2015, All Rights Reserved #}
|
|
||||||
{% load origin static ietf_filters textfilters %}
|
|
||||||
{% block pagehead %}
|
|
||||||
<link rel="stylesheet" href="{% static "ietf/css/list.css" %}">
|
|
||||||
{% endblock %}
|
|
||||||
{% block title %}{{ type.label|cut:"state"|cut:"state" }} states{% endblock %}
|
|
||||||
{% block content %}
|
|
||||||
{% origin %}
|
|
||||||
<h1>{{ type.label|cut:"state"|cut:"State" }} states</h1>
|
|
||||||
<table class="table table-sm table-striped tablesorter">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th scope="col" data-sort="state">State</th>
|
|
||||||
<th scope="col" data-sort="desc">Description</th>
|
|
||||||
<th scope="col" data-sort="next">Next states</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{% for state in states %}
|
|
||||||
<tr>
|
|
||||||
<th scope="row">{{ state.name }}</th>
|
|
||||||
<td>{{ state.desc|urlize_ietf_docs|linkify }}</td>
|
|
||||||
<td>
|
|
||||||
<ul>
|
|
||||||
{% for s in state.next_states.all %}
|
|
||||||
<li>{{ s.name }}</li>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
{% endblock %}
|
|
||||||
{% block js %}
|
|
||||||
<script src="{% static "ietf/js/list.js" %}"></script>
|
|
||||||
{% endblock %}
|
|
Loading…
Reference in a new issue