-
Notifications
You must be signed in to change notification settings - Fork 34
Send email when marked absent from house meeting #285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 1 commit
c7475bd
8d5cd97
dc28471
a2ddf28
422372a
ae3b3c5
838a967
9496804
b511d05
d465127
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import smtplib | ||
| from email.mime.text import MIMEText | ||
| from email.utils import formatdate | ||
| from email.mime.multipart import MIMEMultipart | ||
| from datetime import date | ||
| from conditional import app | ||
|
Comment on lines
+1
to
+6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please organise these like in the rest of conditional:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is already the case There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Separate with a line break please |
||
|
|
||
| def send_absent_hm_attendance_emails(absent_members): | ||
| today_date = date.today().strftime("%m/%d") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an ambiguous date format. Why not do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was done to be consistent with the emails sent out by quotefault. And at least in the subject line conciseness is better imo. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Quotefault does not include a date in emails. Please don't be terse in the body, at least. |
||
| subject = "You were marked as absent for the {} House Meeting.".format(today_date) | ||
| body = subject + "\n\nIf this is a mistake please message the evaluations director and let them know." | ||
| # doing this uses the same connection for all emails sent to absent members | ||
| send_email(absent_members, subject, body) | ||
|
|
||
| def send_present_hm_attendance_email(member): | ||
| today_date = date.today().strftime("%m/%d") | ||
Lontronix marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| subject = "You were marked as present for the {} House Meeting.".format(today_date) | ||
| body = subject | ||
| # doing this uses the same connection for all emails sent to absent members | ||
Lontronix marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| send_email([member], subject, body) | ||
|
|
||
| def send_attenance_requirement_met_email(user): | ||
Lontronix marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| subject = "You have attended 30 Directorship Meetings" | ||
Lontronix marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # pylint: disable=line-too-long | ||
| body = "You have met one of the requirements of active membership by attending 30 directorship meetings. Congratulations or I'm Sorry!" | ||
Lontronix marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| send_email([user], subject, body) | ||
|
|
||
| def send_email(members, subject, body): | ||
| """A function capable of sending one or many emails""" | ||
| debug_email = app.config['DEBUG_EMAIL'] | ||
| should_send_email = app.config['SEND_EMAIL'] | ||
|
|
||
| if should_send_email: | ||
Lontronix marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| recipents = map("{}@csh.rit.edu".format, members) | ||
| server = smtplib.SMTP(app.config['MAIL_SERVER']) | ||
Lontronix marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| server.starttls() | ||
| server.login('conditional', app.config['EMAIL_PASSWORD']) | ||
| sender_addr = "[email protected]" | ||
| for member in recipents: | ||
| msg = MIMEMultipart() | ||
| if debug_email is not None: | ||
Lontronix marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| recipient_addr = debug_email | ||
| else: | ||
| recipient_addr = "{}@csh.rit.edu".format(member) | ||
| msg["To"] = recipient_addr | ||
| msg["From"] = sender_addr | ||
| msg["Subject"] = subject | ||
| msg["Date"] = formatdate(localtime=True) | ||
| msg.attach(MIMEText(body, 'plain')) | ||
| server.sendmail(sender_addr, recipient_addr, msg.as_string()) | ||
| server.quit() | ||
Uh oh!
There was an error while loading. Please reload this page.