Skip to content

Commit 166c753

Browse files
committed
Changed the nomcom code to permit nomcom year interpolation in the nomcom from-address and in nomcom templates. Changed the nomcom from-address setting to 'nomcom-chair-{year}@ietf.org'.
- Legacy-Id: 14175
1 parent c7f4f82 commit 166c753

3 files changed

Lines changed: 45 additions & 27 deletions

File tree

ietf/nomcom/forms.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,9 @@ def save(self):
333333
duplicate_persons = self.cleaned_data.get("duplicate_persons")
334334

335335
subject = "Request to merge Person records"
336-
from_email = settings.NOMCOM_FROM_EMAIL
336+
from_email = settings.NOMCOM_FROM_EMAIL.format(year=self.nomcom.year())
337337
(to_email, cc) = gather_address_lists('person_merge_requested')
338-
context = {'primary_person':primary_person, 'duplicate_persons':duplicate_persons}
338+
context = {'primary_person':primary_person, 'duplicate_persons':duplicate_persons, 'year': self.nomcom.year(), }
339339
send_mail(None, to_email, from_email, subject, 'nomcom/merge_request.txt', context, cc=cc)
340340

341341
class NominateForm(forms.ModelForm):
@@ -427,11 +427,13 @@ def save(self, commit=True):
427427
if confirmation:
428428
if author:
429429
subject = 'Nomination receipt'
430-
from_email = settings.NOMCOM_FROM_EMAIL
430+
from_email = settings.NOMCOM_FROM_EMAIL.format(year=self.nomcom.year())
431431
(to_email, cc) = gather_address_lists('nomination_receipt_requested',nominator=author.address)
432432
context = {'nominee': nominee.email.person.name,
433433
'comments': qualifications,
434-
'position': position.name}
434+
'position': position.name,
435+
'year': self.nomcom.year(),
436+
}
435437
path = nomcom_template_path + NOMINATION_RECEIPT_TEMPLATE
436438
send_mail(None, to_email, from_email, subject, path, context, cc=cc)
437439

@@ -483,10 +485,11 @@ def clean_candidate_email(self):
483485
candidate_email = self.cleaned_data['candidate_email']
484486
if Email.objects.filter(address=candidate_email).exists():
485487
normal_url_name = 'ietf.nomcom.views.%s_nominate' % 'public' if self.public else 'private'
486-
msg = '%s is already in the datatracker. \
487-
Use the <a href="%s">normal nomination form</a> to nominate the person \
488-
with this address.\
489-
' % (candidate_email,reverse(normal_url_name,kwargs={'year':self.nomcom.year()}))
488+
msg = (('%s is already in the datatracker. '
489+
'Use the <a href="%s">normal nomination form</a> to nominate the person '
490+
'with this address. ') %
491+
(candidate_email, reverse(normal_url_name, kwargs={'year':self.nomcom.year()}) )
492+
)
490493
raise forms.ValidationError(mark_safe(msg))
491494
return candidate_email
492495

@@ -539,11 +542,13 @@ def save(self, commit=True):
539542
if confirmation:
540543
if author:
541544
subject = 'Nomination receipt'
542-
from_email = settings.NOMCOM_FROM_EMAIL
545+
from_email = settings.NOMCOM_FROM_EMAIL.format(year=self.nomcom.year())
543546
(to_email, cc) = gather_address_lists('nomination_receipt_requested',nominator=author.address)
544547
context = {'nominee': nominee.email.person.name,
545548
'comments': qualifications,
546-
'position': position.name}
549+
'position': position.name,
550+
'year': self.nomcom.year(),
551+
}
547552
path = nomcom_template_path + NOMINATION_RECEIPT_TEMPLATE
548553
send_mail(None, to_email, from_email, subject, path, context, cc=cc)
549554

