|
32 | 32 | INEXISTENT_PERSON_TEMPLATE = 'email/inexistent_person.txt' |
33 | 33 | NOMINEE_EMAIL_TEMPLATE = 'email/new_nominee.txt' |
34 | 34 | NOMINATION_EMAIL_TEMPLATE = 'email/new_nomination.txt' |
35 | | -NOMINEE_REMINDER_TEMPLATE = 'email/nomination_reminder.txt' |
| 35 | +NOMINEE_ACCEPT_REMINDER_TEMPLATE = 'email/nomination_accept_reminder.txt' |
| 36 | +NOMINEE_QUESTIONNAIRE_REMINDER_TEMPLATE = 'email/questionnaire_reminder.txt' |
36 | 37 | NOMINATION_RECEIPT_TEMPLATE = 'email/nomination_receipt.txt' |
37 | 38 | FEEDBACK_RECEIPT_TEMPLATE = 'email/feedback_receipt.txt' |
38 | 39 |
|
39 | 40 | DEFAULT_NOMCOM_TEMPLATES = [HOME_TEMPLATE, |
40 | 41 | INEXISTENT_PERSON_TEMPLATE, |
41 | 42 | NOMINEE_EMAIL_TEMPLATE, |
42 | 43 | NOMINATION_EMAIL_TEMPLATE, |
43 | | - NOMINEE_REMINDER_TEMPLATE, |
| 44 | + NOMINEE_ACCEPT_REMINDER_TEMPLATE, |
| 45 | + NOMINEE_QUESTIONNAIRE_REMINDER_TEMPLATE, |
44 | 46 | NOMINATION_RECEIPT_TEMPLATE, |
45 | 47 | FEEDBACK_RECEIPT_TEMPLATE] |
46 | 48 |
|
@@ -107,7 +109,7 @@ def initialize_questionnaire_for_position(position): |
107 | 109 | content=header_template.content) |
108 | 110 | questionnaire = DBTemplate.objects.create( |
109 | 111 | group=position.nomcom.group, |
110 | | - title=template.title + '[%s]' % position.name, |
| 112 | + title=template.title + ' [%s]' % position.name, |
111 | 113 | path='/nomcom/' + position.nomcom.group.acronym + '/' + str(position.id) + '/' + QUESTIONNAIRE_TEMPLATE, |
112 | 114 | variables=template.variables, |
113 | 115 | type_id=template.type_id, |
@@ -191,15 +193,15 @@ def validate_public_key(public_key): |
191 | 193 | return (not error, error) |
192 | 194 |
|
193 | 195 |
|
194 | | -def send_reminder_to_nominee(nominee_position): |
| 196 | +def send_accept_reminder_to_nominee(nominee_position): |
195 | 197 | today = datetime.date.today().strftime('%Y%m%d') |
196 | | - subject = 'IETF Nomination Information' |
| 198 | + subject = 'Reminder: please accept (or decline) your nomination.' |
197 | 199 | from_email = settings.NOMCOM_FROM_EMAIL |
198 | 200 | domain = Site.objects.get_current().domain |
199 | 201 | position = nominee_position.position |
200 | 202 | nomcom = position.nomcom |
201 | 203 | nomcom_template_path = '/nomcom/%s/' % nomcom.group.acronym |
202 | | - mail_path = nomcom_template_path + NOMINEE_REMINDER_TEMPLATE |
| 204 | + mail_path = nomcom_template_path + NOMINEE_ACCEPT_REMINDER_TEMPLATE |
203 | 205 | nominee = nominee_position.nominee |
204 | 206 | to_email = nominee.email.address |
205 | 207 |
|
@@ -229,11 +231,42 @@ def send_reminder_to_nominee(nominee_position): |
229 | 231 | body += '\n\n%s' % render_to_string(path, context) |
230 | 232 | send_mail_text(None, to_email, from_email, subject, body) |
231 | 233 |
|
| 234 | +def send_questionnaire_reminder_to_nominee(nominee_position): |
| 235 | + today = datetime.date.today().strftime('%Y%m%d') |
| 236 | + subject = 'Reminder: please complete the Nomcom questionnaires for your nomination.' |
| 237 | + from_email = settings.NOMCOM_FROM_EMAIL |
| 238 | + domain = Site.objects.get_current().domain |
| 239 | + position = nominee_position.position |
| 240 | + nomcom = position.nomcom |
| 241 | + nomcom_template_path = '/nomcom/%s/' % nomcom.group.acronym |
| 242 | + mail_path = nomcom_template_path + NOMINEE_QUESTIONNAIRE_REMINDER_TEMPLATE |
| 243 | + nominee = nominee_position.nominee |
| 244 | + to_email = nominee.email.address |
| 245 | + |
| 246 | + hash = get_hash_nominee_position(today, nominee_position.id) |
| 247 | + |
| 248 | + context = {'nominee': nominee, |
| 249 | + 'position': position, |
| 250 | + 'domain': domain, |
| 251 | + } |
| 252 | + body = render_to_string(mail_path, context) |
| 253 | + path = '%s%d/%s' % (nomcom_template_path, position.id, QUESTIONNAIRE_TEMPLATE) |
| 254 | + body += '\n\n%s' % render_to_string(path, context) |
| 255 | + send_mail_text(None, to_email, from_email, subject, body) |
232 | 256 |
|
233 | | -def send_reminder_to_nominees(nominees): |
234 | | - for nominee in nominees: |
235 | | - for nominee_position in nominee.nomineeposition_set.pending(): |
236 | | - send_reminder_to_nominee(nominee_position) |
| 257 | +def send_reminder_to_nominees(nominees,type): |
| 258 | + addrs = [] |
| 259 | + if type=='accept': |
| 260 | + for nominee in nominees: |
| 261 | + for nominee_position in nominee.nomineeposition_set.pending(): |
| 262 | + send_accept_reminder_to_nominee(nominee_position) |
| 263 | + addrs.append(nominee_position.nominee.email.address) |
| 264 | + elif type=='questionnaire': |
| 265 | + for nominee in nominees: |
| 266 | + for nominee_position in nominee.nomineeposition_set.accepted(): |
| 267 | + send_questionnaire_reminder_to_nominee(nominee_position) |
| 268 | + addrs.append(nominee_position.nominee.email.address) |
| 269 | + return addrs |
237 | 270 |
|
238 | 271 |
|
239 | 272 | def get_or_create_nominee(nomcom, candidate_name, candidate_email, position, author): |
|
0 commit comments