From 4f9bacbe74412b90dc7f8755130ddc03c19866a4 Mon Sep 17 00:00:00 2001 From: Ole Laursen Date: Fri, 4 May 2012 16:56:12 +0000 Subject: [PATCH] Add notify edit functionality, and send email to charter.notify when the state is changed as is done for drafts. - Legacy-Id: 4396 --- ietf/templates/idrfc/document_charter.html | 12 +++++- ietf/templates/wgcharter/edit_notify.html | 32 +++++++++++++++ ietf/wgcharter/mails.py | 14 +++++++ ietf/wgcharter/tests.py | 16 ++++++++ ietf/wgcharter/urls.py | 2 +- ietf/wgcharter/views.py | 47 +++++++++++++++++++++- 6 files changed, 119 insertions(+), 4 deletions(-) create mode 100644 ietf/templates/wgcharter/edit_notify.html diff --git a/ietf/templates/idrfc/document_charter.html b/ietf/templates/idrfc/document_charter.html index f1e5f4072..9aae9ec31 100644 --- a/ietf/templates/idrfc/document_charter.html +++ b/ietf/templates/idrfc/document_charter.html @@ -88,16 +88,24 @@ {% endif %} -
+ + Send notices to: + {{ doc.notify|default:"none" }} + {% if user|has_role:"Area Director,Secretariat" %} + - Change + {% endif %} + + + Last updated: {{ doc.time|date:"Y-m-d" }}
- Atom feed + Atom feed
diff --git a/ietf/templates/wgcharter/edit_notify.html b/ietf/templates/wgcharter/edit_notify.html new file mode 100644 index 000000000..632e0aec8 --- /dev/null +++ b/ietf/templates/wgcharter/edit_notify.html @@ -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 %} +

Set notification list for {{ doc.name }}

+ +
+ + + + + + + + + +
{{ form.notify.label_tag }}:{{ form.notify }} +
{{ form.notify.help_text }}
+ {{ form.notify.errors }} +
+ Back + +
+
+{% endblock %} diff --git a/ietf/wgcharter/mails.py b/ietf/wgcharter/mails.py index 40dc50816..834c583e4 100644 --- a/ietf/wgcharter/mails.py +++ b/ietf/wgcharter/mails.py @@ -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" diff --git a/ietf/wgcharter/tests.py b/ietf/wgcharter/tests.py index e2a10e3d4..309afe314 100644 --- a/ietf/wgcharter/tests.py +++ b/ietf/wgcharter/tests.py @@ -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() diff --git a/ietf/wgcharter/urls.py b/ietf/wgcharter/urls.py index 79ee1c247..ec01728c7 100644 --- a/ietf/wgcharter/urls.py +++ b/ietf/wgcharter/urls.py @@ -6,9 +6,9 @@ urlpatterns = patterns('', url(r'^state/$', "ietf.wgcharter.views.change_state", name='charter_change_state'), url(r'^(?P