Skip to content

Commit 47b466e

Browse files
committed
Move charter urls from /wgcharter/<group-acronym> to
/doc/<doc-name>/charter/ since they now all concern the actual charter documents rather than the WG (this removes some redundant code). - Legacy-Id: 4271
1 parent 4f4a47b commit 47b466e

9 files changed

Lines changed: 38 additions & 83 deletions

File tree

ietf/idrfc/urls.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3131
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3232

33-
from django.conf.urls.defaults import patterns, url
33+
from django.conf.urls.defaults import patterns, url, include
3434
from ietf.idrfc import views_doc, views_search, views_edit, views_ballot, views
3535

3636
urlpatterns = patterns('',
@@ -65,4 +65,6 @@
6565
url(r'^(?P<name>[A-Za-z0-9.-]+)/edit/approvaltext/$', views_ballot.ballot_approvaltext, name='doc_ballot_approvaltext'),
6666
url(r'^(?P<name>[A-Za-z0-9.-]+)/edit/approveballot/$', views_ballot.approve_ballot, name='doc_approve_ballot'),
6767
url(r'^(?P<name>[A-Za-z0-9.-]+)/edit/makelastcall/$', views_ballot.make_last_call, name='doc_make_last_call'),
68+
69+
(r'^(?P<name>[A-Za-z0-9.-]+)/charter/', include('ietf.wgcharter.urls')),
6870
)

ietf/idrfc/views_doc.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,17 +217,17 @@ def document_writeup(request, name):
217217
e = doc.latest_event(WriteupDocEvent, type="changed_review_announcement")
218218
writeups.append(("WG Review Announcement",
219219
e.text if e else "",
220-
urlreverse("ietf.wgcharter.views.announcement_text", kwargs=dict(name=doc.group.acronym, ann="review"))))
220+
urlreverse("ietf.wgcharter.views.announcement_text", kwargs=dict(name=doc.name, ann="review"))))
221221

222222
e = doc.latest_event(WriteupDocEvent, type="changed_action_announcement")
223223
writeups.append(("WG Action Announcement",
224224
e.text if e else "",
225-
urlreverse("ietf.wgcharter.views.announcement_text", kwargs=dict(name=doc.group.acronym, ann="action"))))
225+
urlreverse("ietf.wgcharter.views.announcement_text", kwargs=dict(name=doc.name, ann="action"))))
226226

227227
e = doc.latest_event(WriteupDocEvent, type="changed_ballot_writeup_text")
228228
writeups.append(("Ballot Announcement",
229229
e.text if e else "",
230-
urlreverse("ietf.wgcharter.views.ballot_writeupnotes", kwargs=dict(name=doc.group.acronym))))
230+
urlreverse("ietf.wgcharter.views.ballot_writeupnotes", kwargs=dict(name=doc.name))))
231231

232232
if not writeups:
233233
raise Http404()

ietf/templates/idrfc/document_charter.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@
4141
{% if chartering == "rechartering" %}(Rechartering){% endif %}
4242

4343
{% if not snapshot and user|has_role:"Area Director,Secretariat" %}
44-
- <a href="{% url wg_change_state name=doc.group.acronym %}">Change state</a>
44+
- <a href="{% url wg_change_state name=doc.name %}">Change state</a>
4545

4646
{% if chartering %}
47-
- <a href="{% url wg_startstop_process name=doc.group.acronym option='abandon' %}">Abandon effort</a>
47+
- <a href="{% url wg_startstop_process name=doc.name option='abandon' %}">Abandon effort</a>
4848
{% else %}
49-
- <a href="{% url wg_startstop_process name=doc.group.acronym option='recharter' %}">Recharter</a>
49+
- <a href="{% url wg_startstop_process name=doc.name option='recharter' %}">Recharter</a>
5050
{% endif %}
5151

