Skip to content

Commit

Permalink
Allow changing the title of a charter document
Browse files Browse the repository at this point in the history
Fixes #1334
Commit ready for merge
 - Legacy-Id: 8609
  • Loading branch information
Timothy B. Terriberry committed Nov 9, 2014
1 parent b74d4e7 commit 63d919e
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 0 deletions.
1 change: 1 addition & 0 deletions ietf/doc/urls_charter.py
Expand Up @@ -4,6 +4,7 @@

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'),
Expand Down
54 changes: 54 additions & 0 deletions ietf/doc/views_charter.py
Expand Up @@ -224,6 +224,60 @@ def state_pk(slug):
),
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)
Expand Down
44 changes: 44 additions & 0 deletions ietf/templates/doc/charter/change_title.html
@@ -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 %}
11 changes: 11 additions & 0 deletions ietf/templates/doc/document_charter.html
Expand Up @@ -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>
Expand Down

0 comments on commit 63d919e

Please sign in to comment.