Add notify edit functionality, and send email to charter.notify when
the state is changed as is done for drafts. - Legacy-Id: 4396
This commit is contained in:
parent
fc01365352
commit
4f9bacbe74
|
@ -88,16 +88,24 @@
|
|||
</tr>
|
||||
{% endif %}
|
||||
|
||||
|
||||
<tr><td colspan='2'><hr size='1' noshade /></td></tr>
|
||||
|
||||
<tr>
|
||||
<td>Send notices to:</td>
|
||||
<td>{{ doc.notify|default:"none" }}
|
||||
{% if user|has_role:"Area Director,Secretariat" %}
|
||||
- <a href="{% url charter_edit_notify name=doc.name %}">Change</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr><td>Last updated:</td><td> {{ doc.time|date:"Y-m-d" }}</td></tr>
|
||||
|
||||
<tr><td colspan='2'><hr size='1' noshade /></td></tr>
|
||||
</table>
|
||||
|
||||
<div class="actions">
|
||||
<a href="/feed/wgchanges/{{ group.acronym }}/">Atom feed</a>
|
||||
<a href="/feed/group-changes/{{ group.acronym }}/">Atom feed</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
32
ietf/templates/wgcharter/edit_notify.html
Normal file
32
ietf/templates/wgcharter/edit_notify.html
Normal file
|
@ -0,0 +1,32 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Set notification list for {{ doc.name }}{% endblock %}
|
||||
|
||||
{% block morecss %}
|
||||
form.edit-notify td input#id_notify { width: 40em; }
|
||||
form.edit-notify td.actions { padding-top: 1em; }
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% load ietf_filters %}
|
||||
<h1>Set notification list for {{ doc.name }}</h1>
|
||||
|
||||
<form class="edit-notify" action="" method="POST">
|
||||
<table>
|
||||
<tr>
|
||||
<th>{{ form.notify.label_tag }}:</th>
|
||||
<td>{{ form.notify }}
|
||||
<div class="help">{{ form.notify.help_text }}</div>
|
||||
{{ form.notify.errors }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td class="actions">
|
||||
<a href="{% url doc_view name=doc.name %}">Back</a>
|
||||
<input type="submit" value="Save"/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
{% endblock %}
|
|
@ -37,6 +37,20 @@ def email_secretariat(request, wg, type, text):
|
|||
)
|
||||
)
|
||||
|
||||
def email_state_changed(request, doc, text):
|
||||
to = [e.strip() for e in doc.notify.replace(';', ',').split(',')]
|
||||
if not to:
|
||||
return
|
||||
|
||||
text = strip_tags(text)
|
||||
text += "\n\n"
|
||||
text += "URL: %s" % (settings.IDTRACKER_BASE_URL + doc.get_absolute_url())
|
||||
|
||||
send_mail_text(request, to, None,
|
||||
"State changed: %s-%s" % (doc.canonical_name(), doc.rev),
|
||||
text)
|
||||
|
||||
|
||||
def generate_ballot_writeup(request, doc):
|
||||
e = WriteupDocEvent()
|
||||
e.type = "changed_ballot_writeup_text"
|
||||
|
|
|
@ -116,6 +116,22 @@ class EditCharterTestCase(django.test.TestCase):
|
|||
charter = Document.objects.get(name=charter.name)
|
||||
self.assertTrue(not charter.latest_event(TelechatDocEvent, "scheduled_for_telechat").telechat_date)
|
||||
|
||||
def test_edit_notify(self):
|
||||
make_test_data()
|
||||
|
||||
charter = Group.objects.get(acronym="mars").charter
|
||||
|
||||
url = urlreverse('charter_edit_notify', kwargs=dict(name=charter.name))
|
||||
login_testing_unauthorized(self, "secretary", url)
|
||||
|
||||
# post
|
||||
self.assertTrue(not charter.notify)
|
||||
r = self.client.post(url, dict(notify="someone@example.com, someoneelse@example.com"))
|
||||
self.assertEquals(r.status_code, 302)
|
||||
|
||||
charter = Document.objects.get(name=charter.name)
|
||||
self.assertEquals(charter.notify, "someone@example.com, someoneelse@example.com")
|
||||
|
||||
def test_submit_charter(self):
|
||||
make_test_data()
|
||||
|
||||
|
|
|
@ -6,9 +6,9 @@ urlpatterns = patterns('',
|
|||
url(r'^state/$', "ietf.wgcharter.views.change_state", name='charter_change_state'),
|
||||
url(r'^(?P<option>initcharter|recharter|abandon)/$', "ietf.wgcharter.views.change_state", name='charter_startstop_process'),
|
||||
url(r'^telechat/$', "ietf.wgcharter.views.telechat_date", name='charter_telechat_date'),
|
||||
url(r'^notify/$', "ietf.wgcharter.views.edit_notify", name='charter_edit_notify'),
|
||||
url(r'^(?P<ann>action|review)/$', "ietf.wgcharter.views.announcement_text"),
|
||||
url(r'^ballotwriteupnotes/$', "ietf.wgcharter.views.ballot_writeupnotes"),
|
||||
url(r'^approve/$', "ietf.wgcharter.views.approve", name='charter_approve'),
|
||||
url(r'^submit/$', "ietf.wgcharter.views.submit", name='charter_submit'),
|
||||
|
||||
)
|
||||
|
|
|
@ -9,7 +9,7 @@ from django.template import RequestContext
|
|||
from django import forms
|
||||
from django.forms.util import ErrorList
|
||||
from django.utils import simplejson
|
||||
from django.utils.html import strip_tags
|
||||
from django.utils.html import strip_tags, escape
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.conf import settings
|
||||
|
||||
|
@ -112,6 +112,8 @@ def change_state(request, name, option=None):
|
|||
if message:
|
||||
email_secretariat(request, wg, "state-%s" % charter_state.slug, message)
|
||||
|
||||
email_state_changed(request, charter, "State changed to %s from %s." % (charter_state, prev))
|
||||
|
||||
if charter_state.slug == "intrev":
|
||||
if request.POST.get("ballot_wo_extern"):
|
||||
create_ballot_if_not_open(charter, login, "r-wo-ext")
|
||||
|
@ -223,6 +225,49 @@ def telechat_date(request, name):
|
|||
login=login),
|
||||
context_instance=RequestContext(request))
|
||||
|
||||
class NotifyForm(forms.Form):
|
||||
notify = forms.CharField(max_length=255, help_text="List of email addresses to receive state notifications, separated by comma", label="Notification list", required=False)
|
||||
|
||||
def clean_notify(self):
|
||||
return self.cleaned_data["notify"].strip()
|
||||
|
||||
@role_required("Area Director", "Secretariat")
|
||||
def edit_notify(request, name):
|
||||
doc = get_object_or_404(Document, type="charter", name=name)
|
||||
login = request.user.get_profile()
|
||||
|
||||
init = {'notify': doc.notify}
|
||||
|
||||
if request.method == "POST":
|
||||
form = NotifyForm(request.POST, initial=init)
|
||||
if form.is_valid():
|
||||
n = form.cleaned_data["notify"]
|
||||
if n != doc.notify:
|
||||
save_document_in_history(doc)
|
||||
|
||||
e = DocEvent(doc=doc, by=login)
|
||||
e.desc = "Notification list changed to %s" % (escape(n) or "none")
|
||||
if doc.notify:
|
||||
e.desc += " from %s" % escape(doc.notify)
|
||||
e.type = "changed_document"
|
||||
e.save()
|
||||
|
||||
doc.notify = n
|
||||
doc.time = e.time
|
||||
doc.save()
|
||||
|
||||
return redirect("doc_view", name=doc.name)
|
||||
else:
|
||||
form = NotifyForm(initial=init)
|
||||
|
||||
return render_to_response('wgcharter/edit_notify.html',
|
||||
dict(doc=doc,
|
||||
form=form,
|
||||
user=request.user,
|
||||
login=login),
|
||||
context_instance=RequestContext(request))
|
||||
|
||||
|
||||
class UploadForm(forms.Form):
|
||||
content = forms.CharField(widget=forms.Textarea, label="Charter text", help_text="Edit the charter text", required=False)
|
||||
txt = forms.FileField(label=".txt format", help_text="Or upload a .txt file", required=False)
|
||||
|
|
Loading…
Reference in a new issue