1313from django .utils .encoding import force_text
1414
1515import debug # pyflakes:ignore
16+ from ietf .doc .templatetags .mail_filters import std_level_prompt
1617
1718from ietf .utils .mail import send_mail , send_mail_text
1819from ietf .ipr .utils import iprs_from_docs , related_docs
@@ -401,7 +402,7 @@ def generate_issue_ballot_mail(request, doc, ballot):
401402 last_call_expires = e .expires if e else None
402403 last_call_has_expired = last_call_expires and last_call_expires < datetime .datetime .now ()
403404
404- return render_to_string ("doc/mail/issue_ballot_mail .txt" ,
405+ return render_to_string ("doc/mail/issue_iesg_ballot_mail .txt" ,
405406 dict (doc = doc ,
406407 doc_url = settings .IDTRACKER_BASE_URL + doc .get_absolute_url (),
407408 last_call_expires = last_call_expires ,
@@ -413,6 +414,58 @@ def generate_issue_ballot_mail(request, doc, ballot):
413414 )
414415 )
415416
417+ def _send_irsg_ballot_email (request , doc , ballot , subject , template ):
418+ """Send email notification when IRSG ballot is issued"""
419+ (to , cc ) = gather_address_lists ('irsg_ballot_issued' , doc = doc )
420+ sender = 'IESG Secretary <iesg-secretary@ietf.org>'
421+
422+ ballot_expired = ballot .duedate < datetime .datetime .now ()
423+ active_ballot = doc .active_ballot ()
424+ if active_ballot is None :
425+ needed_bps = ''
426+ else :
427+ needed_bps = needed_ballot_positions (
428+ doc ,
429+ list (active_ballot .active_balloter_positions ().values ())
430+ )
431+
432+ return send_mail (
433+ request = request ,
434+ frm = sender ,
435+ to = to ,
436+ cc = cc ,
437+ subject = subject ,
438+ extra = {'Reply-To' : [sender ]},
439+ template = template ,
440+ context = dict (
441+ doc = doc ,
442+ doc_url = settings .IDTRACKER_BASE_URL + doc .get_absolute_url (),
443+ ballot_duedate = ballot .duedate ,
444+ ballot_expired = ballot_expired ,
445+ needed_ballot_positions = needed_bps ,
446+ ))
447+
448+
449+ def email_irsg_ballot_issued (request , doc , ballot ):
450+ """Send email notification when IRSG ballot is issued"""
451+ return _send_irsg_ballot_email (
452+ request ,
453+ doc ,
454+ ballot ,
455+ 'IRSG ballot issued: %s to %s' % (doc .file_tag (), std_level_prompt (doc )),
456+ 'doc/mail/issue_irsg_ballot_mail.txt' ,
457+ )
458+
459+ def email_irsg_ballot_closed (request , doc , ballot ):
460+ """Send email notification when IRSG ballot is closed"""
461+ return _send_irsg_ballot_email (
462+ request ,
463+ doc ,
464+ ballot ,
465+ 'IRSG ballot closed: %s to %s' % (doc .file_tag (), std_level_prompt (doc )),
466+ "doc/mail/close_irsg_ballot_mail.txt" ,
467+ )
468+
416469def email_iana (request , doc , to , msg , cc = None ):
417470 # fix up message and send it with extra info on doc in headers
418471 import email
0 commit comments