diff --git a/ietf/doc/mails.py b/ietf/doc/mails.py index d7e5b31fe..9d0d27e73 100644 --- a/ietf/doc/mails.py +++ b/ietf/doc/mails.py @@ -52,8 +52,8 @@ def email_stream_changed(request, doc, old_stream, new_stream, text=""): def email_pulled_from_rfc_queue(request, doc, comment, prev_state, next_state): extra=extra_automation_headers(doc) - extra['Cc'] = 'iesg-secretary@ietf.org' - send_mail(request, ["IANA ", "RFC Editor "], None, + extra['Cc'] = gather_addresses('doc_pulled_from_rfc_queue_cc',doc=doc) + send_mail(request, gather_address_list('doc_pulled_from_rfc_queue',doc=doc), None, "%s changed state from %s to %s" % (doc.name, prev_state.name, next_state.name), "doc/mail/pulled_from_rfc_queue_email.txt", dict(doc=doc, diff --git a/ietf/doc/utils.py b/ietf/doc/utils.py index 6572d48e4..37cee0b11 100644 --- a/ietf/doc/utils.py +++ b/ietf/doc/utils.py @@ -456,35 +456,15 @@ def rebuild_reference_relations(doc,filename=None): return ret -def collect_email_addresses(emails, doc): - for author in doc.authors.all(): - if author.address not in emails: - emails[author.address] = '"%s"' % (author.person.name) - if doc.group and doc.group.acronym != 'none': - for role in doc.group.role_set.filter(name='chair'): - if role.email.address not in emails: - emails[role.email.address] = '"%s"' % (role.person.name) - if doc.group.type.slug == 'wg': - address = '%s-ads@tools.ietf.org' % doc.group.acronym - if address not in emails: - emails[address] = '"%s-ads"' % (doc.group.acronym) - elif doc.group.type.slug == 'rg': - for role in doc.group.parent.role_set.filter(name='chair'): - if role.email.address not in emails: - emails[role.email.address] = '"%s"' % (role.person.name) - if doc.shepherd and doc.shepherd.address not in emails: - emails[doc.shepherd.address] = u'"%s"' % (doc.shepherd.person.name or "") - def set_replaces_for_document(request, doc, new_replaces, by, email_subject, email_comment=""): - emails = {} - collect_email_addresses(emails, doc) + to = gather_address_list('doc_replacement_changed',doc=doc) relationship = DocRelationshipName.objects.get(slug='replaces') old_replaces = doc.related_that_doc("replaces") for d in old_replaces: if d not in new_replaces: - collect_email_addresses(emails, d.document) + to.extend(gather_address_list('doc_replacement_changed',doc=d.document)) RelatedDocument.objects.filter(source=doc, target=d, relationship=relationship).delete() if not RelatedDocument.objects.filter(target=d, relationship=relationship): s = 'active' if d.document.expires > datetime.datetime.now() else 'expired' @@ -492,7 +472,7 @@ def set_replaces_for_document(request, doc, new_replaces, by, email_subject, ema for d in new_replaces: if d not in old_replaces: - collect_email_addresses(emails, d.document) + to.extend(gather_address_list('doc_replacement_changed',doc=d.document)) RelatedDocument.objects.create(source=doc, target=d, relationship=relationship) d.document.set_state(State.objects.get(type='draft', slug='repl')) @@ -510,10 +490,7 @@ def set_replaces_for_document(request, doc, new_replaces, by, email_subject, ema if email_comment: email_desc += "\n" + email_comment - to = [ - u'%s <%s>' % (emails[email], email) if emails[email] else u'<%s>' % email - for email in sorted(emails) - ] + to = list(set([addr for addr in to if addr])) from ietf.doc.mails import html_to_text diff --git a/ietf/doc/views_draft.py b/ietf/doc/views_draft.py index 36155714b..f654dd0be 100644 --- a/ietf/doc/views_draft.py +++ b/ietf/doc/views_draft.py @@ -450,7 +450,7 @@ def change_intention(request, name): doc.save() # TODO: Build explicit changed_intended_publication_status - email_ad(request, doc, doc.ad, login, email_desc) + email_state_changed(request, doc, email_desc,'doc_state_edited') return HttpResponseRedirect(doc.get_absolute_url()) diff --git a/ietf/mailtoken/migrations/0002_auto_20150809_1314.py b/ietf/mailtoken/migrations/0002_auto_20150809_1314.py index 0c656cb67..abab3a997 100644 --- a/ietf/mailtoken/migrations/0002_auto_20150809_1314.py +++ b/ietf/mailtoken/migrations/0002_auto_20150809_1314.py @@ -113,6 +113,10 @@ def make_recipients(apps): desc="The group's responsible AD(s) or IRTF chair", template=None) + rc(slug='doc_group_responsible_directors', + desc="The document's group's responsible AD(s) or IRTF chair", + template=None) + def make_mailtokens(apps): Recipient=apps.get_model('mailtoken','Recipient') @@ -364,6 +368,30 @@ def make_mailtokens(apps): 'doc_affecteddoc_notify', ]) + mt_factory(slug='doc_pulled_from_rfc_queue', + desc="Recipients when a document is taken out of the RFC's editor queue before publication", + recipient_slugs=['iana', + 'rfc_editor', + ]) + + mt_factory(slug='doc_pulled_from_rfc_queue_cc', + desc="Recipients when a document is taken out of the RFC's editor queue before publication", + recipient_slugs=['iesg-secretary', + 'doc_ad', + 'doc_notify', + 'doc_authors', + 'doc_shepherd', + 'doc_group_chairs', + ]) + + mt_factory(slug='doc_replacement_changed', + desc="Recipients when what a document replaces or is replaced by changes", + recipient_slugs=['doc_authors', + 'doc_notify', + 'doc_shepherd', + 'doc_group_chairs', + 'doc_group_responsible_directors', + ]) def forward(apps, schema_editor): diff --git a/ietf/mailtoken/models.py b/ietf/mailtoken/models.py index 659a63430..632e55b26 100644 --- a/ietf/mailtoken/models.py +++ b/ietf/mailtoken/models.py @@ -133,3 +133,11 @@ class Recipient(models.Model): if group.type_id=='rg': addrs.extend(Recipient.objects.get(slug='stream_managers').gather(**{'streams':['irtf']})) return addrs + + def gather_doc_group_responsible_directors(self, **kwargs): + addrs = [] + if 'doc' in kwargs: + group = kwargs['doc'].group + if group: + addrs.extend(Recipient.objects.get(slug='group_responsible_directors').gather(**{'group':group})) + return addrs diff --git a/ietf/name/fixtures/names.json b/ietf/name/fixtures/names.json index 4b72f2fc7..b31ea91f1 100644 --- a/ietf/name/fixtures/names.json +++ b/ietf/name/fixtures/names.json @@ -4407,6 +4407,14 @@ "model": "mailtoken.recipient", "pk": "doc_group_mail_list" }, +{ + "fields": { + "template": null, + "desc": "The document's group's responsible AD(s) or IRTF chair" + }, + "model": "mailtoken.recipient", + "pk": "doc_group_responsible_directors" +}, { "fields": { "template": "{{doc.notify}}", @@ -4762,6 +4770,45 @@ "model": "mailtoken.mailtoken", "pk": "doc_iana_state_changed" }, +{ + "fields": { + "recipients": [ + "iana", + "rfc_editor" + ], + "desc": "Recipients when a document is taken out of the RFC's editor queue before publication" + }, + "model": "mailtoken.mailtoken", + "pk": "doc_pulled_from_rfc_queue" +}, +{ + "fields": { + "recipients": [ + "doc_ad", + "doc_authors", + "doc_group_chairs", + "doc_notify", + "doc_shepherd" + ], + "desc": "Recipients when a document is taken out of the RFC's editor queue before publication" + }, + "model": "mailtoken.mailtoken", + "pk": "doc_pulled_from_rfc_queue_cc" +}, +{ + "fields": { + "recipients": [ + "doc_authors", + "doc_group_chairs", + "doc_group_responsible_directors", + "doc_notify", + "doc_shepherd" + ], + "desc": "Recipients when what a document replaces or is replaced by changes" + }, + "model": "mailtoken.mailtoken", + "pk": "doc_replacement_changed" +}, { "fields": { "recipients": [