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
This commit is contained in:
Henrik Levkowetz 2017-09-27 21:20:59 +00:00
parent c7f4f82c31
commit 166c7531f9
3 changed files with 45 additions and 27 deletions

View file

@ -333,9 +333,9 @@ class MergePersonForm(forms.Form):
duplicate_persons = self.cleaned_data.get("duplicate_persons") duplicate_persons = self.cleaned_data.get("duplicate_persons")
subject = "Request to merge Person records" subject = "Request to merge Person records"
from_email = settings.NOMCOM_FROM_EMAIL from_email = settings.NOMCOM_FROM_EMAIL.format(year=self.nomcom.year())
(to_email, cc) = gather_address_lists('person_merge_requested') (to_email, cc) = gather_address_lists('person_merge_requested')
context = {'primary_person':primary_person, 'duplicate_persons':duplicate_persons} context = {'primary_person':primary_person, 'duplicate_persons':duplicate_persons, 'year': self.nomcom.year(), }
send_mail(None, to_email, from_email, subject, 'nomcom/merge_request.txt', context, cc=cc) send_mail(None, to_email, from_email, subject, 'nomcom/merge_request.txt', context, cc=cc)
class NominateForm(forms.ModelForm): class NominateForm(forms.ModelForm):
@ -427,11 +427,13 @@ class NominateForm(forms.ModelForm):
if confirmation: if confirmation:
if author: if author:
subject = 'Nomination receipt' subject = 'Nomination receipt'
from_email = settings.NOMCOM_FROM_EMAIL from_email = settings.NOMCOM_FROM_EMAIL.format(year=self.nomcom.year())
(to_email, cc) = gather_address_lists('nomination_receipt_requested',nominator=author.address) (to_email, cc) = gather_address_lists('nomination_receipt_requested',nominator=author.address)
context = {'nominee': nominee.email.person.name, context = {'nominee': nominee.email.person.name,
'comments': qualifications, 'comments': qualifications,
'position': position.name} 'position': position.name,
'year': self.nomcom.year(),
}
path = nomcom_template_path + NOMINATION_RECEIPT_TEMPLATE path = nomcom_template_path + NOMINATION_RECEIPT_TEMPLATE
send_mail(None, to_email, from_email, subject, path, context, cc=cc) send_mail(None, to_email, from_email, subject, path, context, cc=cc)
@ -483,10 +485,11 @@ class NominateNewPersonForm(forms.ModelForm):
candidate_email = self.cleaned_data['candidate_email'] candidate_email = self.cleaned_data['candidate_email']
if Email.objects.filter(address=candidate_email).exists(): if Email.objects.filter(address=candidate_email).exists():
normal_url_name = 'ietf.nomcom.views.%s_nominate' % 'public' if self.public else 'private' normal_url_name = 'ietf.nomcom.views.%s_nominate' % 'public' if self.public else 'private'
msg = '%s is already in the datatracker. \ msg = (('%s is already in the datatracker. '
Use the <a href="%s">normal nomination form</a> to nominate the person \ 'Use the <a href="%s">normal nomination form</a> to nominate the person '
with this address.\ 'with this address. ') %
' % (candidate_email,reverse(normal_url_name,kwargs={'year':self.nomcom.year()})) (candidate_email, reverse(normal_url_name, kwargs={'year':self.nomcom.year()}) )
)
raise forms.ValidationError(mark_safe(msg)) raise forms.ValidationError(mark_safe(msg))
return candidate_email return candidate_email
@ -539,11 +542,13 @@ class NominateNewPersonForm(forms.ModelForm):
if confirmation: if confirmation:
if author: if author:
subject = 'Nomination receipt' subject = 'Nomination receipt'
from_email = settings.NOMCOM_FROM_EMAIL from_email = settings.NOMCOM_FROM_EMAIL.format(year=self.nomcom.year())
(to_email, cc) = gather_address_lists('nomination_receipt_requested',nominator=author.address) (to_email, cc) = gather_address_lists('nomination_receipt_requested',nominator=author.address)
context = {'nominee': nominee.email.person.name, context = {'nominee': nominee.email.person.name,
'comments': qualifications, 'comments': qualifications,
'position': position.name} 'position': position.name,
'year': self.nomcom.year(),
}
path = nomcom_template_path + NOMINATION_RECEIPT_TEMPLATE path = nomcom_template_path + NOMINATION_RECEIPT_TEMPLATE
send_mail(None, to_email, from_email, subject, path, context, cc=cc) send_mail(None, to_email, from_email, subject, path, context, cc=cc)
@ -625,14 +630,16 @@ class FeedbackForm(forms.ModelForm):
if confirmation: if confirmation:
if author: if author:
subject = "NomCom comment confirmation" subject = "NomCom comment confirmation"
from_email = settings.NOMCOM_FROM_EMAIL from_email = settings.NOMCOM_FROM_EMAIL.format(year=self.nomcom.year())
(to_email, cc) = gather_address_lists('nomcom_comment_receipt_requested',commenter=author.address) (to_email, cc) = gather_address_lists('nomcom_comment_receipt_requested',commenter=author.address)
if self.nominee and self.position: if self.nominee and self.position:
about = '%s for the position of\n%s'%(self.nominee.email.person.name, self.position.name) about = '%s for the position of\n%s'%(self.nominee.email.person.name, self.position.name)
elif self.topic: elif self.topic:
about = self.topic.subject about = self.topic.subject
context = {'about': about, context = {'about': about,
'comments': comments, } 'comments': comments,
'year': self.nomcom.year(),
}
path = nomcom_template_path + FEEDBACK_RECEIPT_TEMPLATE path = nomcom_template_path + FEEDBACK_RECEIPT_TEMPLATE
# TODO - make the thing above more generic # TODO - make the thing above more generic
send_mail(None, to_email, from_email, subject, path, context, cc=cc) send_mail(None, to_email, from_email, subject, path, context, cc=cc)

