def poll_email_reminder(sender, instance, raw, **kwargs): """Send email reminders when a vote starts/ends.""" subject_start = '[Voting] Cast your vote for "%s" now!' % instance.name subject_end = '[Voting] Results for "%s"' % instance.name start_template = 'emails/voting_starting_reminder.jinja' end_template = 'emails/voting_results_reminder.jinja' if not instance.task_start_id or instance.is_future_voting: start_reminder = send_voting_mail.apply_async(eta=instance.start, kwargs={ 'voting_id': instance.id, 'subject': subject_start, 'email_template': start_template }) Poll.objects.filter(pk=instance.pk).update( task_start_id=start_reminder.task_id) if not instance.is_past_voting: end_reminder = send_voting_mail.apply_async(eta=instance.end, kwargs={ 'voting_id': instance.id, 'subject': subject_end, 'email_template': end_template }) Poll.objects.filter(pk=instance.pk).update( task_end_id=end_reminder.task_id)
def poll_email_reminder(sender, instance, raw, **kwargs): """Send email reminders when a vote starts/ends.""" subject_start = '[Voting] Cast your vote for "%s" now!' % instance.name subject_end = '[Voting] Results for "%s"' % instance.name start_template = 'emails/voting_starting_reminder.jinja' end_template = 'emails/voting_results_reminder.jinja' if not instance.task_start_id or instance.is_future_voting: start_reminder = send_voting_mail.apply_async( eta=instance.start, kwargs={'voting_id': instance.id, 'subject': subject_start, 'email_template': start_template}) Poll.objects.filter(pk=instance.pk).update(task_start_id=start_reminder.task_id) if not instance.is_past_voting: end_reminder = send_voting_mail.apply_async( eta=instance.end, kwargs={'voting_id': instance.id, 'subject': subject_end, 'email_template': end_template}) Poll.objects.filter(pk=instance.pk).update(task_end_id=end_reminder.task_id)