Skip to content

Commit aebd885

Browse files
committed
Moved the tokens created so far into a migration
- Legacy-Id: 9994
1 parent 7649397 commit aebd885

4 files changed

Lines changed: 151 additions & 102 deletions

File tree

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
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+
]

ietf/mailtoken/models.py

Lines changed: 0 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -67,101 +67,3 @@ def gather_doc_affecteddoc_group_chairs(self, **kwargs):
6767
addrs.extend(Recipient.objects.get(slug='doc_group_chairs').gather(**{'doc':reldoc.document}))
6868
return addrs
6969

70-
def make_recipients():
71-
72-
Recipient.objects.all().delete()
73-
Recipient.objects.create(slug='iesg',
74-
desc='The IESG',
75-
template='The IESG <iesg@ietf.org>')
76-
Recipient.objects.create(slug='ietf_announce',
77-
desc='The IETF Announce list',
78-
template='IETF-Announce <ietf-announce@ietf.org>')
79-
Recipient.objects.create(slug='rfc_editor',
80-
desc='The RFC Editor',
81-
template='<rfc-editor@rfc-editor.org>')
82-
Recipient.objects.create(slug='iesg_secretary',
83-
desc='The Secretariat',
84-
template='<iesg-secretary@ietf.org>')
85-
Recipient.objects.create(slug='doc_authors',
86-
desc="The document's authors",
87-
template='{{doc.name}}@ietf.org')
88-
Recipient.objects.create(slug='doc_notify',
89-
desc="The addresses in the document's notify field",
90-
template='{{doc.notify}}')
91-
Recipient.objects.create(slug='doc_group_chairs',
92-
desc="The document's group chairs (if the document is assigned to a working or research group)",
93-
template=None)
94-
Recipient.objects.create(slug='doc_affecteddoc_authors',
95-
desc="The authors of the subject documents of a conflict-review or status-change",
96-
template=None)
97-
Recipient.objects.create(slug='doc_affecteddoc_group_chairs',
98-
desc="The chairs of groups of the subject documents of a conflict-review or status-change",
99-
template=None)
100-
Recipient.objects.create(slug='doc_shepherd',
101-
desc="The document's shepherd",
102-
template='{% if doc.shepherd %}{{doc.shepherd.address}}{% endif %}' )
103-
Recipient.objects.create(slug='doc_ad',
104-
desc="The document's responsible Area Director",
105-
template='{% if doc.ad %}{{doc.ad.email_address}}{% endif %}' )
106-
Recipient.objects.create(slug='doc_group_mail_list',
107-
desc="The list address of the document's group",
108-
template=None )
109-
Recipient.objects.create(slug='conflict_review_stream_owner',
110-
desc="The stream owner of a document being reviewed for IETF stream conflicts",
111-
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 %}')
112-
Recipient.objects.create(slug='iana_approve',
113-
desc="IANA's draft approval address",
114-
template='IANA <drafts-approval@icann.org>')
115-
116-
def make_mailtokens():
117-
118-
MailToken.objects.all().delete()
119-
120-
m = MailToken.objects.create(slug='ballot_saved',
121-
desc='Recipients when a new ballot position (with discusses, other blocking positions, or comments) is saved')
122-
m.recipients = Recipient.objects.filter(slug__in=['iesg'])
123-
124-
m = MailToken.objects.create(slug='ballot_saved_cc',
125-
desc='Copied when a new ballot position (with discusses, other blocking positions, or comments) is saved')
126-
m.recipients = Recipient.objects.filter(slug__in=['doc_authors',
127-
'doc_group_chairs',
128-
'doc_shepherd',
129-
'doc_affecteddoc_authors',
130-
'doc_affecteddoc_group_chairs',
131-
'conflict_review_stream_owner',
132-
])
133-
134-
m = MailToken.objects.create(slug='ballot_deferred',
135-
desc='Recipients when a ballot is deferred to or undeferred from a future telechat')
136-
m.recipients = Recipient.objects.filter(slug__in=['iesg',
137-
'iesg_secretary',
138-
'doc_group_chairs',
139-
'doc_notify',
140-
'doc_authors',
141-
'doc_shepherd',
142-
'doc_affecteddoc_authors',
143-
'doc_affecteddoc_group_chairs',
144-
'conflict_review_stream_owner',
145-
])
146-
147-
m = MailToken.objects.create(slug='ballot_approved_ietf_stream',
148-
desc='Recipients when an IETF stream document ballot is approved')
149-
m.recipients = Recipient.objects.filter(slug__in=['ietf_announce'])
150-
151-
m = MailToken.objects.create(slug='ballot_approved_ietf_stream_cc',
152-
desc='Copied when an IETF stream document ballot is approved')
153-
m.recipients = Recipient.objects.filter(slug__in=['iesg',
154-
'doc_notify',
155-
'doc_ad',
156-
'doc_authors',
157-
'doc_shepherd',
158-
'doc_group_mail_list',
159-
'doc_group_chairs',
160-
'rfc_editor',
161-
])
162-
163-
m = MailToken.objects.create(slug='ballot_approved_ietf_stream_iana',
164-
desc='Recipients for IANA message when an IETF stream document ballot is approved')
165-
m.recipients = Recipient.objects.filter(slug__in=['iana_approve'])
166-
167-

ietf/templates/mailtoken/recipient.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ <h1>Mail Recipients</h1>
1313
<thead>
1414
<tr>
1515
<th>Recipient</th>
16-
<th>Events</th>
16+
<th>Tokens</th>
1717
<th>Template</th>
1818
<th>Code</th>
1919
</tr>

ietf/templates/mailtoken/token.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
{# Copyright The IETF Trust 2015, All Rights Reserved #}
33
{% load origin %}
44

5-
{% block title %}Mail Events{% endblock %}
5+
{% block title %}Mail Tokens{% endblock %}
66

77

88
{% block content %}
99
{% origin %}
10-
<h1>Mail Events</h1>
10+
<h1>Mail Tokens</h1>
1111

1212
<table class="table table-condensed table-striped">
1313
<thead>
1414
<tr>
15-
<th>Event</th>
15+
<th>Token</th>
1616
<th>Recipients</th>
1717
</tr>
1818
</thead>

0 commit comments

Comments
 (0)