Send overdue emails
This commit is contained in:
parent
ef6cefe9aa
commit
67276a7e49
26
apiserver/apiserver/api/emails/overdue.html
Normal file
26
apiserver/apiserver/api/emails/overdue.html
Normal file
|
@ -0,0 +1,26 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
<style type="text/css">p.MsoNormal,p.MsoNoSpacing{margin:0}</style>
|
||||
</head>
|
||||
<body>
|
||||
<div>Hi [name],<br></div>
|
||||
<div><br></div>
|
||||
<div>Your Protospace member dues are behind by two months and you are now "overdue".<br></div>
|
||||
<div><br></div>
|
||||
<div>You are paid up until [date]. Please pay your dues to prevent having your card and account deactivated by the system.<br></div>
|
||||
<div><br></div>
|
||||
<div>You can log into the portal and pay here:<br></div>
|
||||
<div><a href="https://my.protospace.ca/paymaster">https://my.protospace.ca/paymaster</a><br></div>
|
||||
<div><br></div>
|
||||
<div>Or send e-Transfer to info@protospace.ca or hand a director cash.<br></div>
|
||||
<div><br></div>
|
||||
<div>If there has been an error or you want to reply to this email, please click "reply-all" since the Spaceport inbox does not exist.<br></div>
|
||||
<div><br></div>
|
||||
<div>You won't recieve any other emails about this.<br></div>
|
||||
<div><br></div>
|
||||
<div>Thanks,</div>
|
||||
<div>Spaceport<br></div>
|
||||
</body>
|
||||
</html>
|
19
apiserver/apiserver/api/emails/overdue.txt
Normal file
19
apiserver/apiserver/api/emails/overdue.txt
Normal file
|
@ -0,0 +1,19 @@
|
|||
Hi [name],
|
||||
|
||||
Your Protospace member dues are behind by two months and you are now "overdue".
|
||||
|
||||
You are paid up until [date]. Please pay your dues to prevent having your
|
||||
account and card deactivated by the system.
|
||||
|
||||
You can log into the portal and pay here:
|
||||
https://my.protospace.ca/paymaster
|
||||
|
||||
Or send e-Transfer to info@protospace.ca or hand a director cash.
|
||||
|
||||
If there has been an error or you want to reply to this email, please click
|
||||
"reply-all" since the Spaceport inbox does not exist.
|
||||
|
||||
You won't recieve any other emails about this.
|
||||
|
||||
Thanks,
|
||||
Spaceport
|
|
@ -115,11 +115,16 @@ def tally_membership_months(member, fake_date=None):
|
|||
alert_tanner(msg)
|
||||
logger.info(msg)
|
||||
|
||||
if status == 'Overdue' and previous_status == 'Due':
|
||||
if status == 'Overdue':
|
||||
if previous_status == 'Due':
|
||||
msg = 'Member has become Overdue: {} {}'.format(member.preferred_name, member.last_name)
|
||||
alert_tanner(msg)
|
||||
logger.info(msg)
|
||||
|
||||
utils_email.send_overdue_email(member)
|
||||
else:
|
||||
logger.info('Skipping email because member wasn\'t due before.')
|
||||
|
||||
member.save()
|
||||
logging.debug('Tallied %s membership months: updated.', member)
|
||||
else:
|
||||
|
|
|
@ -121,10 +121,34 @@ def send_usage_bill_email(user, device, month, minutes, overage, bill):
|
|||
subject='{} {} Usage Bill'.format(month, device),
|
||||
message=email_text,
|
||||
from_email=None, # defaults to DEFAULT_FROM_EMAIL
|
||||
recipient_list=[user.email, 'directors@protospace.ca', 'protospace@tannercollin.com'],
|
||||
recipient_list=[user.email, 'directors@protospace.ca', 'spaceport@tannercollin.com'],
|
||||
)
|
||||
|
||||
if not settings.EMAIL_HOST:
|
||||
time.sleep(0.5) # simulate slowly sending emails when logging to console
|
||||
|
||||
logger.info('Sent usage bill email:\n' + email_text)
|
||||
|
||||
def send_overdue_email(member):
|
||||
def replace_fields(text):
|
||||
return text.replace(
|
||||
'[name]', member.preferred_name,
|
||||
).replace(
|
||||
'[date]', member.expire_date.strftime('%B %d, %Y'),
|
||||
)
|
||||
|
||||
with open(EMAIL_DIR + 'overdue.txt', 'r') as f:
|
||||
email_text = replace_fields(f.read())
|
||||
|
||||
with open(EMAIL_DIR + 'overdue.html', 'r') as f:
|
||||
email_html = replace_fields(f.read())
|
||||
|
||||
send_mail(
|
||||
subject='Protospace member dues overdue',
|
||||
message=email_text,
|
||||
from_email=None, # defaults to DEFAULT_FROM_EMAIL
|
||||
recipient_list=[member.user.email, 'directors@protospace.ca', 'spaceport@tannercollin.com'],
|
||||
html_message=email_html,
|
||||
)
|
||||
|
||||
logger.info('Sent overdue email:\n' + email_text)
|
||||
|
|
Loading…
Reference in New Issue
Block a user