Improve the stream state change email a bit, switch to using a

specific message for adoptions with the name of the WG/RG
 - Legacy-Id: 6270
This commit is contained in:
Ole Laursen 2013-09-26 15:03:55 +00:00
parent c508a5672d
commit f1e0be1033
5 changed files with 31 additions and 11 deletions

View file

@ -432,15 +432,28 @@ def stream_state_email_recipients(doc, extra_recipients):
return res
def email_stream_state_changed(request, doc, prev_state, new_state, changed_by, comment="", extra_recipients=[]):
def email_stream_state_changed(request, doc, prev_state, new_state, by, comment="", extra_recipients=[]):
recipients = stream_state_email_recipients(doc, extra_recipients)
state_type = (prev_state or new_state).type
send_mail(request, recipients, settings.DEFAULT_FROM_EMAIL,
u"Stream State Changed for Draft %s" % doc.name,
u"%s changed for %s" % (state_type.label, doc.name),
'doc/mail/stream_state_changed_email.txt',
dict(doc=doc,
url=settings.IDTRACKER_BASE_URL + doc.get_absolute_url(),
state_type=state_type,
prev_state=prev_state,
new_state=new_state,
changed_by=changed_by,
by=by,
comment=comment))
def email_draft_adopted(request, doc, by, comment):
recipients = stream_state_email_recipients(doc, [])
send_mail(request, recipients, settings.DEFAULT_FROM_EMAIL,
u"%s adopted in %s %s" % (doc.name, doc.group.acronym, doc.group.type.name),
'doc/mail/draft_adopted_email.txt',
dict(doc=doc,
url=settings.IDTRACKER_BASE_URL + doc.get_absolute_url(),
by=by,
comment=comment))

View file

@ -1017,7 +1017,6 @@ class AdoptDraftTests(django.test.TestCase):
self.assertEquals(draft.stream_id, "ietf")
self.assertEquals(draft.docevent_set.count() - events_before, 4)
self.assertEquals(len(outbox), mailbox_before + 1)
self.assertTrue("state changed" in outbox[-1]["Subject"].lower())
self.assertTrue("adopted" in outbox[-1]["Subject"].lower())
self.assertTrue("wgchairman@ietf.org" in unicode(outbox[-1]))
self.assertTrue("wgdelegate@ietf.org" in unicode(outbox[-1]))

View file

@ -1177,13 +1177,13 @@ def adopt_draft(request, name):
update_reminder(doc, "stream-s", e, due_date)
email_stream_state_changed(request, doc, prev_state, new_state, by, comment)
if comment:
e = DocEvent(type="added_comment", time=doc.time, by=by, doc=doc)
e.desc = comment
e.save()
email_draft_adopted(request, doc, by, comment)
return HttpResponseRedirect(doc.get_absolute_url())
else:
form = AdoptDraftForm(user=request.user)

View file

@ -0,0 +1,8 @@
{% autoescape off %}{% filter wordwrap:73 %}
The document {{ doc }} has been adopted in the {{ doc.group.acronym }} {{ doc.group.type.name }} by {{ by }}:
{{ url }}
{% if comment %}
Comment:
{{ comment }}{% endif %}{% endfilter %}{% endautoescape %}

View file

@ -1,8 +1,8 @@
{% autoescape off %}{% filter wordwrap:73 %}
The stream state of {{ doc }} has been changed{% if prev_state %} from {{ prev_state.name }}{% endif %} to {{ new_state.name }} by {{ changed_by }}.
The {{ state_type.label }} of {{ doc }} has been changed to "{{ new_state.name }}"{% if prev_state %} from "{{ prev_state.name }}"{% endif %} by {{ by }}:
{{ url }}
{% if comment %}
Comment:
{{ comment }}
{% endif %}
{% endfilter %}{% endautoescape %}
{{ comment }}{% endif %}{% endfilter %}{% endautoescape %}