Skip to content

Commit 5db9e0d

Browse files
committed
checkpoint
- Legacy-Id: 10029
1 parent 093ff52 commit 5db9e0d

9 files changed

Lines changed: 367 additions & 67 deletions

File tree

ietf/ipr/mail.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ def get_update_submitter_emails(ipr):
129129
else:
130130
email_to_iprs[email] = [related.target]
131131

132+
# TODO: This has not been converted to use mailtoken. It is complicated.
133+
# When converting it, it will need something like ipr_submitter_ietfer_or_holder perhaps
132134
for email in email_to_iprs:
133135
context = dict(
134136
to_email=email,

ietf/ipr/models.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,18 @@ def update_notified_date(self):
9292
else:
9393
return None
9494

95+
def recursively_updates(self,disc_set=None):
96+
"""Returns the set of disclosures updated directly or transitively by this disclosure"""
97+
if disc_set == None:
98+
disc_set = set()
99+
new_candidates = set([y.target.get_child() for y in self.updates])
100+
unseen = new_candidates - disc_set
101+
disc_set.update(unseen)
102+
for disc in unseen:
103+
disc_set.update(disc.recursively_updates(disc_set))
104+
return disc_set
105+
106+
95107
class HolderIprDisclosure(IprDisclosureBase):
96108
ietfer_name = models.CharField(max_length=255, blank=True) # "Whose Personal Belief Triggered..."
97109
ietfer_contact_email = models.EmailField(blank=True)

ietf/ipr/tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ def test_post(self):
489489
self.assertEqual(r.status_code,302)
490490
self.assertEqual(len(outbox),len_before+2)
491491
self.assertTrue('george@acme.com' in outbox[len_before]['To'])
492-
self.assertTrue('aread@ietf.org' in outbox[len_before+1]['To'])
492+
self.assertTrue('draft-ietf-mars-test@ietf.org' in outbox[len_before+1]['To'])
493493
self.assertTrue('mars-wg@ietf.org' in outbox[len_before+1]['Cc'])
494494

495495
def test_process_response_email(self):

ietf/ipr/views.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
from ietf.doc.models import DocAlias
1717
from ietf.group.models import Role, Group
1818
from ietf.ietfauth.utils import role_required, has_role
19-
from ietf.ipr.mail import (message_from_message, get_reply_to, get_update_submitter_emails,
20-
get_update_cc_addrs)
19+
from ietf.ipr.mail import (message_from_message, get_reply_to, get_update_submitter_emails)
2120
from ietf.ipr.fields import select2_id_ipr_title_json
2221
from ietf.ipr.forms import (HolderIprDisclosureForm, GenericDisclosureForm,
2322
ThirdPartyIprDisclosureForm, DraftForm, SearchForm, MessageModelForm,
@@ -80,13 +79,13 @@ def get_document_emails(ipr):
8079
else:
8180
cc_list = get_wg_email_list(doc.group)
8281

83-
author_emails = ','.join([a.address for a in authors])
82+
to_list = gather_addresses('ipr_posted_on_doc',doc=doc)
83+
cc_list = gather_addresses('ipr_posted_on_doc_cc',doc=doc)
8484
author_names = ', '.join([a.person.name for a in authors])
85-
cc_list += ", ipr-announce@ietf.org"
8685

8786
context = dict(
8887
doc_info=doc_info,
89-
to_email=author_emails,
88+
to_email=to_list,
9089
to_name=author_names,
9190
cc_email=cc_list,
9291
ipr=ipr)
@@ -99,16 +98,14 @@ def get_posted_emails(ipr):
9998
"""Return a list of messages suitable to initialize a NotifyFormset for
10099
the notify view when a new disclosure is posted"""
101100
messages = []
102-
# NOTE 1000+ legacy iprs have no submitter_email
103-
# add submitter message
104-
if True:
105-
context = dict(
106-
to_email=ipr.submitter_email,
107-
to_name=ipr.submitter_name,
108-
cc_email=get_update_cc_addrs(ipr),
109-
ipr=ipr)
110-
text = render_to_string('ipr/posted_submitter_email.txt',context)
111-
messages.append(text)
101+
102+
context = dict(
103+
to_email=gather_addresses('ipr_posting_confirmation',ipr=ipr),
104+
to_name=ipr.submitter_name,
105+
cc_email=gather_addresses('ipr_posting_confirmation_cc',ipr=ipr),
106+
ipr=ipr)
107+
text = render_to_string('ipr/posted_submitter_email.txt',context)
108+
messages.append(text)
112109

113110
# add email to related document authors / parties
114111
if ipr.iprdocrel_set.all():

ietf/liaisons/mails.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,13 @@
77
from ietf.utils.mail import send_mail_text
88
from ietf.liaisons.utils import role_persons_with_fixed_email
99
from ietf.group.models import Role
10+
from ietf.mailtoken.utils import gather_address_list
1011

1112
def send_liaison_by_email(request, liaison):
1213
subject = u'New Liaison Statement, "%s"' % (liaison.title)
1314
from_email = settings.LIAISON_UNIVERSAL_FROM
14-
to_email = liaison.to_contact.split(',')
15-
cc = liaison.cc.split(',')
16-
if liaison.technical_contact:
17-
cc += liaison.technical_contact.split(',')
18-
if liaison.response_contact:
19-
cc += liaison.response_contact.split(',')
15+
to_email = gather_address_list('liaison_statement_posted',liaison=liaison)
16+
cc = gather_address_list('liaison_statement_posted_cc',liaison=liaison)
2017
bcc = ['statements@ietf.org']
2118
body = render_to_string('liaisons/liaison_mail.txt', dict(
2219
liaison=liaison,
@@ -42,13 +39,14 @@ def notify_pending_by_email(request, liaison):
4239
# to_email.append('%s <%s>' % person.email())
4340
subject = u'New Liaison Statement, "%s" needs your approval' % (liaison.title)
4441
from_email = settings.LIAISON_UNIVERSAL_FROM
42+
to = gather_address_list('liaison_approval_requested',liaison=liaison)
4543
body = render_to_string('liaisons/pending_liaison_mail.txt', dict(
4644
liaison=liaison,
4745
url=settings.IDTRACKER_BASE_URL + urlreverse("liaison_approval_detail", kwargs=dict(object_id=liaison.pk)),
4846
referenced_url=settings.IDTRACKER_BASE_URL + urlreverse("liaison_detail", kwargs=dict(object_id=liaison.related_to.pk)) if liaison.related_to else None,
4947
))
5048
# send_mail_text(request, to_email, from_email, subject, body)
51-
send_mail_text(request, ['statements@ietf.org'], from_email, subject, body)
49+
send_mail_text(request, to, from_email, subject, body)
5250

5351
def send_sdo_reminder(sdo):
5452
roles = Role.objects.filter(name="liaiman", group=sdo)
@@ -58,7 +56,7 @@ def send_sdo_reminder(sdo):
5856
manager_role = roles[0]
5957

6058
subject = 'Request for update of list of authorized individuals'
61-
to_email = manager_role.email.address
59+
to_email = gather_address_list('liaison_manager_update_request',group=sdo)
6260
name = manager_role.person.plain_name()
6361

6462
authorized_list = role_persons_with_fixed_email(sdo, "auth")
@@ -95,12 +93,8 @@ def possibly_send_deadline_reminder(liaison):
9593
days_msg = 'expires %s' % PREVIOUS_DAYS[days_to_go]
9694

9795
from_email = settings.LIAISON_UNIVERSAL_FROM
98-
to_email = liaison.to_contact.split(',')
99-
cc = liaison.cc.split(',')
100-
if liaison.technical_contact:
101-
cc += liaison.technical_contact.split(',')
102-
if liaison.response_contact:
103-
cc += liaison.response_contact.split(',')
96+
to_email = gather_address_list('liaison_deadline_soon',liaison=liaison)
97+
cc = gather_address_list('liaison_deadline_soon_cc',liaison=liaison)
10498
bcc = 'statements@ietf.org'
10599
body = render_to_string('liaisons/liaison_deadline_mail.txt',
106100
dict(liaison=liaison,

ietf/mailtoken/migrations/0002_auto_20150809_1314.py

Lines changed: 101 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@ def make_recipients(apps):
161161
desc="The session request ticketing system",
162162
template='session-request@ietf.org')
163163

164+
rc(slug='logged_in_person',
165+
desc="The person currently logged into the datatracker who initiated a given action",
166+
template='{% if person and person.email_address %}{{ person.email_address }}{% endif %}')
167+
164168
rc(slug='ipr_requests',
165169
desc="The ipr disclosure handling system",
166170
template='ietf-ipr@ietf.org')
@@ -169,9 +173,47 @@ def make_recipients(apps):
169173
desc="The submitter of an IPR disclosure",
170174
template='{% if ipr.submitter_email %}{{ ipr.submitter_email }}{% endif %}')
171175

172-
rc(slug='logged_in_person',
173-
desc="The person currently logged into the datatracker who initiated a given action",
174-
template='{% if person and person.email_address %}{{ person.email_address }}{% endif %}')
176+
rc(slug='ipr_updatedipr_contacts',
177+
desc="The submitter (or ietf participant if the submitter is not available) "
178+
"of all IPR disclosures updated directly by this disclosure, without recursing "
179+
"to what the updated disclosures might have updated.",
180+
template=None)
181+
182+
rc(slug='ipr_updatedipr_holders',
183+
desc="The holders of all IPR disclosures updated by disclosure and disclosures updated by those and so on.",
184+
template=None)
185+
186+
rc(slug='ipr_announce',
187+
desc="The IETF IPR announce list",
188+
template='ipr-announce@ietf.org')
189+
190+
rc(slug='doc_ipr_group_or_ad',
191+
desc="Leadership for a document that has a new IPR disclosure",
192+
template=None)
193+
194+
rc(slug='liaison_to_contact',
195+
desc="The addresses captured in the To field of the liaison statement form",
196+
template='{{liaison.to_contact}}')
197+
198+
rc(slug='liaison_cc',
199+
desc="The addresses captured in the Cc field of the liaison statement form",
200+
template='{{liaison.cc}}')
201+
202+
rc(slug='liaison_technical_contact',
203+
desc="The addresses captured in the technical contact field of the liaison statement form",
204+
template='{{liaison.technical_contact}}')
205+
206+
rc(slug='liaison_response_contact',
207+
desc="The addresses captured in the response contact field of the liaison statement form",
208+
template='{{liaison.response_contact}}')
209+
210+
rc(slug='liaison_statements_list',
211+
desc="The IETF liaison statement ticketing system",
212+
template='statements@ietf.org')
213+
214+
rc(slug='liaison_manager',
215+
desc="The assigned liaison manager for an external group ",
216+
template=None)
175217

176218
def make_mailtokens(apps):
177219

@@ -645,6 +687,62 @@ def mt_factory(slug,desc,recipient_slugs):
645687
desc="Copied when the secretary follows up on an IPR disclosure submission",
646688
recipient_slugs=[])
647689

690+
mt_factory(slug='ipr_posting_confirmation',
691+
desc="Recipients for a message confirming that a disclosure has been posted",
692+
recipient_slugs=['ipr_submitter',
693+
])
694+
695+
mt_factory(slug='ipr_posting_confirmation_cc',
696+
desc="Copied on a message confirming that a disclosure has been posted",
697+
recipient_slugs=['ipr_updatedipr_contacts',
698+
'ipr_updatedipr_holders',
699+
])
700+
701+
mt_factory(slug='ipr_posted_on_doc',
702+
desc="Recipients when an IPR disclosure calls out a given document",
703+
recipient_slugs=['doc_authors',
704+
])
705+
706+
mt_factory(slug='ipr_posted_on_doc_cc',
707+
desc="Copied when an IPR disclosure calls out a given document",
708+
recipient_slugs=['doc_ipr_group_or_ad',
709+
'ipr_announce',
710+
])
711+
712+
mt_factory(slug='liaison_statement_posted',
713+
desc="Recipient for a message when a new liaison statement is posted",
714+
recipient_slugs=['liaison_to_contact',
715+
])
716+
717+
mt_factory(slug='liaison_statement_posted_cc',
718+
desc="Copied on a message when a new liaison statement is posted",
719+
recipient_slugs=['liaison_cc',
720+
'liaison_technical_contact',
721+
'liaison_response_contact',
722+
])
723+
724+
mt_factory(slug='liaison_approval_requested',
725+
desc="Recipients for a message that a pending liaison statement needs approval",
726+
recipient_slugs=['liaison_statements_list',
727+
])
728+
729+
mt_factory(slug='liaison_deadline_soon',
730+
desc="Recipients for a message about a liaison statement deadline that is approaching.",
731+
recipient_slugs=['liaison_to_contact',
732+
])
733+
734+
mt_factory(slug='liaison_deadline_soon_cc',
735+
desc="Copied on a message about a liaison statement deadline that is approaching.",
736+
recipient_slugs=['liaison_cc',
737+
'liaison_technical_contact',
738+
'liaison_response_contact',
739+
])
740+
741+
mt_factory(slug='liaison_manager_update_request',
742+
desc="Recipients for a message requesting an updated list of authorized individuals",
743+
recipient_slugs=['liaison_manager',
744+
])
745+
648746
def forward(apps, schema_editor):
649747

650748
make_recipients(apps)

ietf/mailtoken/models.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from django.db import models
44
from django.template import Template, Context
55

6+
from ietf.group.models import Role
7+
68
class MailToken(models.Model):
79
slug = models.CharField(max_length=32, primary_key=True)
810
desc = models.TextField(blank=True)
@@ -206,3 +208,46 @@ def gather_doc_discussing_ads(self, **kwargs):
206208
if pos and pos.pos_id == "discuss":
207209
addrs.append(ad.role_email("ad").address)
208210
return addrs
211+
212+
def gather_ipr_updatedipr_contacts(self, **kwargs):
213+
addrs=[]
214+
if 'ipr' in kwargs:
215+
ipr = kwargs['ipr']
216+
for rel in ipr.updates:
217+
if rel.target.submitter_email:
218+
addrs.append(rel.target.submitter_email)
219+
elif hasattr(rel.target,'ietfer_email') and rel.target.ietfer_email:
220+
addrs.append(rel.target.ietfer_email)
221+
return addrs
222+
223+
def gather_ipr_updatedipr_holders(self, **kwargs):
224+
addrs=[]
225+
if 'ipr' in kwargs:
226+
ipr = kwargs['ipr']
227+
for disc in ipr.recursively_updates():
228+
if hasattr(ipr,'holder_contact_email') and ipr.holder_contact_email:
229+
addrs.append(ipr.holder_contact_email)
230+
return addrs
231+
232+
def gather_doc_ipr_group_or_ad(self, **kwargs):
233+
"""A document's group email list if the document is a group document,
234+
otherwise, the document's AD if the document is active, otherwise
235+
the IETF chair"""
236+
addrs=[]
237+
if 'doc' in kwargs:
238+
doc=kwargs['doc']
239+
if doc.group and doc.group.acronym == 'none':
240+
if doc.ad and doc.get_state_slug('draft')=='active':
241+
addrs.extend(Recipient.objects.get(slug='doc_ad').gather(**kwargs))
242+
else:
243+
addrs.extend(Role.objects.filter(group__acronym='gen',name='ad').values_list('email__address',flat=True))
244+
else:
245+
addrs.extend(Recipient.objects.get(slug='doc_group_mail_list').gather(**kwargs))
246+
return addrs
247+
248+
def gather_liaison_manager(self, **kwargs):
249+
addrs=[]
250+
if 'group' in kwargs:
251+
group=kwargs['group']
252+
addrs.extend(group.role_set.filter(name='liaiman').values_list('email__address',flat=True))
253+
return addrs

0 commit comments

Comments
 (0)