def send_match_email(netid1, netid2): print("Match emailing code running") # construct the email message body with open("match_template.txt", 'r', encoding='utf-8') as template_file: template_file_content = template_file.read() template = Template(template_file_content) message = template.substitute(PERSON1_NAME=getName(netid1).split(",")[0], PERSON2_NAME=getName(netid2).split(",")[0]) # send the email msg = Message(subject="TigerCrush: And That's a Match!", sender=os.environ.get('MAIL_DEFAULT_SENDER'), recipients=[netid1 + "@princeton.edu", netid2 + "@princeton.edu"], body=message) send_async_mail(msg) print("Email sent! A new match is made <3")
def crushes(): # validate the current user session netid, err = check_user(session) if err: return redirect(url_for('login', err=netid)) url_netid = request.args.get('netid') if netid != url_netid: return {'data': []} crushList = getCrushes(netid) return {'data': [getName(crush.crushed_on) for crush in crushList]}
def index(): # validate the current user session netid, err = check_user(session) if err: return redirect(url_for('login'), err="CAS authentication failed.") if not isUser(netid): return redirect( url_for( 'login', err="Sorry! Looks like you are not an undergraduate student. " + "This app is currently only available to undergraduates. " + "If enough graduate students are interested in using this " + "app, we will look into implementing that functionality " + "at a later point!")) err = request.args.get('err') if err is None: err = "" firstTime = isFirstTime(netid) remCrushes = getRemCrushes(netid) numSecretAdmirers = getSecretAdmirers(netid) matched = len(getMatches(netid)) > 0 name = getName(netid).split() if name == '(unregistered user)': name = netid else: name = name[0] if firstTime: # we display a banner about ProofPoint blocking our emails and # send a welcome email accordingly removeFirstTime(netid) send_welcome_email(netid) html = render_template("index.html", netid=netid, name=name, remCrushes=remCrushes, firstTime=firstTime, numSecretAdmirers=numSecretAdmirers, matched=matched, err=err) return make_response(html)
def matches(): # validate the current user session netid, err = check_user(session) if err: return redirect(url_for('login', err=netid)) url_netid = request.args.get('netid') if netid != url_netid: return {'data': []} matchList = getMatches(netid) return { 'data': [ '%s (%[email protected])' % (getName(match), match) for match in matchList ] }
def send_welcome_email(netid): print("First login email code running") # construct the email message body with open("first_email.txt", 'r', encoding='utf-8') as template_file: template_file_content = template_file.read() template = Template(template_file_content) message = template.substitute(PERSON=getName(netid).split(",")[0]) # send the email msg = Message(subject="TigerCrush: Welcome!", sender=os.environ.get('MAIL_DEFAULT_SENDER'), recipients=[netid + "@princeton.edu"], body=message) send_async_mail(msg) print("Email sent! New user welcomed!")