@@ -625,14 +630,16 @@ def save(self, commit=True):
625630
if confirmation:
626631
if author:
627632
subject = "NomCom comment confirmation"
628-
from_email = settings.NOMCOM_FROM_EMAIL
633+
from_email = settings.NOMCOM_FROM_EMAIL.format(year=self.nomcom.year())
629634
(to_email, cc) = gather_address_lists('nomcom_comment_receipt_requested',commenter=author.address)
630635
if self.nominee and self.position:
631636
about = '%s for the position of\n%s'%(self.nominee.email.person.name, self.position.name)
632637
elif self.topic:
633638
about = self.topic.subject
634639
context = {'about': about,
635-
'comments': comments, }
640+
'comments': comments,
641+
'year': self.nomcom.year(),
642+
}
636643
path = nomcom_template_path + FEEDBACK_RECEIPT_TEMPLATE
637644
# TODO - make the thing above more generic
638645
send_mail(None, to_email, from_email, subject, path, context, cc=cc)

ietf/nomcom/utils.py

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,10 @@ def validate_public_key(public_key):
212212
def send_accept_reminder_to_nominee(nominee_position):
213213
today = datetime.date.today().strftime('%Y%m%d')
214214
subject = 'Reminder: please accept (or decline) your nomination.'
215-
from_email = settings.NOMCOM_FROM_EMAIL
216215
domain = Site.objects.get_current().domain
217216
position = nominee_position.position
218217
nomcom = position.nomcom
218+
from_email = settings.NOMCOM_FROM_EMAIL.format(year=nomcom.year())
219219
nomcom_template_path = '/nomcom/%s/' % nomcom.group.acronym
220220
mail_path = nomcom_template_path + NOMINEE_ACCEPT_REMINDER_TEMPLATE
221221
nominee = nominee_position.nominee
@@ -241,18 +241,20 @@ def send_accept_reminder_to_nominee(nominee_position):
241241
'position': position,
242242
'domain': domain,
243243
'accept_url': accept_url,
244-
'decline_url': decline_url}
244+
'decline_url': decline_url,
245+
'year': nomcom.year(),
246+
}
245247
body = render_to_string(mail_path, context)
246248
path = '%s%d/%s' % (nomcom_template_path, position.id, QUESTIONNAIRE_TEMPLATE)
247249
body += '\n\n%s' % render_to_string(path, context)
248250
send_mail_text(None, to_email, from_email, subject, body, cc=cc)
249251

250252
def send_questionnaire_reminder_to_nominee(nominee_position):
251253
subject = 'Reminder: please complete the Nomcom questionnaires for your nomination.'
252-
from_email = settings.NOMCOM_FROM_EMAIL
253254
domain = Site.objects.get_current().domain
254255
position = nominee_position.position
255256
nomcom = position.nomcom
257+
from_email = settings.NOMCOM_FROM_EMAIL.format(year=nomcom.year())
256258
nomcom_template_path = '/nomcom/%s/' % nomcom.group.acronym
257259
mail_path = nomcom_template_path + NOMINEE_QUESTIONNAIRE_REMINDER_TEMPLATE
258260
nominee = nominee_position.nominee
@@ -261,7 +263,8 @@ def send_questionnaire_reminder_to_nominee(nominee_position):
261263
context = {'nominee': nominee,
262264
'position': position,
263265
'domain': domain,
264-
}
266+
'year': nomcom.year(),
267+
}
265268
body = render_to_string(mail_path, context)
266269
path = '%s%d/%s' % (nomcom_template_path, position.id, QUESTIONNAIRE_TEMPLATE)
267270
body += '\n\n%s' % render_to_string(path, context)
@@ -296,42 +299,46 @@ def make_nomineeposition(nomcom, candidate, position, author):
296299
if nominee_position_created:
297300
# send email to nominee
298301
subject = 'IETF Nomination Information'
299-
from_email = settings.NOMCOM_FROM_EMAIL
302+
from_email = settings.NOMCOM_FROM_EMAIL.format(year=nomcom.year())
300303
(to_email, cc) = gather_address_lists('nomination_new_nominee',nominee=nominee.email.address)
301304
domain = Site.objects.get_current().domain
302305
today = datetime.date.today().strftime('%Y%m%d')
303306
hash = get_hash_nominee_position(today, nominee_position.id)
304307
accept_url = reverse('ietf.nomcom.views.process_nomination_status',
305308
None,
306-
args=(get_year_by_nomcom(nomcom),
309+
args=(nomcom.year(),
307310
nominee_position.id,
308311
'accepted',
309312
today,
310313
hash))
311314
decline_url = reverse('ietf.nomcom.views.process_nomination_status',
312315
None,
313-
args=(get_year_by_nomcom(nomcom),
316+
args=(nomcom.year(),
314317
nominee_position.id,
315318
'declined',
316319
today,
317320
hash))
318321

319322
context = {'nominee': nominee.person.name,
320323
'position': position.name,
324+
'year': nomcom.year(),
321325
'domain': domain,
322326
'accept_url': accept_url,
323-
'decline_url': decline_url}
327+
'decline_url': decline_url,
328+
}
324329

325330
path = nomcom_template_path + NOMINEE_EMAIL_TEMPLATE
326331
send_mail(None, to_email, from_email, subject, path, context, cc=cc)
327332

328333
# send email to nominee with questionnaire
329334
if nomcom.send_questionnaire:
330335
subject = '%s Questionnaire' % position
331-
from_email = settings.NOMCOM_FROM_EMAIL
336+
from_email = settings.NOMCOM_FROM_EMAIL.format(year=nomcom.year())
332337
(to_email, cc) = gather_address_lists('nomcom_questionnaire',nominee=nominee.email.address)
333338
context = {'nominee': nominee.person.name,
334-
'position': position.name}
339+
'position': position.name,
340+
'year' : nomcom.year(),
341+
}
335342
path = '%s%d/%s' % (nomcom_template_path,
336343
position.id, HEADER_QUESTIONNAIRE_TEMPLATE)
337344
body = render_to_string(path, context)
@@ -342,11 +349,13 @@ def make_nomineeposition(nomcom, candidate, position, author):
342349