View file

@ -212,10 +212,10 @@ def validate_public_key(public_key):
def send_accept_reminder_to_nominee(nominee_position): def send_accept_reminder_to_nominee(nominee_position):
today = datetime.date.today().strftime('%Y%m%d') today = datetime.date.today().strftime('%Y%m%d')
subject = 'Reminder: please accept (or decline) your nomination.' subject = 'Reminder: please accept (or decline) your nomination.'
from_email = settings.NOMCOM_FROM_EMAIL
domain = Site.objects.get_current().domain domain = Site.objects.get_current().domain
position = nominee_position.position position = nominee_position.position
nomcom = position.nomcom nomcom = position.nomcom
from_email = settings.NOMCOM_FROM_EMAIL.format(year=nomcom.year())
nomcom_template_path = '/nomcom/%s/' % nomcom.group.acronym nomcom_template_path = '/nomcom/%s/' % nomcom.group.acronym
mail_path = nomcom_template_path + NOMINEE_ACCEPT_REMINDER_TEMPLATE mail_path = nomcom_template_path + NOMINEE_ACCEPT_REMINDER_TEMPLATE
nominee = nominee_position.nominee nominee = nominee_position.nominee
@ -241,7 +241,9 @@ def send_accept_reminder_to_nominee(nominee_position):
'position': position, 'position': position,
'domain': domain, 'domain': domain,
'accept_url': accept_url, 'accept_url': accept_url,
'decline_url': decline_url} 'decline_url': decline_url,
'year': nomcom.year(),
}
body = render_to_string(mail_path, context) body = render_to_string(mail_path, context)
path = '%s%d/%s' % (nomcom_template_path, position.id, QUESTIONNAIRE_TEMPLATE) path = '%s%d/%s' % (nomcom_template_path, position.id, QUESTIONNAIRE_TEMPLATE)
body += '\n\n%s' % render_to_string(path, context) body += '\n\n%s' % render_to_string(path, context)
@ -249,10 +251,10 @@ def send_accept_reminder_to_nominee(nominee_position):
def send_questionnaire_reminder_to_nominee(nominee_position): def send_questionnaire_reminder_to_nominee(nominee_position):
subject = 'Reminder: please complete the Nomcom questionnaires for your nomination.' subject = 'Reminder: please complete the Nomcom questionnaires for your nomination.'
from_email = settings.NOMCOM_FROM_EMAIL
domain = Site.objects.get_current().domain domain = Site.objects.get_current().domain
position = nominee_position.position position = nominee_position.position
nomcom = position.nomcom nomcom = position.nomcom
from_email = settings.NOMCOM_FROM_EMAIL.format(year=nomcom.year())
nomcom_template_path = '/nomcom/%s/' % nomcom.group.acronym nomcom_template_path = '/nomcom/%s/' % nomcom.group.acronym
mail_path = nomcom_template_path + NOMINEE_QUESTIONNAIRE_REMINDER_TEMPLATE mail_path = nomcom_template_path + NOMINEE_QUESTIONNAIRE_REMINDER_TEMPLATE
nominee = nominee_position.nominee nominee = nominee_position.nominee
@ -261,7 +263,8 @@ def send_questionnaire_reminder_to_nominee(nominee_position):
context = {'nominee': nominee, context = {'nominee': nominee,
'position': position, 'position': position,
'domain': domain, 'domain': domain,
} 'year': nomcom.year(),
}
body = render_to_string(mail_path, context) body = render_to_string(mail_path, context)
path = '%s%d/%s' % (nomcom_template_path, position.id, QUESTIONNAIRE_TEMPLATE) path = '%s%d/%s' % (nomcom_template_path, position.id, QUESTIONNAIRE_TEMPLATE)
body += '\n\n%s' % render_to_string(path, context) body += '\n\n%s' % render_to_string(path, context)
@ -296,21 +299,21 @@ def make_nomineeposition(nomcom, candidate, position, author):
if nominee_position_created: if nominee_position_created:
# send email to nominee # send email to nominee
subject = 'IETF Nomination Information' subject = 'IETF Nomination Information'
from_email = settings.NOMCOM_FROM_EMAIL from_email = settings.NOMCOM_FROM_EMAIL.format(year=nomcom.year())
(to_email, cc) = gather_address_lists('nomination_new_nominee',nominee=nominee.email.address) (to_email, cc) = gather_address_lists('nomination_new_nominee',nominee=nominee.email.address)
domain = Site.objects.get_current().domain domain = Site.objects.get_current().domain
today = datetime.date.today().strftime('%Y%m%d') today = datetime.date.today().strftime('%Y%m%d')
hash = get_hash_nominee_position(today, nominee_position.id) hash = get_hash_nominee_position(today, nominee_position.id)
accept_url = reverse('ietf.nomcom.views.process_nomination_status', accept_url = reverse('ietf.nomcom.views.process_nomination_status',
None, None,
args=(get_year_by_nomcom(nomcom), args=(nomcom.year(),
nominee_position.id, nominee_position.id,
'accepted', 'accepted',
today, today,
hash)) hash))
decline_url = reverse('ietf.nomcom.views.process_nomination_status', decline_url = reverse('ietf.nomcom.views.process_nomination_status',
None, None,
args=(get_year_by_nomcom(nomcom), args=(nomcom.year(),
nominee_position.id, nominee_position.id,
'declined', 'declined',
today, today,
@ -318,9 +321,11 @@ def make_nomineeposition(nomcom, candidate, position, author):
context = {'nominee': nominee.person.name, context = {'nominee': nominee.person.name,
'position': position.name, 'position': position.name,
'year': nomcom.year(),
'domain': domain, 'domain': domain,
'accept_url': accept_url, 'accept_url': accept_url,
'decline_url': decline_url} 'decline_url': decline_url,
}
path = nomcom_template_path + NOMINEE_EMAIL_TEMPLATE path = nomcom_template_path + NOMINEE_EMAIL_TEMPLATE
send_mail(None, to_email, from_email, subject, path, context, cc=cc) send_mail(None, to_email, from_email, subject, path, context, cc=cc)
@ -328,10 +333,12 @@ def make_nomineeposition(nomcom, candidate, position, author):
# send email to nominee with questionnaire # send email to nominee with questionnaire
if nomcom.send_questionnaire: if nomcom.send_questionnaire:
subject = '%s Questionnaire' % position subject = '%s Questionnaire' % position
from_email = settings.NOMCOM_FROM_EMAIL from_email = settings.NOMCOM_FROM_EMAIL.format(year=nomcom.year())
(to_email, cc) = gather_address_lists('nomcom_questionnaire',nominee=nominee.email.address) (to_email, cc) = gather_address_lists('nomcom_questionnaire',nominee=nominee.email.address)
context = {'nominee': nominee.person.name, context = {'nominee': nominee.person.name,
'position': position.name} 'position': position.name,
'year' : nomcom.year(),
}
path = '%s%d/%s' % (nomcom_template_path, path = '%s%d/%s' % (nomcom_template_path,
position.id, HEADER_QUESTIONNAIRE_TEMPLATE) position.id, HEADER_QUESTIONNAIRE_TEMPLATE)
body = render_to_string(path, context) body = render_to_string(path, context)
@ -342,11 +349,13 @@ def make_nomineeposition(nomcom, candidate, position, author):
# send emails to nomcom chair # send emails to nomcom chair
subject = 'Nomination Information' subject = 'Nomination Information'
from_email = settings.NOMCOM_FROM_EMAIL from_email = settings.NOMCOM_FROM_EMAIL.format(year=nomcom.year())
(to_email, cc) = gather_address_lists('nomination_received',nomcom=nomcom) (to_email, cc) = gather_address_lists('nomination_received',nomcom=nomcom)
context = {'nominee': nominee.person.name, context = {'nominee': nominee.person.name,
'nominee_email': nominee.email.address, 'nominee_email': nominee.email.address,
'position': position.name} 'position': position.name,
'year': nomcom.year(),
}
if author: if author:
context.update({'nominator': author.person.name, context.update({'nominator': author.person.name,
@ -372,11 +381,13 @@ def make_nomineeposition_for_newperson(nomcom, candidate_name, candidate_email,
# send email to secretariat and nomcomchair to warn about the new person # send email to secretariat and nomcomchair to warn about the new person
subject = 'New person is created' subject = 'New person is created'
from_email = settings.NOMCOM_FROM_EMAIL from_email = settings.NOMCOM_FROM_EMAIL.format(year=nomcom.year())
(to_email, cc) = gather_address_lists('nomination_created_person',nomcom=nomcom) (to_email, cc) = gather_address_lists('nomination_created_person',nomcom=nomcom)
context = {'email': email.address, context = {'email': email.address,
'fullname': email.person.name, 'fullname': email.person.name,
'person_id': email.person.id} 'person_id': email.person.id,
'year': nomcom.year(),
}
nomcom_template_path = '/nomcom/%s/' % nomcom.group.acronym nomcom_template_path = '/nomcom/%s/' % nomcom.group.acronym
path = nomcom_template_path + INEXISTENT_PERSON_TEMPLATE path = nomcom_template_path + INEXISTENT_PERSON_TEMPLATE
send_mail(None, to_email, from_email, subject, path, context, cc=cc) send_mail(None, to_email, from_email, subject, path, context, cc=cc)

View file

@ -654,7 +654,7 @@ RFC_EDITOR_ERRATA_URL = "https://www.rfc-editor.org/errata_search.php?rfc={rfc_n
# NomCom Tool settings # NomCom Tool settings
ROLODEX_URL = "" ROLODEX_URL = ""
NOMCOM_PUBLIC_KEYS_DIR = '/a/www/nomcom/public_keys/' NOMCOM_PUBLIC_KEYS_DIR = '/a/www/nomcom/public_keys/'
NOMCOM_FROM_EMAIL = 'nomcom-chair@ietf.org' NOMCOM_FROM_EMAIL = 'nomcom-chair-{year}@ietf.org'
OPENSSL_COMMAND = '/usr/bin/openssl' OPENSSL_COMMAND = '/usr/bin/openssl'
DAYS_TO_EXPIRE_NOMINATION_LINK = '' DAYS_TO_EXPIRE_NOMINATION_LINK = ''
NOMINEE_FEEDBACK_TYPES = ['comment', 'questio', 'nomina'] NOMINEE_FEEDBACK_TYPES = ['comment', 'questio', 'nomina']