Skip to content

Commit 086c429

Browse files
committed
Merged [6361] from rjsparks@nostrum.com:
Allow the secretariat and ads to change the title of a status change document. Fixes bug 1141. Applied changes to adapt the code from Django 1.2 to 1.6: Provide a quoted string to {% url %} and use request.user.person instead of request.user.get_profile(). - Legacy-Id: 7221 Note: SVN reference [6361] has been migrated to Git commit 7c4cf70
2 parents 3c611cd + a461e6c commit 086c429

5 files changed

Lines changed: 103 additions & 1 deletion

File tree

ietf/doc/tests_status_change.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,25 @@ def test_edit_notices(self):
147147
self.assertEqual(doc.notify,newlist)
148148
self.assertTrue(doc.latest_event(DocEvent,type="added_comment").desc.startswith('Notification list changed'))
149149

150+
def test_edit_title(self):
151+
doc = Document.objects.get(name='status-change-imaginary-mid-review')
152+
url = urlreverse('status_change_title',kwargs=dict(name=doc.name))
153+
154+
login_testing_unauthorized(self, "ad", url)
155+
156+
# normal get
157+
r = self.client.get(url)
158+
self.assertEquals(r.status_code, 200)
159+
q = PyQuery(r.content)
160+
self.assertEquals(len(q('input[name=title]')),1)
161+
162+
# change title
163+
r = self.client.post(url,dict(title='New title'))
164+
self.assertEquals(r.status_code,302)
165+
doc = Document.objects.get(name='status-change-imaginary-mid-review')
166+
self.assertEquals(doc.title,'New title')
167+
self.assertTrue(doc.latest_event(DocEvent,type="added_comment").desc.startswith('Title changed'))
168+
150169
def test_edit_ad(self):
151170
doc = Document.objects.get(name='status-change-imaginary-mid-review')
152171
url = urlreverse('status_change_ad',kwargs=dict(name=doc.name))

ietf/doc/urls_status_change.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
url(r'^submit/$', "submit", name='status_change_submit'),
66
url(r'^notices/$', "edit_notices", name='status_change_notices'),
77
url(r'^ad/$', "edit_ad", name='status_change_ad'),
8+
url(r'^title/$', "edit_title", name='status_change_title'),
89
url(r'^approve/$', "approve", name='status_change_approve'),
910
url(r'^telechat/$', "telechat_date", name='status_change_telechat_date'),
1011
url(r'^relations/$', "edit_relations", name='status_change_relations'),

ietf/doc/views_status_change.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,41 @@ def edit_notices(request, name):
234234
},
235235
context_instance = RequestContext(request))
236236

237+
class ChangeTitleForm(forms.Form):
238+
title = forms.CharField(max_length=255, label="Title", required=True)
239+
240+
@role_required("Area Director", "Secretariat")
241+
def edit_title(request, name):
242+
"""Change the title for this status_change document."""
243+
244+
status_change = get_object_or_404(Document, type="statchg", name=name)
245+
246+
if request.method == 'POST':
247+
form = ChangeTitleForm(request.POST)
248+
if form.is_valid():
249+
250+
status_change.title = form.cleaned_data['title']
251+
status_change.save()
252+
253+
login = request.user.person
254+
c = DocEvent(type="added_comment", doc=status_change, by=login)
255+
c.desc = "Title changed to '%s'"%status_change.title
256+
c.save()
257+
258+
return redirect("doc_view", name=status_change.name)
259+
260+
else:
261+
init = { "title" : status_change.title }
262+
form = ChangeTitleForm(initial=init)
263+
264+
titletext = '%s-%s.txt' % (status_change.canonical_name(),status_change.rev)
265+
return render_to_response('doc/change_title.html',
266+
{'form': form,
267+
'doc': status_change,
268+
'titletext' : titletext,
269+
},
270+
context_instance = RequestContext(request))
271+
237272
@role_required("Area Director", "Secretariat")
238273
def edit_ad(request, name):
239274
"""Change the shepherding Area Director for this status_change."""
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{% extends "base.html" %}
2+
3+
{% block morecss %}
4+
.warning {
5+
font-weight: bold;
6+
color: #a00;
7+
}
8+
form.edit-info #id_title {
9+
width: 600px;
10+
}
11+
{% endblock %}
12+
13+
{% block title %}
14+
Change the title for {{titletext}}
15+
{% endblock %}
16+
17+
{% block content %}
18+
<h1>Change the title for {{titletext}}</h1>
19+
20+
<form class="edit-info" action="" enctype="multipart/form-data" method="POST">
21+
<table>
22+
{% for field in form.visible_fields %}
23+
<tr>
24+
<th>{{ field.label_tag }}:</th>
25+
<td>
26+
{{ field }}
27+
{% if field.help_text %}<div class="help">{{ field.help_text }}</div>{% endif %}
28+
{{ field.errors }}
29+
</td>
30+
</tr>
31+
{% endfor %}
32+
<tr>
33+
<td></td>
34+
<td class="actions">
35+
<a href="{% url "doc_view" name=doc.canonical_name %}">Back</a>
36+
<input type="submit" value="Submit"/>
37+
</td>
38+
</tr>
39+
</table>
40+
</form>
41+
42+
{% endblock %}

ietf/templates/doc/document_status_change.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@
2424
<div>
2525
{% if snapshot %}Snapshot of{% endif %}
2626
{% if doc.get_state_slug not in approved_states %}Proposed{% endif %}
27-
Status change : {{ doc.title }} </a>
27+
Status change :
28+
<a {% if not snapshot and user|has_role:"Area Director,Secretariat" and doc.get_state_slug not in approved_states %}
29+
class="editlink" href="{% url "status_change_title" name=doc.name %}"
30+
{% endif %}
31+
>
32+
{{ doc.title }} </a>
2833
</div>
2934

3035
<table id="metatable" width="100%">

0 commit comments

Comments
 (0)