Allow changing the title of a charter document

Fixes #1334
Commit ready for merge
 - Legacy-Id: 8609
This commit is contained in:
Timothy B. Terriberry 2014-11-09 00:46:28 +00:00
parent b74d4e7795
commit 63d919eb52
4 changed files with 110 additions and 0 deletions

View file

@ -4,6 +4,7 @@ from django.conf.urls import patterns, url
urlpatterns = patterns('',
url(r'^state/$', "ietf.doc.views_charter.change_state", name='charter_change_state'),
url(r'^title/$', "ietf.doc.views_charter.change_title", name='charter_change_title'),
url(r'^(?P<option>initcharter|recharter|abandon)/$', "ietf.doc.views_charter.change_state", name='charter_startstop_process'),
url(r'^telechat/$', "ietf.doc.views_doc.telechat_date", name='charter_telechat_date'),
url(r'^notify/$', "ietf.doc.views_doc.edit_notify", name='charter_edit_notify'),

View file

@ -224,6 +224,60 @@ def change_state(request, name, option=None):
),
context_instance=RequestContext(request))
class ChangeTitleForm(forms.Form):
charter_title = forms.CharField(widget=forms.TextInput, label="Charter title", help_text="Enter new charter title", required=True)
message = forms.CharField(widget=forms.Textarea, help_text="Leave blank to change the title without notifying the Secretariat", required=False, label=mark_safe("Message to<br> Secretariat"))
comment = forms.CharField(widget=forms.Textarea, help_text="Optional comment for the charter history", required=False)
def __init__(self, *args, **kwargs):
charter = kwargs.pop('charter')
super(ChangeTitleForm, self).__init__(*args, **kwargs)
charter_title_field = self.fields["charter_title"]
charter_title_field.initial = charter.title;
@login_required
def change_title(request, name, option=None):
"""Change title of charter, notifying parties as necessary and
logging the title as a comment."""
charter = get_object_or_404(Document, type="charter", name=name)
group = charter.group
if not can_manage_group_type(request.user, group.type_id):
return HttpResponseForbidden("You don't have permission to access this view")
login = request.user.person
if request.method == 'POST':
form = ChangeTitleForm(request.POST, charter=charter)
if form.is_valid():
clean = form.cleaned_data
charter_rev = charter.rev
new_title = clean['charter_title']
comment = clean['comment'].rstrip()
message = clean['message']
prev_title = charter.title
if new_title != prev_title:
# Charter title changed
save_document_in_history(charter)
charter.title=new_title
charter.rev = charter_rev
if comment:
c = DocEvent(type="added_comment", doc=charter, by=login)
c.desc = comment
c.save()
charter.time = datetime.datetime.now()
charter.save()
if message:
email_iesg_secretary_re_charter(request, group, "Charter title changed to %s" % new_title, message)
email_state_changed(request, charter, "Title changed to %s." % new_title)
return redirect('doc_view', name=charter.name)
else:
form = ChangeTitleForm(charter=charter)
title = "Change charter title of %s %s" % (group.acronym, group.type.name)
return render_to_response('doc/charter/change_title.html',
dict(form=form,
doc=group.charter,
login=login,
title=title,
),
context_instance=RequestContext(request))
class AdForm(forms.Form):
ad = forms.ModelChoiceField(Person.objects.filter(role__name="ad", role__group__state="active").order_by('name'),
label="Responsible AD", empty_label="(None)", required=True)

View file

@ -0,0 +1,44 @@
{% extends "base.html" %}
{% block title %}{{ title }}{% endblock %}
{% block morecss %}
form.change-title select {
width: 22em;
}
#id_charter_title, #id_message, #id_comment {
width: 40em;
}
form.change-title .actions {
text-align: right;
padding-top: 10px;
}
{% endblock %}
{% block content %}
<h1>{{ title }}</h1>
<form class="change-title" action="" method="post">{% csrf_token %}
<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 colspan="2" class="actions">
<a href="{% url "doc_view" name=doc.name %}">Back</a>
<input type="submit" value="Save and (possibly) notify Secretariat"/>
</td>
</tr>
</table>
</form>
{% endblock %}

View file

@ -22,6 +22,17 @@
</div>
<table id="metatable" width="100%">
<tr>
<td>Title:</td>
<td>
<a
{% if not snapshot and can_manage %}
class="editlink" href="{% url "charter_change_title" name=doc.name %}"
{% endif %}>
{{ doc.title }}
</a>
</td>
</tr>
<tr>
<td>WG State:</td>
<td>{{ group.state.name }}</td>