5252
{% endif %}
@@ -67,7 +67,7 @@
6767
<td>
6868
{% if not telechat %}Not on agenda{% else %}{{ telechat.telechat_date|date:"Y-m-d" }}{% endif %}
6969
{% if user|has_role:"Area Director,Secretariat" %}
70-
- <a href="{% url charter_telechat_date name=doc.group.acronym %}">Change</a>
70+
- <a href="{% url charter_telechat_date name=doc.name %}">Change</a>
7171
{% endif %}
7272
</td>
7373
</tr>
@@ -89,7 +89,7 @@
8989

9090
<h3>Charter {{ doc.name }}-{{ doc.rev }}
9191
{% if user|has_role:"Area Director,Secretariat" and chartering and doc.group.state_id != "conclude" %}
92-
<a class="edit" href="{% url wg_submit name=doc.group.acronym %}">Edit charter text</a>
92+
<a class="edit" href="{% url wg_submit name=doc.name %}">Edit charter text</a>
9393
{% endif %}
9494
</h3>
9595

ietf/templates/wgcharter/change_state.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
{% block content %}
2121
<h1>{{ title }}</h1>
2222

23-
{% if "Change state" in title %}<p class="helptext">For help on the states, see the <a href="{% url help_charter_states %}">state table</a>.</p>{% endif %}
23+
{% if "Change state" in title %}<p class="helptext">For help on the states, see the <a href="{% url help_charter_states name=doc.name %}">state table</a>.</p>{% endif %}
2424

2525
<form class="change-state" action="" method="post">
2626
<table>
@@ -57,7 +57,7 @@ <h1>{{ title }}</h1>
5757
{% if option %}
5858
<input type="submit" value="Submit"/>
5959
{% else %}
60-
<a href="{% url doc_view name=wg.charter.name %}">Back</a>
60+
<a href="{% url doc_view name=doc.name %}">Back</a>
6161
<input type="submit" value="Save"/>
6262
{% endif %}
6363
</td>
@@ -82,5 +82,5 @@ <h3>Or revert to previous state</h3>
8282
<script type="text/javascript">
8383
var messages = {{ messages|safe }};
8484
</script>
85-
<script type="text/javascript" src="/js/wg-change-state.js"></script>
85+
<script type="text/javascript" src="/js/charter-change-state.js"></script>
8686
{% endblock %}

ietf/urls.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
(r'^accounts/', include('ietf.ietfauth.urls')),
6262
(r'^doc/', include('ietf.idrfc.urls')),
6363
(r'^wg/', include('ietf.wginfo.urls')),
64-
(r'^wgcharter/', include('ietf.wgcharter.urls')),
6564
(r'^cookies/', include('ietf.cookies.urls')),
6665
(r'^person/', include('ietf.person.urls')),
6766
(r'^submit/', include('ietf.submit.urls')),

ietf/wgcharter/tests.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ def test_change_state(self):
3838
group = Group.objects.get(acronym="ames")
3939
charter = group.charter
4040

41-
# -- Test change state --
42-
url = urlreverse('wg_change_state', kwargs=dict(name=group.acronym))
41+
url = urlreverse('wg_change_state', kwargs=dict(name=charter.name))
4342
login_testing_unauthorized(self, "secretary", url)
4443

4544
first_state = charter.get_state()
@@ -84,11 +83,10 @@ def test_change_state(self):
8483
def test_edit_telechat_date(self):
8584
make_test_data()
8685

87-
# And make a charter for group
8886
group = Group.objects.get(acronym="mars")
8987
charter = group.charter
9088

91-
url = urlreverse('charter_telechat_date', kwargs=dict(name=group.acronym))
89+
url = urlreverse('charter_telechat_date', kwargs=dict(name=charter.name))
9290
login_testing_unauthorized(self, "secretary", url)
9391

9492
# add to telechat
@@ -120,11 +118,10 @@ def test_edit_telechat_date(self):
120118
def test_submit_charter(self):
121119
make_test_data()
122120

123-
# And make a charter for group
124121
group = Group.objects.get(acronym="mars")
125122
charter = group.charter
126123

127-
url = urlreverse('wg_submit', kwargs=dict(name=group.acronym))
124+
url = urlreverse('wg_submit', kwargs=dict(name=charter.name))
128125
login_testing_unauthorized(self, "secretary", url)
129126

