enable email to submitter and speakers when an event is scheduled

This commit is contained in:
Thomas Steen Rasmussen 2021-08-07 15:31:11 +02:00
parent d5fa4b98d5
commit 5162a54a2d
6 changed files with 23 additions and 11 deletions

View file

@ -12,6 +12,7 @@ from django.views.generic.edit import CreateView, DeleteView, FormView, UpdateVi
from camps.mixins import CampViewMixin from camps.mixins import CampViewMixin
from program.autoscheduler import AutoScheduler from program.autoscheduler import AutoScheduler
from program.email import add_event_scheduled_email
from program.mixins import AvailabilityMatrixViewMixin from program.mixins import AvailabilityMatrixViewMixin
from program.models import ( from program.models import (
Event, Event,
@ -537,6 +538,7 @@ class EventScheduleView(CampViewMixin, ContentTeamPermissionMixin, FormView):
self.request, self.request,
f"{self.event.title} has been scheduled to begin at {slot.when.lower} at location {slot.event_location.name} successfully!", f"{self.event.title} has been scheduled to begin at {slot.when.lower} at location {slot.event_location.name} successfully!",
) )
add_event_scheduled_email(slot)
return redirect( return redirect(
reverse( reverse(
"backoffice:event_detail", "backoffice:event_detail",

View file

@ -6,6 +6,8 @@ from conference_scheduler.lp_problem import objective_functions
from conference_scheduler.validator import is_valid_schedule, schedule_violations from conference_scheduler.validator import is_valid_schedule, schedule_violations
from psycopg2.extras import DateTimeTZRange from psycopg2.extras import DateTimeTZRange
from program.email import add_event_scheduled_email
from .models import EventType from .models import EventType
logger = logging.getLogger("bornhack.%s" % __name__) logger = logging.getLogger("bornhack.%s" % __name__)
@ -281,7 +283,7 @@ class AutoScheduler:
# "The Clean Slate protocol sir?" - delete any existing autoscheduled Events # "The Clean Slate protocol sir?" - delete any existing autoscheduled Events
# TODO: investigate how this affects the FRAB XML export (for which we added a UUID on # TODO: investigate how this affects the FRAB XML export (for which we added a UUID on
# EventInstance objects). Make sure "favourite" functionality or bookmarks or w/e in # Slot objects). Make sure "favourite" functionality or bookmarks or w/e in
# FRAB clients still work after a schedule "re"apply. We might need a smaller hammer here. # FRAB clients still work after a schedule "re"apply. We might need a smaller hammer here.
deleted = self.camp.event_slots.filter( deleted = self.camp.event_slots.filter(
# get all autoscheduled EventSlots # get all autoscheduled EventSlots
@ -309,6 +311,7 @@ class AutoScheduler:
slot.event = event slot.event = event
slot.autoscheduled = True slot.autoscheduled = True
slot.save() slot.save()
add_event_scheduled_email(slot)
scheduled += 1 scheduled += 1

View file

@ -168,25 +168,27 @@ def add_event_proposal_accepted_email(event_proposal):
) )
def add_event_scheduled_email(eventinstance, action): def add_event_scheduled_email(slot):
formatdict = {"eventinstance": eventinstance, "action": action} formatdict = {"slot": slot}
recipients = [speaker.email for speaker in eventinstance.event.speakers.all()] # add all speaker emails
recipients.append(eventinstance.event.proposal.user.email) recipients = [speaker.email for speaker in slot.event.speakers.all()]
# also add the submitting users email
recipients.append(slot.event.proposal.user.email)
try: try:
content_team = Team.objects.get(camp=eventinstance.camp, name="Content") content_team = Team.objects.get(camp=slot.camp, name="Content")
except ObjectDoesNotExist as e: except ObjectDoesNotExist as e:
logger.info("There is no team with name Content: {}".format(e)) logger.info("There is no team with name Content: {}".format(e))
return False return False
# loop over unique recipients and send an email to each # loop over unique recipients and send an email to each
for rcpt in set(recipients): for rcpt in set(recipients):
return add_outgoing_email( add_outgoing_email(
responsible_team=content_team, responsible_team=content_team,
text_template="emails/event_scheduled.txt", text_template="emails/event_scheduled.txt",
html_template="emails/event_scheduled.html", html_template="emails/event_scheduled.html",
to_recipients=rcpt, to_recipients=rcpt,
formatdict=formatdict, formatdict=formatdict,
subject=f"Your {eventinstance.camp.title} event '{eventinstance.event.title}' has been {action}!", subject=f"Your {slot.camp.title} event '{slot.event.title}' has been scheduled!",
hold=True, hold=True,
) )

View file

@ -1,6 +1,6 @@
Hello,<br> Hello,<br>
<br> <br>
The {{ eventinstance.camp.title }} event "{{ eventinstance.event.title }}" has been {{ action }} to begin {{ eventinstance.when.lower }} and end at {{ eventinstance.when.upper }}.<br> The {{ slot.camp.title }} event "{{ slot.event.title }}" has been scheduled to begin {{ slot.when.lower }} and end at {{ slot.when.upper }}.<br>
<br> <br>
Let us know in case this time slot doesn't work for you.<br> Let us know in case this time slot doesn't work for you.<br>
<br> <br>

View file

@ -1,6 +1,6 @@
Hello, Hello,
The {{ eventinstance.camp.title }} event "{{ eventinstance.event.title }}" has been {% if rescheduled %}re{% endif %}scheduled to begin {{ eventinstance.when.lower }} and end at {{ eventinstance.when.upper }}. The {{ slot.camp.title }} event "{{ slot.event.title }}" has been scheduled to begin {{ slot.when.lower }} and end at {{ slot.when.upper }}.
Let us know in case this time slot doesn't work for you. Let us know in case this time slot doesn't work for you.

View file

@ -226,7 +226,12 @@ class Command(BaseCommand):
dict(year=2018, tagline="scale it", colour="#008026", read_only=True), dict(year=2018, tagline="scale it", colour="#008026", read_only=True),
dict(year=2019, tagline="a new /home", colour="#ffed00", read_only=True), dict(year=2019, tagline="a new /home", colour="#ffed00", read_only=True),
dict(year=2020, tagline="Make Clean", colour="#ff8c00", read_only=False), dict(year=2020, tagline="Make Clean", colour="#ff8c00", read_only=False),
dict(year=2021, tagline="Undecided", colour="#e40303", read_only=False), dict(
year=2021,
tagline="Continuous Delivery",
colour="#e40303",
read_only=False,
),
dict(year=2022, tagline="Undecided", colour="#004dff", read_only=False), dict(year=2022, tagline="Undecided", colour="#004dff", read_only=False),
] ]