|
12 | 12 | from django.utils import simplejson |
13 | 13 | from django.db.models import Count, Q |
14 | 14 | from django.forms.models import modelformset_factory, inlineformset_factory |
| 15 | +from django.contrib.sites.models import Site |
15 | 16 |
|
16 | | -from ietf.utils.mail import send_mail |
| 17 | +from ietf.utils.mail import send_mail_text |
17 | 18 |
|
18 | 19 | from ietf.dbtemplate.models import DBTemplate |
19 | 20 | from ietf.dbtemplate.views import template_edit |
|
25 | 26 | PrivateKeyForm, EditNomcomForm, PendingFeedbackForm, |
26 | 27 | ReminderDatesForm) |
27 | 28 | from ietf.nomcom.models import Position, NomineePosition, Nominee, Feedback, NomCom, ReminderDates |
28 | | -from ietf.nomcom.utils import (get_nomcom_by_year, HOME_TEMPLATE, |
| 29 | +from ietf.nomcom.utils import (get_nomcom_by_year, get_year_by_nomcom, HOME_TEMPLATE, |
29 | 30 | store_nomcom_private_key, get_hash_nominee_position, |
30 | | - NOMINEE_REMINDER_TEMPLATE) |
| 31 | + NOMINEE_REMINDER_TEMPLATE, QUESTIONNAIRE_TEMPLATE) |
31 | 32 |
|
32 | 33 |
|
33 | 34 | def index(request, year): |
@@ -149,11 +150,37 @@ def send_reminder_mail(request, year): |
149 | 150 | if selected_nominees: |
150 | 151 | subject = 'IETF Nomination Information' |
151 | 152 | from_email = settings.NOMCOM_FROM_EMAIL |
| 153 | + domain = Site.objects.get_current().domain |
| 154 | + today = datetime.date.today().strftime('%Y%m%d') |
152 | 155 | for nominee in nominees: |
153 | 156 | to_email = nominee.email.address |
154 | | - positions = ', '.join([nominee_position.position.name for nominee_position in nominee.nomineeposition_set.pending()]) |
155 | | - context = {'positions': positions} |
156 | | - send_mail(None, to_email, from_email, subject, mail_path, context) |
| 157 | + for nominee_position in nominee.nomineeposition_set.pending(): |
| 158 | + hash = get_hash_nominee_position(today, nominee_position.id) |
| 159 | + accept_url = reverse('nomcom_process_nomination_status', |
| 160 | + None, |
| 161 | + args=(get_year_by_nomcom(nomcom), |
| 162 | + nominee_position.id, |
| 163 | + 'accepted', |
| 164 | + today, |
| 165 | + hash)) |
| 166 | + decline_url = reverse('nomcom_process_nomination_status', |
| 167 | + None, |
| 168 | + args=(get_year_by_nomcom(nomcom), |
| 169 | + nominee_position.id, |
| 170 | + 'declined', |
| 171 | + today, |
| 172 | + hash)) |
| 173 | + |
| 174 | + context = {'nominee': nominee, |
| 175 | + 'position': nominee_position.position, |
| 176 | + 'domain': domain, |
| 177 | + 'accept_url': accept_url, |
| 178 | + 'decline_url': decline_url} |
| 179 | + body = render_to_string(mail_path, context) |
| 180 | + path = '%s%d/%s' % (nomcom_template_path, nominee_position.position.id, QUESTIONNAIRE_TEMPLATE) |
| 181 | + body += '\n\n%s' % render_to_string(path, context) |
| 182 | + send_mail_text(None, to_email, from_email, subject, body) |
| 183 | + |
157 | 184 | message = ('success', 'An query has been sent to each person, asking them to accept (or decline) the nominations') |
158 | 185 | else: |
159 | 186 | message = ('warning', "Please, select some nominee") |
|
0 commit comments