130127
# normal get
@@ -162,7 +159,7 @@ def test_approve_ballot(self):
162159
group = Group.objects.get(acronym="ames")
163160
charter = group.charter
164161

165-
url = urlreverse('wg_approve_ballot', kwargs=dict(name=group.acronym))
162+
url = urlreverse('wg_approve_ballot', kwargs=dict(name=charter.name))
166163
login_testing_unauthorized(self, "secretary", url)
167164

168165
with open(os.path.join(self.charter_dir, "charter-ietf-%s-%s.txt" % (group.acronym, charter.rev)), "w") as f:

ietf/wgcharter/urls.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
url(r'^help/state/$', 'direct_to_template', { 'template': 'wgcharter/states.html', 'extra_context': { 'states': State.objects.filter(type="charter") } }, name='help_charter_states'),
88
)
99
urlpatterns += patterns('',
10-
url(r'^(?P<name>[A-Za-z0-9._+-]+)/edit/state/$', "ietf.wgcharter.views.change_state", name='wg_change_state'),
11-
url(r'^(?P<name>[A-Za-z0-9._+-]+)/edit/(?P<option>initcharter|recharter|abandon)/$', "ietf.wgcharter.views.change_state", name='wg_startstop_process'),
12-
url(r'^(?P<name>[A-Za-z0-9._+-]+)/edit/telechat/$', "ietf.wgcharter.views.telechat_date", name='charter_telechat_date'),
13-
url(r'^(?P<name>[A-Za-z0-9._+-]+)/edit/(?P<ann>action|review)/$', "ietf.wgcharter.views.announcement_text", name='wg_announcement_text'),
14-
url(r'^(?P<name>[A-Za-z0-9._+-]+)/edit/ballotwriteupnotes/$', "ietf.wgcharter.views.ballot_writeupnotes", name='wg_ballot_writeupnotes'),
15-
url(r'^(?P<name>[A-Za-z0-9._+-]+)/edit/approveballot/$', "ietf.wgcharter.views.approve_ballot", name='wg_approve_ballot'),
16-
url(r'^(?P<name>[A-Za-z0-9._+-]+)/submit/$', "ietf.wgcharter.views.submit", name='wg_submit'),
10+
url(r'^state/$', "ietf.wgcharter.views.change_state", name='wg_change_state'),
11+
url(r'^(?P<option>initcharter|recharter|abandon)/$', "ietf.wgcharter.views.change_state", name='wg_startstop_process'),
12+
url(r'^telechat/$', "ietf.wgcharter.views.telechat_date", name='charter_telechat_date'),
13+
url(r'^(?P<ann>action|review)/$', "ietf.wgcharter.views.announcement_text", name='wg_announcement_text'),
14+
url(r'^ballotwriteupnotes/$', "ietf.wgcharter.views.ballot_writeupnotes", name='wg_ballot_writeupnotes'),
15+
url(r'^approveballot/$', "ietf.wgcharter.views.approve_ballot", name='wg_approve_ballot'),
16+
url(r'^submit/$', "ietf.wgcharter.views.submit", name='wg_submit'),
1717

1818
)

ietf/wgcharter/views.py

Lines changed: 13 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,8 @@ def __init__(self, *args, **kwargs):
4242
def change_state(request, name, option=None):
4343
"""Change state of WG and charter, notifying parties as necessary
4444
and logging the change as a comment."""
45-
# Get WG by acronym, redirecting if there's a newer acronym
46-
try:
47-
wg = Group.objects.get(acronym=name)
48-
except Group.DoesNotExist:
49-
old = GroupHistory.objects.filter(acronym=name)
50-
if old:
51-
return redirect('wg_change_state', name=old[0].group.acronym)
52-
else:
53-
raise Http404()
54-
55-
charter = set_or_create_charter(wg)
45+
charter = get_object_or_404(Document, type="charter", name=name)
46+
wg = charter.group
5647

