Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions config.env.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,12 @@
LDAP_BIND_DN = environ.get("PACKET_LDAP_BIND_DN", None)
LDAP_BIND_PASS = environ.get("PACKET_LDAP_BIND_PASS", None)

# Mail Config
MAIL_PROD = environ.get("PACKET_MAIL_PROD", False)
MAIL_SERVER = environ.get("PACKET_MAIL_SERVER", "thoth.csh.rit.edu")
MAIL_USERNAME = environ.get("PACKET_MAIL_USERNAME", "[email protected]")
MAIL_PASSWORD = environ.get("PACKET_MAIL_PASSWORD", None)
MAIL_USE_TLS = environ.get("PACKET_MAIL_TLS", True)

# Slack URL for pushing to #general
SLACK_WEBHOOK_URL = environ.get("PACKET_SLACK_URL", None)
4 changes: 3 additions & 1 deletion packet/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import csv
import click

from packet.mail import send_mail
from . import app, db
from .models import Freshman, Packet, FreshSignature, UpperSignature, MiscSignature
from .ldap import ldap_get_eboard_role, ldap_get_active_rtps, ldap_get_3das, ldap_get_webmasters, \
Expand Down Expand Up @@ -126,10 +127,11 @@ def create_packets(freshmen_csv):

# Create the new packets and the signatures for each freshman in the given CSV
freshmen_in_csv = parse_csv(freshmen_csv)
print("Creating DB entries...")
print("Creating DB entries and sending emails...")
for freshman in Freshman.query.filter(Freshman.rit_username.in_(freshmen_in_csv)).all():
packet = Packet(freshman=freshman, start=start, end=end)
db.session.add(packet)
send_mail(packet)

for member in all_upper:
sig = UpperSignature(packet=packet, member=member.uid)
Expand Down
19 changes: 19 additions & 0 deletions packet/mail.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from flask import render_template
from flask_mail import Mail, Message

from packet import app

mail = Mail(app)


def send_mail(packet):
if app.config['MAIL_PROD']:
recipients = ["<" + packet.freshman.rit_username + "@rit.edu>"]
msg = Message(subject="CSH Packet Starts " + packet.start.strftime('%A, %B %-d'),
sender=app.config.get("MAIL_USERNAME"),
recipients=recipients)

template = 'mail/packet_start'
msg.body = render_template(template + '.txt', packet=packet)
msg.html = render_template(template + '.html', packet=packet)
mail.send(msg)
18 changes: 18 additions & 0 deletions packet/templates/extend/email.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">

{% block head %}
<head>
<title>CSH Packet</title>
<link rel="stylesheet"
href="https://assets.csh.rit.edu/csh-material-bootstrap/4.3.1/dist/csh-material-bootstrap.min.css"
media="screen">
</head>
{% endblock %}

<body>
{% block body %}
{% endblock %}

</body>
</html>
15 changes: 15 additions & 0 deletions packet/templates/mail/packet_start.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% extends "extend/email.html" %}

{% block body %}
<div class="container main">
<h2>Hello {{ packet.freshman.name }},</h2>
<h3>Welcome to Computer Science House!</h3>
<p>Soon you'll starting the introductory process for CSH, and the first part of that is Packet.</p>
<p>Your packet will start on <span class="badge">{{ packet.start.strftime('%A, %B %-d') }} at {{ packet.start.strftime('%-I:%M %p') }}</span></p>
<p>You can view your packet at <a href="https://freshen-packet.csh.rit.edu">freshmen-packet.csh.rit.edu</a> with
the credentials you should have been sent.</p>
<p>If you don't know your credentials, reach out to an <a href="mailto:[email protected]">RTP</a></p>
<p>If you have any questions about Packet or the introductory process, email <a href="mailto:[email protected]">[email protected]</a></p>
<p>If you have any questions about login credentials or any technical issues, email <a href="mailto:[email protected]">[email protected]</a></p>
</div>
{% endblock %}
14 changes: 14 additions & 0 deletions packet/templates/mail/packet_start.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Hello {{ packet.freshman.name }},

Welcome to Computer Science House!

Soon you'll starting the introductory process for CSH, and the first part of that is Packet.

Your packet will start on {{ packet.start.strftime('%A, %B %-d') }} at {{ packet.start.strftime('%-I:%M %p') }}

You can view your packet at freshmen-packet.csh.rit.edu with the credentials you should have been sent.
If you don't know your credentials, reach out to an RTP

If you have any questions about Packet or the introductory process, email [email protected]

If you have any questions about login credentials or any technical issues, email [email protected]
13 changes: 7 additions & 6 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
Flask~=1.1.0
Flask-pyoidc~=2.2.0
flask_sqlalchemy==2.3.2
psycopg2-binary==2.8.3
Flask-Migrate==2.2.1
pylint==2.3.1
gunicorn==19.7.1
csh_ldap>=2.1.0
Flask-Mail~=0.9.1
flask_sqlalchemy~=2.3.2
psycopg2-binary~=2.8.3
Flask-Migrate~=2.2.1
pylint~=2.3.1
gunicorn~=19.7.1
csh_ldap~=2.1.0