Skip to content

Commit fa93d26

Browse files
committed
Added a set of help pages for document states (at /help/state/<doctype>/<statetype>/).
- Legacy-Id: 5467
1 parent 73e6f35 commit fa93d26

File tree

7 files changed

+78
-0
lines changed

7 files changed

+78
-0
lines changed

ietf/help/__init__.py

Whitespace-only changes.

ietf/help/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Empty

ietf/help/tests.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""
2+
This file demonstrates two different styles of tests (one doctest and one
3+
unittest). These will both pass when you run "manage.py test".
4+
5+
Replace these with more appropriate tests for your application.
6+
"""
7+
8+
from django.test import TestCase
9+
10+
class SimpleTest(TestCase):
11+
def test_basic_addition(self):
12+
"""
13+
Tests that 1 + 1 always equals 2.
14+
"""
15+
self.failUnlessEqual(1 + 1, 2)
16+
17+
__test__ = {"doctest": """
18+
Another way to test that 1 + 1 is equal to 2.
19+
20+
>>> 1 + 1 == 2
21+
True
22+
"""}
23+

ietf/help/urls.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from django.conf.urls.defaults import patterns, url
2+
3+
urlpatterns = patterns('',
4+
url(r'^state/(?P<doc>[-\w]+)/(?P<type>[-\w]+)/?$', 'ietf.help.views.state'),
5+
url(r'^state/(?P<doc>[-\w]+)/?$', 'ietf.help.views.state'),
6+
)
7+

ietf/help/views.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright The IETF Trust 2007, All Rights Reserved
2+
3+
from django.template import RequestContext
4+
from django.shortcuts import get_object_or_404, render_to_response
5+
6+
import debug
7+
8+
from doc.models import State, StateType
9+
10+
11+
def state(request, doc, type=None):
12+
slug = "%s-%s" % (doc,type) if type else doc
13+
debug.show('slug')
14+
statetype = get_object_or_404(StateType, slug=slug)
15+
states = State.objects.filter(type=statetype).order_by('order')
16+
return render_to_response('help/states.html', {"doc": doc, "type": statetype, "states":states},
17+
context_instance=RequestContext(request))
18+

ietf/templates/help/states.html

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{% extends "base.html" %}
2+
{# Copyright The IETF Trust 2007, All Rights Reserved #}
3+
4+
{% block title %} {{type.label|cut:"state"|cut:"State"}} Statess{% endblock %}
5+
6+
{% block content %}
7+
8+
<h1>{{type.label|cut:"state"|cut:"State"}} States</h1>
9+
10+
11+
<table class="ietf-table">
12+
<tr>
13+
<th>State</th>
14+
<th>Description</th>
15+
<th>Next State</th>
16+
</tr>
17+
18+
{% for state in states %}
19+
<tr class="{% cycle oddrow,evenrow as cycle1 %}">
20+
<td>{{ state.name }}</td>
21+
<td>{{ state.desc|safe }}</td>
22+
<td><ul>{% for s in state.next_states.all %}<li>{{ s.name }}</li>{%endfor%}</ul></td>
23+
</tr>
24+
{% endfor %}
25+
</table>
26+
27+
28+
{% endblock %}

ietf/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
(r'^(?P<path>public)/', include('ietf.redirects.urls')),
7070
(r'^wg/', include('ietf.wginfo.urls')),
7171
(r'^sync/', include('ietf.sync.urls')),
72+
(r'^help/', include('ietf.help.urls')),
7273

7374
# Google webmaster tools verification url
7475
(r'^googlea30ad1dacffb5e5b.html', 'django.views.generic.simple.direct_to_template', { 'template': 'googlea30ad1dacffb5e5b.html' }),

0 commit comments

Comments
 (0)