Skip to content
This repository has been archived by the owner. It is now read-only.
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
110 lines (97 sloc) 5.32 KB
import threading
from collections import Counter
from django.contrib.sites.models import Site
from django.core.mail import EmailMessage
from django.conf import settings
from django.utils import timezone
class BasePostmarkSessionEmailThread(threading.Thread):
def __init__(self, session, **kwargs):
super(BasePostmarkSessionEmailThread, self).__init__(**kwargs)
self.session = session
self.sender = settings.POSTMARK_SENDER
self.recipients = [session.speakers[0]['email']]
def should_send(self):
# feel free to spam admins whenever, but nobody else.
admins = Counter(dict(settings.ADMINS).values())
recipients = Counter(self.recipients)
return not (settings.DEBUG is True and len(list(recipients - admins)) is not 0)
def run(self):
headers = {}
headers = self.headers
except AttributeError:
if self.should_send:
EmailMessage(self.subject, self.body, self.sender, self.recipients, headers=headers).send()
class SessionConversionEmailThread(BasePostmarkSessionEmailThread):
def __init__(self, session, **kwargs):
super(SessionConversionEmailThread, self).__init__(session, **kwargs)
self.headers = {'Reply-To': '', }
self.subject = '[TCamp] Your Idea was Selected!'
self.body = ("Congratulations! We'd like to include your session "
"proposal as part of TransparencyCamp. "
"If for any reason you can't "
"be in attendence to give your talk, please let us know by emailing "
" (or replying to this email)."
"You'll receive another email once your time slot and room have been "
"In the meantime, if you need to edit your proposal at all, "
"you can use this link: "
"Looking forward to seeing you at TCamp!"
"The Transparencycamp Team"
class SessionConfirmationEmailThread(BasePostmarkSessionEmailThread):
def __init__(self, session, **kwargs):
super(SessionConfirmationEmailThread, self).__init__(session, **kwargs)
self.subject = '[TCamp] Submit confirmation & edit link'
self.body = ("Thanks for submitting a session at TCamp! We'll "
"be reviewing all of the proposals as they come in, "
"and you'll get "
"another email with the pertinent details if your "
"session is chosen. In the meantime, if you need to "
"edit anything, visit this URL: "
class SessionApprovedEmailThread(BasePostmarkSessionEmailThread):
def __init__(self, session, **kwargs):
super(SessionApprovedEmailThread, self).__init__(session, **kwargs)
details = dict(start_time=self.session.start_time.astimezone(
).strftime('%I:%M %p'),
).strftime('%a %D'),,
self.subject = '[TCamp] {start_date}, {start_time} @ {location} -- Your Session is scheduled!'.format(**details)
self.body = ("Your session has been approved and scheduled for:"
"{start_date}, {start_time} in {location}."
"Please see the registration desk 10 minutes before "
"your scheduled time slot if you need an "
"adapter to connect your laptop to a VGA projector, "
"or ask the wall crew if you have logistical or timing "
"Your session's permalink page (http://{site}{schedule_url}) has an "
"etherpad on it for collaborative notetaking. To help keep "
"a good record of the discussion that goes on during your talk, "
"you may want to mention to the group that it's available."
"Also, note that since it's published, your proposal can no longer be "
"edited. Please see the wall crew with logistical or timing "
"questions. ").format(**details)
You can’t perform that action at this time.