2020-02-12 12:10:41 +00:00
|
|
|
import logging
|
|
|
|
|
2017-07-11 20:02:19 +00:00
|
|
|
from django.core.exceptions import ObjectDoesNotExist
|
|
|
|
|
|
|
|
from teams.models import Team
|
2020-02-12 12:10:41 +00:00
|
|
|
from utils.email import add_outgoing_email
|
2019-06-16 12:32:24 +00:00
|
|
|
|
2017-07-11 20:02:19 +00:00
|
|
|
logger = logging.getLogger("bornhack.%s" % __name__)
|
|
|
|
|
|
|
|
|
|
|
|
def add_new_speakerproposal_email(speakerproposal):
|
2019-06-16 12:32:24 +00:00
|
|
|
formatdict = {"proposal": speakerproposal}
|
2017-07-11 20:02:19 +00:00
|
|
|
|
|
|
|
try:
|
2019-06-16 12:32:24 +00:00
|
|
|
content_team = Team.objects.get(camp=speakerproposal.camp, name="Content")
|
2017-07-11 20:02:19 +00:00
|
|
|
except ObjectDoesNotExist as e:
|
2019-06-16 12:32:24 +00:00
|
|
|
logger.info("There is no team with name Content: {}".format(e))
|
2017-07-11 20:02:19 +00:00
|
|
|
return False
|
|
|
|
|
2019-07-21 13:26:57 +00:00
|
|
|
return add_outgoing_email(
|
|
|
|
text_template="emails/new_speakerproposal.txt",
|
|
|
|
html_template="emails/new_speakerproposal.html",
|
|
|
|
to_recipients=content_team.mailing_list,
|
|
|
|
formatdict=formatdict,
|
|
|
|
subject="New speaker proposal '%s' was just submitted" % speakerproposal.name,
|
|
|
|
)
|
2017-07-11 20:02:19 +00:00
|
|
|
|
2020-02-07 17:46:34 +00:00
|
|
|
|
2017-07-11 20:02:19 +00:00
|
|
|
def add_new_eventproposal_email(eventproposal):
|
2019-06-16 12:32:24 +00:00
|
|
|
formatdict = {"proposal": eventproposal}
|
2017-07-11 20:02:19 +00:00
|
|
|
|
|
|
|
try:
|
2019-06-16 12:32:24 +00:00
|
|
|
content_team = Team.objects.get(camp=eventproposal.camp, name="Content")
|
2017-07-11 20:02:19 +00:00
|
|
|
except ObjectDoesNotExist as e:
|
2019-06-16 12:32:24 +00:00
|
|
|
logger.info("There is no team with name Content: {}".format(e))
|
2017-07-11 20:02:19 +00:00
|
|
|
return False
|
|
|
|
|
2019-07-21 13:26:57 +00:00
|
|
|
return add_outgoing_email(
|
|
|
|
text_template="emails/new_eventproposal.txt",
|
|
|
|
html_template="emails/new_eventproposal.html",
|
|
|
|
to_recipients=content_team.mailing_list,
|
|
|
|
formatdict=formatdict,
|
|
|
|
subject="New event proposal '%s' was just submitted" % eventproposal.title,
|
|
|
|
)
|
2017-07-11 20:02:19 +00:00
|
|
|
|
2020-02-07 17:46:34 +00:00
|
|
|
|
2017-07-11 20:02:19 +00:00
|
|
|
def add_speakerproposal_updated_email(speakerproposal):
|
2019-06-16 12:32:24 +00:00
|
|
|
formatdict = {"proposal": speakerproposal}
|
2017-07-11 20:02:19 +00:00
|
|
|
|
|
|
|
try:
|
2019-06-16 12:32:24 +00:00
|
|
|
content_team = Team.objects.get(camp=speakerproposal.camp, name="Content")
|
2017-07-11 20:02:19 +00:00
|
|
|
except ObjectDoesNotExist as e:
|
2019-06-16 12:32:24 +00:00
|
|
|
logger.info("There is no team with name Content: {}".format(e))
|
2017-07-11 20:02:19 +00:00
|
|
|
return False
|
|
|
|
|
2019-07-21 13:26:57 +00:00
|
|
|
return add_outgoing_email(
|
|
|
|
text_template="emails/update_speakerproposal.txt",
|
|
|
|
html_template="emails/update_speakerproposal.html",
|
|
|
|
to_recipients=content_team.mailing_list,
|
|
|
|
formatdict=formatdict,
|
|
|
|
subject="Speaker proposal '%s' was just updated" % speakerproposal.name,
|
|
|
|
)
|
2017-07-11 20:02:19 +00:00
|
|
|
|
2020-02-07 17:46:34 +00:00
|
|
|
|
2017-07-11 20:02:19 +00:00
|
|
|
def add_eventproposal_updated_email(eventproposal):
|
2019-06-16 12:32:24 +00:00
|
|
|
formatdict = {"proposal": eventproposal}
|
2017-07-11 20:02:19 +00:00
|
|
|
|
|
|
|
try:
|
2019-06-16 12:32:24 +00:00
|
|
|
content_team = Team.objects.get(camp=eventproposal.camp, name="Content")
|
2017-07-11 20:02:19 +00:00
|
|
|
except ObjectDoesNotExist as e:
|
2019-06-16 12:32:24 +00:00
|
|
|
logger.info("There is no team with name Content: {}".format(e))
|
2017-07-11 20:02:19 +00:00
|
|
|
return False
|
2019-07-21 13:26:57 +00:00
|
|
|
|
|
|
|
return add_outgoing_email(
|
|
|
|
text_template="emails/update_eventproposal.txt",
|
|
|
|
html_template="emails/update_eventproposal.html",
|
|
|
|
to_recipients=content_team.mailing_list,
|
|
|
|
formatdict=formatdict,
|
|
|
|
subject="Event proposal '%s' was just updated" % eventproposal.title,
|
|
|
|
)
|