|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +from __future__ import unicode_literals |
| 3 | + |
| 4 | +from django.db import migrations |
| 5 | + |
| 6 | +def make_recipients(apps): |
| 7 | + |
| 8 | + Recipient=apps.get_model('mailtoken','Recipient') |
| 9 | + |
| 10 | + rc = Recipient.objects.create |
| 11 | + |
| 12 | + rc(slug='iesg', |
| 13 | + desc='The IESG', |
| 14 | + template='The IESG <iesg@ietf.org>') |
| 15 | + |
| 16 | + rc(slug='ietf_announce', |
| 17 | + desc='The IETF Announce list', |
| 18 | + template='IETF-Announce <ietf-announce@ietf.org>') |
| 19 | + |
| 20 | + rc(slug='rfc_editor', |
| 21 | + desc='The RFC Editor', |
| 22 | + template='<rfc-editor@rfc-editor.org>') |
| 23 | + |
| 24 | + rc(slug='iesg_secretary', |
| 25 | + desc='The Secretariat', |
| 26 | + template='<iesg-secretary@ietf.org>') |
| 27 | + |
| 28 | + rc(slug='doc_authors', |
| 29 | + desc="The document's authors", |
| 30 | + template='{{doc.name}}@ietf.org') |
| 31 | + |
| 32 | + rc(slug='doc_notify', |
| 33 | + desc="The addresses in the document's notify field", |
| 34 | + template='{{doc.notify}}') |
| 35 | + |
| 36 | + rc(slug='doc_group_chairs', |
| 37 | + desc="The document's group chairs (if the document is assigned to a working or research group)", |
| 38 | + template=None) |
| 39 | + |
| 40 | + rc(slug='doc_affecteddoc_authors', |
| 41 | + desc="The authors of the subject documents of a conflict-review or status-change", |
| 42 | + template=None) |
| 43 | + |
| 44 | + rc(slug='doc_affecteddoc_group_chairs', |
| 45 | + desc="The chairs of groups of the subject documents of a conflict-review or status-change", |
| 46 | + template=None) |
| 47 | + |
| 48 | + rc(slug='doc_shepherd', |
| 49 | + desc="The document's shepherd", |
| 50 | + template='{% if doc.shepherd %}{{doc.shepherd.address}}{% endif %}' ) |
| 51 | + |
| 52 | + rc(slug='doc_ad', |
| 53 | + desc="The document's responsible Area Director", |
| 54 | + template='{% if doc.ad %}{{doc.ad.email_address}}{% endif %}' ) |
| 55 | + |
| 56 | + rc(slug='doc_group_mail_list', |
| 57 | + desc="The list address of the document's group", |
| 58 | + template=None ) |
| 59 | + |
| 60 | + rc(slug='conflict_review_stream_owner', |
| 61 | + desc="The stream owner of a document being reviewed for IETF stream conflicts", |
| 62 | + template='{% ifequal doc.type_id "conflrev" %}{% ifequal doc.stream_id "ise" %}<rfc-ise@rfc-editor.org>{% endifequal %}{% ifequal doc.stream_id "irtf" %}<irtf-chair@irtf.org>{% endifequal %}{% endifequal %}') |
| 63 | + |
| 64 | + rc(slug='iana_approve', |
| 65 | + desc="IANA's draft approval address", |
| 66 | + template='IANA <drafts-approval@icann.org>') |
| 67 | + |
| 68 | +def make_mailtokens(apps): |
| 69 | + |
| 70 | + Recipient=apps.get_model('mailtoken','Recipient') |
| 71 | + MailToken=apps.get_model('mailtoken','MailToken') |
| 72 | + |
| 73 | + def mt_factory(slug,desc,recipient_slugs): |
| 74 | + m = MailToken.objects.create(slug=slug, desc=desc) |
| 75 | + m.recipients = Recipient.objects.filter(slug__in=recipient_slugs) |
| 76 | + |
| 77 | + mt_factory(slug='ballot_saved', |
| 78 | + desc='Recipients when a new ballot position (with discusses, other blocking positions, or comments) is saved', |
| 79 | + recipient_slugs=['iesg']) |
| 80 | + |
| 81 | + mt_factory(slug='ballot_saved_cc', |
| 82 | + desc='Copied when a new ballot position (with discusses, other blocking positions, or comments) is saved', |
| 83 | + recipient_slugs=['doc_authors', |
| 84 | + 'doc_group_chairs', |
| 85 | + 'doc_shepherd', |
| 86 | + 'doc_affecteddoc_authors', |
| 87 | + 'doc_affecteddoc_group_chairs', |
| 88 | + 'conflict_review_stream_owner', |
| 89 | + ]) |
| 90 | + |
| 91 | + mt_factory(slug='ballot_deferred', |
| 92 | + desc='Recipients when a ballot is deferred to or undeferred from a future telechat', |
| 93 | + recipient_slugs=['iesg', |
| 94 | + 'iesg_secretary', |
| 95 | + 'doc_group_chairs', |
| 96 | + 'doc_notify', |
| 97 | + 'doc_authors', |
| 98 | + 'doc_shepherd', |
| 99 | + 'doc_affecteddoc_authors', |
| 100 | + 'doc_affecteddoc_group_chairs', |
| 101 | + 'conflict_review_stream_owner', |
| 102 | + ]) |
| 103 | + |
| 104 | + mt_factory(slug='ballot_approved_ietf_stream', |
| 105 | + desc='Recipients when an IETF stream document ballot is approved', |
| 106 | + recipient_slugs=['ietf_announce']) |
| 107 | + |
| 108 | + mt_factory(slug='ballot_approved_ietf_stream_cc', |
| 109 | + desc='Copied when an IETF stream document ballot is approved', |
| 110 | + recipient_slugs=['iesg', |
| 111 | + 'doc_notify', |
| 112 | + 'doc_ad', |
| 113 | + 'doc_authors', |
| 114 | + 'doc_shepherd', |
| 115 | + 'doc_group_mail_list', |
| 116 | + 'doc_group_chairs', |
| 117 | + 'rfc_editor', |
| 118 | + ]) |
| 119 | + |
| 120 | + mt_factory(slug='ballot_approved_ietf_stream_iana', |
| 121 | + desc='Recipients for IANA message when an IETF stream document ballot is approved', |
| 122 | + recipient_slugs=['iana_approve']) |
| 123 | + |
| 124 | + |
| 125 | +def forward(apps, schema_editor): |
| 126 | + |
| 127 | + make_recipients(apps) |
| 128 | + make_mailtokens(apps) |
| 129 | + |
| 130 | +def reverse(apps, schema_editor): |
| 131 | + |
| 132 | + Recipient=apps.get_model('mailtoken','Recipient') |
| 133 | + MailToken=apps.get_model('mailtoken','MailToken') |
| 134 | + |
| 135 | + Recipient.objects.all().delete() |
| 136 | + MailToken.objects.all().delete() |
| 137 | + |
| 138 | + |
| 139 | +class Migration(migrations.Migration): |
| 140 | + |
| 141 | + dependencies = [ |
| 142 | + ('mailtoken', '0001_initial'), |
| 143 | + ] |
| 144 | + |
| 145 | + operations = [ |
| 146 | + migrations.RunPython(forward, reverse) |
| 147 | + ] |
0 commit comments