5748
initial_review = charter.latest_event(InitialReviewDocEvent, type="initial_review")
5849
if charter.get_state_slug() != "infrev" or (initial_review and initial_review.expires < datetime.datetime.now()):
@@ -162,7 +153,7 @@ def state_pk(slug):
162153

163154
return render_to_response('wgcharter/change_state.html',
164155
dict(form=form,
165-
wg=wg,
156+
doc=wg.charter,
166157
login=login,
167158
option=option,
168159
prev_charter_state=prev_charter_state,
@@ -187,8 +178,7 @@ def __init__(self, *args, **kwargs):
187178

188179
@role_required("Area Director", "Secretariat")
189180
def telechat_date(request, name):
190-
wg = get_object_or_404(Group, acronym=name)
191-
doc = set_or_create_charter(wg)
181+
doc = get_object_or_404(Document, type="charter", name=name)
192182
login = request.user.get_profile()
193183

194184
e = doc.latest_event(TelechatDocEvent, type="scheduled_for_telechat")
@@ -235,18 +225,9 @@ def save(self, wg, rev):
235225

236226
@role_required('Area Director','Secretariat')
237227
def submit(request, name):
238-
# Get WG by acronym, redirecting if there's a newer acronym
239-
try:
240-
wg = Group.objects.get(acronym=name)
241-
except Group.DoesNotExist:
242-
wglist = GroupHistory.objects.filter(acronym=name)
243-
if wglist:
244-
return redirect('charter_submit', name=wglist[0].group.acronym)
245-
else:
246-
raise Http404()
247-
# Get charter
248-
charter = set_or_create_charter(wg)
249-
228+
charter = get_object_or_404(Document, type="charter", name=name)
229+
wg = charter.group
230+
250231
login = request.user.get_profile()
251232

252233
if request.method == 'POST':
@@ -301,16 +282,8 @@ def clean_announcement_text(self):
301282
@role_required('Area Director','Secretariat')
302283
def announcement_text(request, name, ann):
303284
"""Editing of announcement text"""
304-
try:
305-
wg = Group.objects.get(acronym=name)
306-
except Group.DoesNotExist:
307-
wglist = GroupHistory.objects.filter(acronym=name)
308-
if wglist:
309-
return redirect('wg_announcement_text', name=wglist[0].group.acronym)
310-
else:
311-
raise Http404
312-
313-
charter = set_or_create_charter(wg)
285+
charter = get_object_or_404(Document, type="charter", name=name)
286+
wg = charter.group
314287

315288
login = request.user.get_profile()
316289

@@ -383,16 +356,8 @@ def clean_ballot_writeup(self):
383356
@role_required('Area Director','Secretariat')
384357
def ballot_writeupnotes(request, name):
385358
"""Editing of ballot write-up and notes"""
386-
try:
387-
wg = Group.objects.get(acronym=name)
388-
except Group.DoesNotExist:
389-
wglist = GroupHistory.objects.filter(acronym=name)
390-
if wglist:
391-
return redirect('wg_ballot_writeupnotes', name=wglist[0].group.acronym)
392-
else:
393-
raise Http404
394-
395-
charter = wg.charter
359+
charter = get_object_or_404(Document, type="charter", name=name)
360+
wg = charter.group
396361

397362
ballot = charter.latest_event(BallotDocEvent, type="created_ballot")
398363
if not ballot:
@@ -459,16 +424,8 @@ def ballot_writeupnotes(request, name):
459424
@role_required("Secretariat")
460425
def approve_ballot(request, name):
461426
"""Approve ballot, changing state, copying charter"""
462-
try:
463-
wg = Group.objects.get(acronym=name)
464-
except Group.DoesNotExist:
465-
wglist = GroupHistory.objects.filter(acronym=name)
466-
if wglist:
467-
return redirect('wg_approve_ballot', name=wglist[0].group.acronym)
468-
else:
469-
raise Http404
470-
471-
charter = set_or_create_charter(wg)
427+
charter = get_object_or_404(Document, type="charter", name=name)
428+
wg = charter.group
472429

473430
login = request.user.get_profile()
474431

0 commit comments

Comments
 (0)