Skip to content

Commit

Permalink
Move all state help to /doc. Fixes ietf-tools#3802
Browse files Browse the repository at this point in the history
  • Loading branch information
jimfenton committed Mar 16, 2024
1 parent 3eade71 commit 4c03e98
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 69 deletions.
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 @@ -3273,3 +3273,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})

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
12 changes: 2 additions & 10 deletions ietf/help/tests_views.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
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)
# Make sure you get at least a redirect
self.assertEqual(r.status_code,301)
23 changes: 5 additions & 18 deletions ietf/help/views.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,20 @@
# 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

# These are just redirects to the new URLs under /doc; can probably go away eventually.

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})
return redirect('/doc/help/state/', permanent = True)

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
statetype = get_object_or_404(StateType, slug=slug)
states = State.objects.filter(used=True, type=statetype).order_by('order')
if doc == 'draft' and type:
return redirect('/doc/help/state/%s' % slug, permanent = True)
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,7 +23,7 @@ <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 %}
Expand Down
38 changes: 0 additions & 38 deletions ietf/templates/help/states.html

This file was deleted.

0 comments on commit 4c03e98

Please sign in to comment.