Skip to content

Commit 7c4cf70

Browse files
committed
Allow the secretariat and ads to change the title of a status change document.
Fixes bug 1141 Commit ready to merge. - Legacy-Id: 6361
1 parent faabcb8 commit 7c4cf70

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
@@ -150,6 +150,25 @@ def test_edit_notices(self):
150150
self.assertEquals(doc.notify,newlist)
151151
self.assertTrue(doc.latest_event(DocEvent,type="added_comment").desc.startswith('Notification list changed'))
152152

153+
def test_edit_title(self):
154+
doc = Document.objects.get(name='status-change-imaginary-mid-review')
155+
url = urlreverse('status_change_title',kwargs=dict(name=doc.name))
156+
157+
login_testing_unauthorized(self, "ad", url)
158+
159+
# normal get
160+
r = self.client.get(url)
161+
self.assertEquals(r.status_code, 200)
162+
q = PyQuery(r.content)
163+
self.assertEquals(len(q('input[name=title]')),1)
164+
165+
# change title
166+
r = self.client.post(url,dict(title='New title'))
167+
self.assertEquals(r.status_code,302)
168+
doc = Document.objects.get(name='status-change-imaginary-mid-review')
169+
self.assertEquals(doc.title,'New title')
170+
self.assertTrue(doc.latest_event(DocEvent,type="added_comment").desc.startswith('Title changed'))
171+
153172
def test_edit_ad(self):
154173
doc = Document.objects.get(name='status-change-imaginary-mid-review')
155174
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
@@ -236,6 +236,41 @@ def edit_notices(request, name):
236236
},
237237
context_instance = RequestContext(request))
238238

239+
class ChangeTitleForm(forms.Form):
240+
title = forms.CharField(max_length=255, label="Title", required=True)
241+
242+
@role_required("Area Director", "Secretariat")
243+
def edit_title(request, name):
244+
"""Change the title for this status_change document."""
245+
246+
status_change = get_object_or_404(Document, type="statchg", name=name)
247+
248+
if request.method == 'POST':
249+
form = ChangeTitleForm(request.POST)
250+
if form.is_valid():
251+
252+
status_change.title = form.cleaned_data['title']
253+
status_change.save()
254+
255+
login = request.user.get_profile()
256+
c = DocEvent(type="added_comment", doc=status_change, by=login)
257+
c.desc = "Title changed to '%s'"%status_change.title
258+
c.save()
259+
260+
return redirect("doc_view", name=status_change.name)
261+
262+
else:
263+
init = { "title" : status_change.title }
264+
form = ChangeTitleForm(initial=init)
265+
266+
titletext = '%s-%s.txt' % (status_change.canonical_name(),status_change.rev)
267+
return render_to_response('doc/change_title.html',
268+
{'form': form,
269+
'doc': status_change,
270+
'titletext' : titletext,
271+
},
272+
context_instance = RequestContext(request))
273+
239274
@role_required("Area Director", "Secretariat")
240275
def edit_ad(request, name):
241276
"""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)