99
1010from ietf .utils .mail import send_mail , send_mail_text
1111from ietf .idtracker .models import *
12+ from doc .models import Text
13+ from person .models import Email
1214
1315def email_state_changed (request , doc , text ):
1416 to = [x .strip () for x in doc .idinternal .state_change_notice_to .replace (';' , ',' ).split (',' )]
@@ -18,6 +20,17 @@ def email_state_changed(request, doc, text):
1820 dict (text = text ,
1921 url = settings .IDTRACKER_BASE_URL + doc .idinternal .get_absolute_url ()))
2022
23+ def email_state_changedREDESIGN (request , doc , text ):
24+ to = [x .strip () for x in doc .notify .replace (';' , ',' ).split (',' )]
25+ send_mail (request , to , None ,
26+ "ID Tracker State Update Notice: %s" % doc .file_tag (),
27+ "idrfc/state_changed_email.txt" ,
28+ dict (text = text ,
29+ url = settings .IDTRACKER_BASE_URL + doc .get_absolute_url ()))
30+
31+ if settings .USE_DB_REDESIGN_PROXY_CLASSES :
32+ email_state_changed = email_state_changedREDESIGN
33+
2134def html_to_text (html ):
2235 return strip_tags (html .replace ("<" , "<" ).replace (">" , ">" ).replace ("&" , "&" ).replace ("<br>" , "\n " ))
2336
@@ -34,6 +47,23 @@ def email_owner(request, doc, owner, changed_by, text, subject=None):
3447 doc = doc ,
3548 url = settings .IDTRACKER_BASE_URL + doc .idinternal .get_absolute_url ()))
3649
50+ def email_ownerREDESIGN (request , doc , owner , changed_by , text , subject = None ):
51+ if not owner or not changed_by or owner == changed_by :
52+ return
53+
54+ to = owner .formatted_email ()
55+ send_mail (request , to ,
56+ "DraftTracker Mail System <iesg-secretary@ietf.org>" ,
57+ "%s updated by %s" % (doc .file_tag (), changed_by ),
58+ "idrfc/change_notice.txt" ,
59+ dict (text = html_to_text (text ),
60+ doc = doc ,
61+ url = settings .IDTRACKER_BASE_URL + doc .get_absolute_url ()))
62+
63+ if settings .USE_DB_REDESIGN_PROXY_CLASSES :
64+ email_owner = email_ownerREDESIGN
65+
66+
3767def full_intended_status (intended_status ):
3868 s = str (intended_status )
3969 # FIXME: this should perhaps be defined in the db
@@ -54,6 +84,15 @@ def full_intended_status(intended_status):
5484 else :
5585 return "a %s" % s
5686
87+ def generate_ballot_writeup (request , doc ):
88+ e = Text ()
89+ e .type = "changed_ballot_writeup_text"
90+ e .by = request .user .get_profile ().email ()
91+ e .doc = doc
92+ e .desc = u"Ballot writeup was generated by %s" % e .by .get_name ()
93+ e .content = unicode (render_to_string ("idrfc/ballot_writeup.txt" ))
94+ e .save ()
95+
5796def generate_last_call_announcement (request , doc ):
5897 status = full_intended_status (doc .intended_status ).replace ("a " , "" ).replace ("an " , "" )
5998
@@ -86,6 +125,49 @@ def generate_last_call_announcement(request, doc):
86125 )
87126 )
88127
128+ def generate_last_call_announcementREDESIGN (request , doc ):
129+ doc .full_status = full_intended_status (doc .intended_std_level )
130+ status = doc .full_status .replace ("a " , "" ).replace ("an " , "" )
131+
132+ expiration_date = date .today () + timedelta (days = 14 )
133+ cc = []
134+ if doc .group .type_id == "individ" :
135+ group = "an individual submitter"
136+ expiration_date += timedelta (days = 14 )
137+ else :
138+ group = "the %s WG (%s)" % (doc .group .name , doc .group .acronym )
139+ if doc .group .list_email :
140+ cc .append (doc .group .list_email )
141+
142+ doc .filled_title = textwrap .fill (doc .title , width = 70 , subsequent_indent = " " * 3 )
143+ url = settings .IDTRACKER_BASE_URL + doc .get_absolute_url ()
144+
145+ mail = render_to_string ("idrfc/last_call_announcement.txt" ,
146+ dict (doc = doc ,
147+ doc_url = settings .IDTRACKER_BASE_URL + doc .get_absolute_url (),
148+ expiration_date = expiration_date .strftime ("%Y-%m-%d" ), #.strftime("%B %-d, %Y"),
149+ cc = ", " .join ("<%s>" % e for e in cc ),
150+ group = group ,
151+ docs = [doc ],
152+ urls = [url ],
153+ status = status ,
154+ impl_report = "Draft" in status or "Full" in status ,
155+ )
156+ )
157+
158+ from doc .models import Text
159+ e = Text ()
160+ e .type = "changed_last_call_text"
161+ e .by = request .user .get_profile ().email ()
162+ e .doc = doc
163+ e .desc = u"Last call announcement was generated by %s" % e .by .get_name ()
164+ e .content = unicode (mail )
165+ e .save ()
166+
167+
168+ if settings .USE_DB_REDESIGN_PROXY_CLASSES :
169+ generate_last_call_announcement = generate_last_call_announcementREDESIGN
170+
89171def generate_approval_mail (request , doc ):
90172 if doc .idinternal .cur_state_id in IDState .DO_NOT_PUBLISH_STATES or doc .idinternal .via_rfc_editor :
91173 return generate_approval_mail_rfc_editor (request , doc )
@@ -114,7 +196,7 @@ def generate_approval_mail(request, doc):
114196 if len (docs ) > 1 :
115197 made_by = "These documents have been reviewed in the IETF but are not the products of an IETF Working Group."
116198 else :
117- made_by = "This document has been reviewed in the IETF but is not the product of an IETF Working Group." ;
199+ made_by = "This document has been reviewed in the IETF but is not the product of an IETF Working Group."
118200 else :
119201 if len (docs ) > 1 :
120202 made_by = "These documents are products of the %s." % doc .group .name_with_wg
@@ -159,6 +241,95 @@ def generate_approval_mail_rfc_editor(request, doc):
159241 )
160242 )
161243
244+ DO_NOT_PUBLISH_IESG_STATES = ("nopubadw" , "nopubanw" )
245+
246+ def generate_approval_mailREDESIGN (request , doc ):
247+ if doc .iesg_state_id in DO_NOT_PUBLISH_IESG_STATES or doc .tags .filter (slug = 'via-rfc' ):
248+ mail = generate_approval_mail_rfc_editor (request , doc )
249+ else :
250+ mail = generate_approval_mail_approved (request , doc )
251+
252+ from doc .models import Text
253+ e = Text ()
254+ e .type = "changed_ballot_approval_text"
255+ e .by = request .user .get_profile ().email ()
256+ e .doc = doc
257+ e .desc = u"Ballot approval text was generated by %s" % e .by .get_name ()
258+ e .content = unicode (mail )
259+ e .save ()
260+
261+ def generate_approval_mail_approved (request , doc ):
262+ doc .full_status = full_intended_status (doc .intended_std_level .name )
263+ status = doc .full_status .replace ("a " , "" ).replace ("an " , "" )
264+
265+ if "an " in status :
266+ action_type = "Document"
267+ else :
268+ action_type = "Protocol"
269+
270+ cc = ["Internet Architecture Board <iab@iab.org>" , "RFC Editor <rfc-editor@rfc-editor.org>" ]
271+
272+ # the second check catches some area working groups (like
273+ # Transport Area Working Group)
274+ if doc .group .type_id != "area" and not doc .group .name .endswith ("Working Group" ):
275+ doc .group .name_with_wg = doc .group .name + " Working Group"
276+ if doc .group .list_email :
277+ cc .append ("%s mailing list <%s>" % (doc .group .acronym , doc .group .list_email ))
278+ cc .append ("%s chair <%s-chairs@tools.ietf.org>" % (doc .group .acronym , doc .group .acronym ))
279+ else :
280+ doc .group .name_with_wg = doc .group .name
281+
282+ doc .filled_title = textwrap .fill (doc .title , width = 70 , subsequent_indent = " " * 3 )
283+
284+ if doc .group .type_id == "individ" :
285+ made_by = "This document has been reviewed in the IETF but is not the product of an IETF Working Group."
286+ else :
287+ made_by = "This document is the product of the %s." % doc .group .name_with_wg
288+
289+ director = doc .ad
290+ other_director = Email .objects .filter (role__group__role__email = director , role__group__role__name = "ad" ).exclude (pk = director .pk )
291+
292+ if doc .group .type_id != "individ" and other_director :
293+ contacts = "The IESG contact persons are %s and %s." % (director .get_name (), other_director [0 ].get_name ())
294+ else :
295+ contacts = "The IESG contact person is %s." % director .get_name ()
296+
297+ doc_type = "RFC" if doc .state_id == "rfc" else "Internet Draft"
298+
299+ return render_to_string ("idrfc/approval_mail.txt" ,
300+ dict (doc = doc ,
301+ docs = [doc ],
302+ doc_url = settings .IDTRACKER_BASE_URL + doc .get_absolute_url (),
303+ cc = ",\n " .join (cc ),
304+ doc_type = doc_type ,
305+ made_by = made_by ,
306+ contacts = contacts ,
307+ status = status ,
308+ action_type = action_type ,
309+ )
310+ )
311+
312+ def generate_approval_mail_rfc_editorREDESIGN (request , doc ):
313+ full_status = full_intended_status (doc .intended_std_level .name )
314+ status = full_status .replace ("a " , "" ).replace ("an " , "" )
315+ disapproved = doc .iesg_state in DO_NOT_PUBLISH_IESG_STATES
316+ doc_type = "RFC" if doc .state_id == "rfc" else "Internet Draft"
317+
318+ return render_to_string ("idrfc/approval_mail_rfc_editor.txt" ,
319+ dict (doc = doc ,
320+ doc_url = settings .IDTRACKER_BASE_URL + doc .idinternal .get_absolute_url (),
321+ doc_type = doc_type ,
322+ status = status ,
323+ full_status = full_status ,
324+ disapproved = disapproved ,
325+ )
326+ )
327+
328+ if settings .USE_DB_REDESIGN_PROXY_CLASSES :
329+ generate_approval_mail = generate_approval_mailREDESIGN
330+ generate_approval_mail_rfc_editor = generate_approval_mail_rfc_editorREDESIGN
331+
332+
162333def send_last_call_request (request , doc , ballot ):
163334 to = "iesg-secretary@ietf.org"
164335 frm = '"DraftTracker Mail System" <iesg-secretary@ietf.org>'
@@ -170,6 +341,19 @@ def send_last_call_request(request, doc, ballot):
170341 dict (docs = docs ,
171342 doc_url = settings .IDTRACKER_BASE_URL + doc .idinternal .get_absolute_url ()))
172343
344+ def send_last_call_requestREDESIGN (request , doc ):
345+ to = "iesg-secretary@ietf.org"
346+ frm = '"DraftTracker Mail System" <iesg-secretary@ietf.org>'
347+
348+ send_mail (request , to , frm ,
349+ "Last Call: %s" % doc .file_tag (),
350+ "idrfc/last_call_request.txt" ,
351+ dict (docs = [doc ],
352+ doc_url = settings .IDTRACKER_BASE_URL + doc .get_absolute_url ()))
353+
354+ if settings .USE_DB_REDESIGN_PROXY_CLASSES :
355+ send_last_call_request = send_last_call_requestREDESIGN
356+
173357def email_resurrect_requested (request , doc , by ):
174358 to = "I-D Administrator <internet-drafts@ietf.org>"
175359 frm = u"%s <%s>" % by .person .email ()
0 commit comments