343350
# send emails to nomcom chair
344351
subject = 'Nomination Information'
345-
from_email = settings.NOMCOM_FROM_EMAIL
352+
from_email = settings.NOMCOM_FROM_EMAIL.format(year=nomcom.year())
346353
(to_email, cc) = gather_address_lists('nomination_received',nomcom=nomcom)
347354
context = {'nominee': nominee.person.name,
348355
'nominee_email': nominee.email.address,
349-
'position': position.name}
356+
'position': position.name,
357+
'year': nomcom.year(),
358+
}
350359

351360
if author:
352361
context.update({'nominator': author.person.name,
@@ -372,11 +381,13 @@ def make_nomineeposition_for_newperson(nomcom, candidate_name, candidate_email,
372381

373382
# send email to secretariat and nomcomchair to warn about the new person
374383
subject = 'New person is created'
375-
from_email = settings.NOMCOM_FROM_EMAIL
384+
from_email = settings.NOMCOM_FROM_EMAIL.format(year=nomcom.year())
376385
(to_email, cc) = gather_address_lists('nomination_created_person',nomcom=nomcom)
377386
context = {'email': email.address,
378387
'fullname': email.person.name,
379-
'person_id': email.person.id}
388+
'person_id': email.person.id,
389+
'year': nomcom.year(),
390+
}
380391
nomcom_template_path = '/nomcom/%s/' % nomcom.group.acronym
381392
path = nomcom_template_path + INEXISTENT_PERSON_TEMPLATE
382393
send_mail(None, to_email, from_email, subject, path, context, cc=cc)

ietf/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ def skip_unreadable_post(record):
654654
# NomCom Tool settings
655655
ROLODEX_URL = ""
656656
NOMCOM_PUBLIC_KEYS_DIR = '/a/www/nomcom/public_keys/'
657-
NOMCOM_FROM_EMAIL = 'nomcom-chair@ietf.org'
657+
NOMCOM_FROM_EMAIL = 'nomcom-chair-{year}@ietf.org'
658658
OPENSSL_COMMAND = '/usr/bin/openssl'
659659
DAYS_TO_EXPIRE_NOMINATION_LINK = ''
660660
NOMINEE_FEEDBACK_TYPES = ['comment', 'questio', 'nomina']

0 commit comments

Comments
 (0)