99
1010from ietf .utils .mail import send_mail , send_mail_text
1111from ietf .idtracker .models import *
12- from doc .models import Text
12+ from doc .models import Text , BallotPosition , Expiration
1313from person .models import Email
1414
1515def email_state_changed (request , doc , text ):
@@ -94,6 +94,8 @@ def generate_ballot_writeup(request, doc):
9494 e .content = unicode (render_to_string ("idrfc/ballot_writeup.txt" ))
9595 e .save ()
9696
97+ return e
98+
9799def generate_last_call_announcement (request , doc ):
98100 status = full_intended_status (doc .intended_status ).replace ("a " , "" ).replace ("an " , "" )
99101
@@ -156,14 +158,15 @@ def generate_last_call_announcementREDESIGN(request, doc):
156158 )
157159 )
158160
159- from doc .models import Text
160161 e = Text ()
161162 e .type = "changed_last_call_text"
162163 e .by = request .user .get_profile ().email ()
163164 e .doc = doc
164165 e .desc = u"Last call announcement was generated by %s" % e .by .get_name ()
165166 e .content = unicode (mail )
166167 e .save ()
168+
169+ return e
167170
168171
169172if settings .USE_DB_REDESIGN_PROXY_CLASSES :
@@ -250,7 +253,6 @@ def generate_approval_mailREDESIGN(request, doc):
250253 else :
251254 mail = generate_approval_mail_approved (request , doc )
252255
253- from doc .models import Text
254256 e = Text ()
255257 e .type = "changed_ballot_approval_text"
256258 e .by = request .user .get_profile ().email ()
@@ -259,6 +261,8 @@ def generate_approval_mailREDESIGN(request, doc):
259261 e .content = unicode (mail )
260262 e .save ()
261263
264+ return e
265+
262266def generate_approval_mail_approved (request , doc ):
263267 doc .full_status = full_intended_status (doc .intended_std_level .name )
264268 status = doc .full_status .replace ("a " , "" ).replace ("an " , "" )
@@ -467,7 +471,79 @@ def formatted(val):
467471 ad_feedback = ad_feedback
468472 )
469473 )
474+
475+ def generate_issue_ballot_mailREDESIGN (request , doc ):
476+ full_status = full_intended_status (doc .intended_std_level .name )
477+ status = full_status .replace ("a " , "" ).replace ("an " , "" )
478+
479+ active_ads = Email .objects .filter (role__name = "ad" , role__group__state = "active" )
470480
481+ e = doc .latest_event (type = "started_iesg_process" )
482+ positions = BallotPosition .objects .filter (doc = doc , type = "changed_ballot_position" , time__gte = e .time ).order_by ("-time" , '-id' ).select_related ('ad' )
483+
484+ # format positions and setup discusses and comments
485+ ad_feedback = []
486+ seen = set ()
487+ active_ad_positions = []
488+ inactive_ad_positions = []
489+ for p in positions :
490+ if p .ad in seen :
491+ continue
492+
493+ seen .add (p .ad )
494+
495+ def formatted (val ):
496+ if val :
497+ return "[ X ]"
498+ else :
499+ return "[ ]"
500+
501+ fmt = u"%-21s%-10s%-11s%-9s%-10s" % (
502+ p .ad .get_name ()[:21 ],
503+ formatted (p .pos_id == "yes" ),
504+ formatted (p .pos_id == "noobj" ),
505+ formatted (p .pos_id == "discuss" ),
506+ "[ R ]" if p .pos_id == "recuse" else formatted (p .pos_id == "abstain" ),
507+ )
508+
509+ if p .ad in active_ads :
510+ active_ad_positions .append (fmt )
511+ if not p .pos_id == "discuss" :
512+ p .discuss = ""
513+ if p .comment or p .discuss :
514+ ad_feedback .append (p )
515+ else :
516+ inactive_ad_positions .append (fmt )
517+
518+ active_ad_positions .sort ()
519+ inactive_ad_positions .sort ()
520+ ad_feedback .sort (key = lambda p : p .ad .get_name ())
521+
522+ e = doc .latest_event (Expiration , type = "sent_last_call" )
523+ last_call_expires = e .expires if e else None
524+
525+ e = doc .latest_event (Text , type = "changed_ballot_approval_text" )
526+ approval_text = e .content if e else ""
527+
528+ e = doc .latest_event (Text , type = "changed_ballot_writeup_text" )
529+ ballot_writeup = e .content if e else ""
530+
531+ return render_to_string ("idrfc/issue_ballot_mailREDESIGN.txt" ,
532+ dict (doc = doc ,
533+ doc_url = settings .IDTRACKER_BASE_URL + doc .get_absolute_url (),
534+ status = status ,
535+ active_ad_positions = active_ad_positions ,
536+ inactive_ad_positions = inactive_ad_positions ,
537+ ad_feedback = ad_feedback ,
538+ last_call_expires = last_call_expires ,
539+ approval_text = approval_text ,
540+ ballot_writeup = ballot_writeup ,
541+ )
542+ )
543+
544+ if settings .USE_DB_REDESIGN_PROXY_CLASSES :
545+ generate_issue_ballot_mail = generate_issue_ballot_mailREDESIGN
546+
471547def email_iana (request , doc , to , msg ):
472548 # fix up message and send message to IANA for each in ballot set
473549 import email
@@ -485,6 +561,25 @@ def email_iana(request, doc, to, msg):
485561 extra = extra ,
486562 bcc = "fenner@research.att.com" )
487563
564+ def email_ianaREDESIGN (request , doc , to , msg ):
565+ # fix up message and send it with extra info on doc in headers
566+ import email
567+ parsed_msg = email .message_from_string (msg .encode ("utf-8" ))
568+
569+ extra = {}
570+ extra ["Reply-To" ] = "noreply@ietf.org"
571+ extra ["X-IETF-Draft-string" ] = doc .name
572+ extra ["X-IETF-Draft-revision" ] = doc .rev
573+
574+ send_mail_text (request , "IANA <%s>" % to ,
575+ parsed_msg ["From" ], parsed_msg ["Subject" ],
576+ parsed_msg .get_payload (),
577+ extra = extra ,
578+ bcc = "fenner@research.att.com" )
579+
580+ if settings .USE_DB_REDESIGN_PROXY_CLASSES :
581+ email_iana = email_ianaREDESIGN
582+
488583def email_last_call_expired (doc ):
489584 text = "IETF Last Call has ended, and the state has been changed to\n %s." % doc .idinternal .cur_state .state
490585
0 commit comments