Skip to content

Commit f1e0be1

Browse files
committed
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
1 parent c508a56 commit f1e0be1

5 files changed

Lines changed: 31 additions & 11 deletions

File tree

ietf/doc/mails.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -432,15 +432,28 @@ def stream_state_email_recipients(doc, extra_recipients):
432432

433433
return res
434434

435-
def email_stream_state_changed(request, doc, prev_state, new_state, changed_by, comment="", extra_recipients=[]):
435+
def email_stream_state_changed(request, doc, prev_state, new_state, by, comment="", extra_recipients=[]):
436436
recipients = stream_state_email_recipients(doc, extra_recipients)
437437

438+
state_type = (prev_state or new_state).type
439+
438440
send_mail(request, recipients, settings.DEFAULT_FROM_EMAIL,
439-
u"Stream State Changed for Draft %s" % doc.name,
441+
u"%s changed for %s" % (state_type.label, doc.name),
440442
'doc/mail/stream_state_changed_email.txt',
441443
dict(doc=doc,
442444
url=settings.IDTRACKER_BASE_URL + doc.get_absolute_url(),
445+
state_type=state_type,
443446
prev_state=prev_state,
444447
new_state=new_state,
445-
changed_by=changed_by,
448+
by=by,
449+
comment=comment))
450+
451+
def email_draft_adopted(request, doc, by, comment):
452+
recipients = stream_state_email_recipients(doc, [])
453+
send_mail(request, recipients, settings.DEFAULT_FROM_EMAIL,
454+
u"%s adopted in %s %s" % (doc.name, doc.group.acronym, doc.group.type.name),
455+
'doc/mail/draft_adopted_email.txt',
456+
dict(doc=doc,
457+
url=settings.IDTRACKER_BASE_URL + doc.get_absolute_url(),
458+
by=by,
446459
comment=comment))

ietf/doc/tests_draft.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,6 @@ def test_adopt_document(self):
10171017
self.assertEquals(draft.stream_id, "ietf")
10181018
self.assertEquals(draft.docevent_set.count() - events_before, 4)
10191019
self.assertEquals(len(outbox), mailbox_before + 1)
1020-
self.assertTrue("state changed" in outbox[-1]["Subject"].lower())
1020+
self.assertTrue("adopted" in outbox[-1]["Subject"].lower())
10211021
self.assertTrue("wgchairman@ietf.org" in unicode(outbox[-1]))
10221022
self.assertTrue("wgdelegate@ietf.org" in unicode(outbox[-1]))
1023-

ietf/doc/views_draft.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,13 +1177,13 @@ def adopt_draft(request, name):
11771177

11781178
update_reminder(doc, "stream-s", e, due_date)
11791179

1180-
email_stream_state_changed(request, doc, prev_state, new_state, by, comment)
1181-
11821180
if comment:
11831181
e = DocEvent(type="added_comment", time=doc.time, by=by, doc=doc)
11841182
e.desc = comment
11851183
e.save()
11861184

1185+
email_draft_adopted(request, doc, by, comment)
1186+
11871187
return HttpResponseRedirect(doc.get_absolute_url())
11881188
else:
11891189
form = AdoptDraftForm(user=request.user)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{% autoescape off %}{% filter wordwrap:73 %}
2+
The document {{ doc }} has been adopted in the {{ doc.group.acronym }} {{ doc.group.type.name }} by {{ by }}:
3+
4+
{{ url }}
5+
{% if comment %}
6+
7+
Comment:
8+
{{ comment }}{% endif %}{% endfilter %}{% endautoescape %}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{% autoescape off %}{% filter wordwrap:73 %}
2-
The stream state of {{ doc }} has been changed{% if prev_state %} from {{ prev_state.name }}{% endif %} to {{ new_state.name }} by {{ changed_by }}.
2+
The {{ state_type.label }} of {{ doc }} has been changed to "{{ new_state.name }}"{% if prev_state %} from "{{ prev_state.name }}"{% endif %} by {{ by }}:
3+
4+
{{ url }}
35
{% if comment %}
46

57
Comment:
6-
{{ comment }}
7-
{% endif %}
8-
{% endfilter %}{% endautoescape %}
8+
{{ comment }}{% endif %}{% endfilter %}{% endautoescape %}

0 commit comments

Comments
 (0)