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 7c4cf7002f
This commit is contained in:
commit
086c4290b7
|
@ -147,6 +147,25 @@ class StatusChangeTests(TestCase):
|
|||
self.assertEqual(doc.notify,newlist)
|
||||
self.assertTrue(doc.latest_event(DocEvent,type="added_comment").desc.startswith('Notification list changed'))
|
||||
|
||||
def test_edit_title(self):
|
||||
doc = Document.objects.get(name='status-change-imaginary-mid-review')
|
||||
url = urlreverse('status_change_title',kwargs=dict(name=doc.name))
|
||||
|
||||
login_testing_unauthorized(self, "ad", url)
|
||||
|
||||
# normal get
|
||||
r = self.client.get(url)
|
||||
self.assertEquals(r.status_code, 200)
|
||||
q = PyQuery(r.content)
|
||||
self.assertEquals(len(q('input[name=title]')),1)
|
||||
|
||||
# change title
|
||||
r = self.client.post(url,dict(title='New title'))
|
||||
self.assertEquals(r.status_code,302)
|
||||
doc = Document.objects.get(name='status-change-imaginary-mid-review')
|
||||
self.assertEquals(doc.title,'New title')
|
||||
self.assertTrue(doc.latest_event(DocEvent,type="added_comment").desc.startswith('Title changed'))
|
||||
|
||||
def test_edit_ad(self):
|
||||
doc = Document.objects.get(name='status-change-imaginary-mid-review')
|
||||
url = urlreverse('status_change_ad',kwargs=dict(name=doc.name))
|
||||
|
|
|
@ -5,6 +5,7 @@ urlpatterns = patterns('ietf.doc.views_status_change',
|
|||
url(r'^submit/$', "submit", name='status_change_submit'),
|
||||
url(r'^notices/$', "edit_notices", name='status_change_notices'),
|
||||
url(r'^ad/$', "edit_ad", name='status_change_ad'),
|
||||
url(r'^title/$', "edit_title", name='status_change_title'),
|
||||
url(r'^approve/$', "approve", name='status_change_approve'),
|
||||
url(r'^telechat/$', "telechat_date", name='status_change_telechat_date'),
|
||||
url(r'^relations/$', "edit_relations", name='status_change_relations'),
|
||||
|
|
|
@ -234,6 +234,41 @@ def edit_notices(request, name):
|
|||
},
|
||||
context_instance = RequestContext(request))
|
||||
|
||||
class ChangeTitleForm(forms.Form):
|
||||
title = forms.CharField(max_length=255, label="Title", required=True)
|
||||
|
||||
@role_required("Area Director", "Secretariat")
|
||||
def edit_title(request, name):
|
||||
"""Change the title for this status_change document."""
|
||||
|
||||
status_change = get_object_or_404(Document, type="statchg", name=name)
|
||||
|
||||
if request.method == 'POST':
|
||||
form = ChangeTitleForm(request.POST)
|
||||
if form.is_valid():
|
||||
|
||||
status_change.title = form.cleaned_data['title']
|
||||
status_change.save()
|
||||
|
||||
login = request.user.person
|
||||
c = DocEvent(type="added_comment", doc=status_change, by=login)
|
||||
c.desc = "Title changed to '%s'"%status_change.title
|
||||
c.save()
|
||||
|
||||
return redirect("doc_view", name=status_change.name)
|
||||
|
||||
else:
|
||||
init = { "title" : status_change.title }
|
||||
form = ChangeTitleForm(initial=init)
|
||||
|
||||
titletext = '%s-%s.txt' % (status_change.canonical_name(),status_change.rev)
|
||||
return render_to_response('doc/change_title.html',
|
||||
{'form': form,
|
||||
'doc': status_change,
|
||||
'titletext' : titletext,
|
||||
},
|
||||
context_instance = RequestContext(request))
|
||||
|
||||
@role_required("Area Director", "Secretariat")
|
||||
def edit_ad(request, name):
|
||||
"""Change the shepherding Area Director for this status_change."""
|
||||
|
|
42
ietf/templates/doc/change_title.html
Normal file
42
ietf/templates/doc/change_title.html
Normal file
|
@ -0,0 +1,42 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block morecss %}
|
||||
.warning {
|
||||
font-weight: bold;
|
||||
color: #a00;
|
||||
}
|
||||
form.edit-info #id_title {
|
||||
width: 600px;
|
||||
}
|
||||
{% endblock %}
|
||||
|
||||
{% block title %}
|
||||
Change the title for {{titletext}}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Change the title for {{titletext}}</h1>
|
||||
|
||||
<form class="edit-info" action="" enctype="multipart/form-data" method="POST">
|
||||
<table>
|
||||
{% for field in form.visible_fields %}
|
||||
<tr>
|
||||
<th>{{ field.label_tag }}:</th>
|
||||
<td>
|
||||
{{ field }}
|
||||
{% if field.help_text %}<div class="help">{{ field.help_text }}</div>{% endif %}
|
||||
{{ field.errors }}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
<tr>
|
||||
<td></td>
|
||||
<td class="actions">
|
||||
<a href="{% url "doc_view" name=doc.canonical_name %}">Back</a>
|
||||
<input type="submit" value="Submit"/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
{% endblock %}
|
|
@ -24,7 +24,12 @@
|
|||
<div>
|
||||
{% if snapshot %}Snapshot of{% endif %}
|
||||
{% if doc.get_state_slug not in approved_states %}Proposed{% endif %}
|
||||
Status change : {{ doc.title }} </a>
|
||||
Status change :
|
||||
<a {% if not snapshot and user|has_role:"Area Director,Secretariat" and doc.get_state_slug not in approved_states %}
|
||||
class="editlink" href="{% url "status_change_title" name=doc.name %}"
|
||||
{% endif %}
|
||||
>
|
||||
{{ doc.title }} </a>
|
||||
</div>
|
||||
|
||||
<table id="metatable" width="100%">
|
||||
|
|
Loading…
Reference in a new issue