Multiple changes to UI, Email Templates, Removed Pubnub, fix bugs.
Pubnub was used to log things, but didn't work. Fixed bugs: - Code wasn't asynchronous - xxl and xxs were not included as valid tshirt sizes - No error thrown when someone trys to send a resume that's too big
This commit is contained in:
parent
658e63c1c0
commit
0354da724d
7 changed files with 45 additions and 53 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
|||
resumes
|
||||
config_hackWPI.py
|
||||
config.py
|
||||
# Created by https://www.gitignore.io/api/web,vim,git,macos,linux,bower,grunt,python,pycharm,windows,eclipse,webstorm,intellij,jetbrains,virtualenv,visualstudio,visualstudiocode
|
||||
|
|
40
flask_app.py
40
flask_app.py
|
@ -13,9 +13,6 @@ from email.mime.text import MIMEText
|
|||
from dateutil.relativedelta import relativedelta
|
||||
from flask import Flask, render_template, redirect, url_for, request, session, jsonify
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
from mailchimp3 import MailChimp
|
||||
from pubnub.pnconfiguration import PNConfiguration
|
||||
from pubnub.pubnub import PubNub
|
||||
from werkzeug.utils import secure_filename
|
||||
|
||||
from config_hackWPI import api_keys, WAITLIST_LIMIT, HACKATHON_TIME, ALLOWED_EXTENSIONS
|
||||
|
@ -25,13 +22,8 @@ app.config.from_pyfile('config.py')
|
|||
|
||||
db = SQLAlchemy(app)
|
||||
|
||||
pnconfig = PNConfiguration()
|
||||
|
||||
pnconfig.publish_key = api_keys['pubnub']['pub']
|
||||
pnconfig.subscribe_key = api_keys['pubnub']['sub']
|
||||
pnconfig.ssl = True
|
||||
|
||||
pn = PubNub(pnconfig)
|
||||
|
||||
|
||||
class Hacker(db.Model):
|
||||
|
@ -54,6 +46,14 @@ class AutoPromoteKeys(db.Model):
|
|||
key = db.Column(db.String(4096))
|
||||
val = db.Column(db.String(4096))
|
||||
|
||||
@app.errorhandler(413)
|
||||
def filesize_too_big(erro):
|
||||
print("Someone tried to send something too big")
|
||||
return "That file was too big, please go back and try a smaller resume pdf"
|
||||
|
||||
@app.errorhandler(500)
|
||||
def server_error():
|
||||
print("There was a server error... If you're having trouble registering, please email hack@wpi.edu with your details and what you did to break our site :P")
|
||||
|
||||
@app.route('/')
|
||||
def root():
|
||||
|
@ -154,7 +154,7 @@ def register():
|
|||
print(session['mymlh']['first_name'] + " put on database successfully.")
|
||||
|
||||
# Send a welcome email
|
||||
msg = 'Hey ' + session['mymlh']['first_name'] + '\n\n'
|
||||
msg = 'Dear ' + session['mymlh']['first_name'] + '\n\n'
|
||||
msg += 'Thanks for applying to Hack@WPI!\n'
|
||||
if waitlist:
|
||||
msg += 'Sorry! We have hit our registration capacity. You have been placed on the waitlist.\n'
|
||||
|
@ -163,8 +163,6 @@ def register():
|
|||
msg += 'You are fully registered! We will send you more info closer to the hackathon.\n'
|
||||
send_email(session['mymlh']['email'], 'Hack@WPI - Thanks for applying', msg)
|
||||
|
||||
pn.publish().channel('hackWPI-admin').message({'action': 'new_user'}).sync()
|
||||
|
||||
# Finally, send them to their dashboard
|
||||
return redirect(url_for('dashboard'))
|
||||
|
||||
|
@ -266,9 +264,6 @@ def change_admin():
|
|||
db.session.query(Hacker).filter(Hacker.mlh_id == request.args.get('mlh_id')).update({'admin': False})
|
||||
db.session.commit()
|
||||
|
||||
pn.publish().channel('hackWPI-admin').message(
|
||||
{'status': 'success', 'action': 'change_admin:' + request.args.get('action'), 'more_info': '',
|
||||
'id': request.args.get('mlh_id')}).sync()
|
||||
|
||||
return jsonify({'status': 'success', 'action': 'change_admin:' + request.args.get('action'), 'more_info': '',
|
||||
'id': request.args.get('mlh_id')})
|
||||
|
@ -300,15 +295,11 @@ def check_in():
|
|||
mlh_info = get_mlh_user(request.args.get('mlh_id'))
|
||||
|
||||
# Send a welcome email...
|
||||
msg = 'Hey ' + mlh_info['first_name'] + ',\n\n'
|
||||
msg = 'Dear ' + mlh_info['first_name'] + ',\n\n'
|
||||
msg += 'Thanks for checking in!\n'
|
||||
msg += 'We will start shortly, please check your dashboard for updates!\n'
|
||||
send_email(mlh_info['email'], 'HackWPI - Thanks for checking in', msg)
|
||||
|
||||
pn.publish().channel('hackWPI-admin').message(
|
||||
{'status': 'success', 'action': 'check_in', 'more_info': '',
|
||||
'id': request.args.get('mlh_id')}).sync()
|
||||
|
||||
return jsonify(
|
||||
{'status': 'success', 'action': 'check_in', 'more_info': '', 'id': request.args.get('mlh_id')})
|
||||
|
||||
|
@ -355,11 +346,9 @@ def drop():
|
|||
|
||||
# Send a goodbye email...
|
||||
msg = 'Dear ' + mlh_info['first_name'] + ',\n\n'
|
||||
msg += 'Your application was dropped, sorry to see you go.\n'
|
||||
msg += 'Your application was dropped, sorry to see you go.\n If this was a mistake, you can re-register by going to hack.wpi.edu/register'
|
||||
send_email(mlh_info['email'], 'Hack@WPI - Application Dropped', msg)
|
||||
|
||||
pn.publish().channel('hackWPI-admin').message(
|
||||
{'status': 'success', 'action': 'drop', 'more_info': '', 'id': request.args.get('mlh_id')}).sync()
|
||||
|
||||
if is_self(request.args.get('mlh_id')):
|
||||
session.clear()
|
||||
|
@ -411,9 +400,6 @@ def promote_from_waitlist():
|
|||
msg += 'If you cannot make it, please remove yourself at hack.wpi.edu\dashboard.\n'
|
||||
send_email(mlh_info['email'], "Hack@WPI - You're off the Waitlist!", msg)
|
||||
|
||||
pn.publish().channel('hackWPI-admin').message(
|
||||
{'status': 'success', 'action': 'promote_from_waitlist', 'more_info': '',
|
||||
'id': request.args.get('mlh_id')}).sync()
|
||||
|
||||
print(mlh_info['first_name'] + "is off the waitlist!")
|
||||
|
||||
|
@ -463,7 +449,7 @@ def send_email(to, subject, body):
|
|||
print("Email sent to: " + to)
|
||||
body += '\nPlease let your friends know about the event as well!.\n'
|
||||
body += 'To update your status, you can go to hack.wpi.edu/dashboard\n'
|
||||
body += '\nThanks Again!\nThe HackWPI Team\nhttps://twitter.com/hackwpi?lang=en'
|
||||
body += '\nAll the best!\nThe HackWPI Team\nhttps://twitter.com/hackwpi?lang=en'
|
||||
|
||||
server = smtplib.SMTP('smtp.gmail.com', 587)
|
||||
server.starttls()
|
||||
|
@ -537,4 +523,4 @@ def allowed_file(filename):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(host='0.0.0.0', port=80)
|
||||
app.run(host='0.0.0.0', port=80, threaded=True)
|
||||
|
|
|
@ -50,5 +50,5 @@ msg += ' ' + str(errs) + '\n'
|
|||
|
||||
print(msg)
|
||||
|
||||
send_email('hack@wpi.edu', 'HackWPI - Daily Waitlist Report!', msg)
|
||||
#send_email('hack@wpi.edu', 'HackWPI - Daily Waitlist Report!', msg)
|
||||
send_email('bkayastha@wpi.edu', 'HackWPI - Daily Waitlist Report!', msg)
|
||||
|
|
|
@ -5,3 +5,5 @@ pubnub==4.0.6
|
|||
requests==2.13.0
|
||||
Werkzeug==0.11.15
|
||||
python_dateutil==2.6.0
|
||||
mysql-connector-python==8.0.5
|
||||
mysqlclient==1.3.12
|
||||
|
|
|
@ -12,11 +12,11 @@
|
|||
<h1>You are fully registered! We look forward to seeing you!</h1>
|
||||
{% endif %}
|
||||
<br>
|
||||
<h2>Here are your available actions... </h2>
|
||||
<a href="#" id="drop-link"><p>Drop Application :(</p></a>
|
||||
<a href="#" id="drop-link"><p class="sub-button btn waves-effect waves-light grey darken-1">Drop Application :(</p></a>
|
||||
{% if admin %}
|
||||
<a href="/admin"><p>Admin Dashboard</p></a>
|
||||
<a href="/admin"><p class="btn">Admin Dashboard</p></a>
|
||||
{% endif %}
|
||||
<br>
|
||||
Please sit tight, while we improve the UI of this page :P
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -19,5 +19,4 @@
|
|||
<img src="../static/img/hackwpi_longlogo.png" alt="hack@WPI" height="100%">
|
||||
</a>
|
||||
</div>
|
||||
<a id="mlh-trust-badge" style="display:block;max-width:100px;min-width:60px;position:fixed;right:50px;top:0;width:10%;z-index:10000" href="https://mlh.io/seasons/na-2018/events?utm_source=na-2018&utm_medium=TrustBadge&utm_campaign=na-2018&utm_content=black" target="_blank"><img src="https://s3.amazonaws.com/logged-assets/trust-badge/2018/black.svg" alt="Major League Hacking 2018 Hackathon Season" style="width:100%"></a>
|
||||
</nav>
|
||||
|
|
|
@ -11,10 +11,11 @@
|
|||
<a id="mlh-trust-badge" href="https://mlh.io/seasons/na-2017/events?utm_source=na-2017&utm_medium=TrustBadge&utm_campaign=na-2017&utm_content=black" target="_blank"><img src="https://s3.amazonaws.com/logged-assets/trust-badge/2017/black.svg" alt="Major League Hacking 2017 Hackathon Season" style="width:100%"></a>
|
||||
|
||||
<div class="container">
|
||||
<h1>Hi {{ name }}, thanks for logging in with MyMLH!</h1>
|
||||
<h2>We will be sending resumes to sponsoring companies. If you would like us to send your resume, please upload it here:</h2>
|
||||
<div class="section">
|
||||
<form method="post" action="/register" enctype="multipart/form-data">
|
||||
<h1>Hi {{ name }}, just a few more steps!</h1>
|
||||
<div class="section">
|
||||
<form method="post" action="/register" enctype="multipart/form-data">
|
||||
<div>
|
||||
<p><b>If you'd like, add your resume to send to sponsors... </b></p>
|
||||
<div class="file-field input-field">
|
||||
<div class="btn">
|
||||
<span>File</span>
|
||||
|
@ -24,23 +25,26 @@
|
|||
<input class="file-path validate" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<p>By registering & attending, you agree to the following policies:</p>
|
||||
<p>
|
||||
<a href="https://github.com/MLH/mlh-policies/blob/master/data-sharing.md">MLH's Data Sharing Notice</a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://mlh.io/privacy">MLH's Privacy Policy</a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://github.com/MLH/mlh-policies/blob/master/prize-terms-and-conditions/contest-terms.md">MLH's Contest Terms and Conditions</a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://static.mlh.io/docs/mlh-code-of-conduct.pdf">MLH's Code of Conduct</a>
|
||||
</p>
|
||||
<br>
|
||||
<input type="checkbox" id="checkboxid" required><label for="checkboxid">Do you agree with MLH Rules?</label><br>
|
||||
<input name="submit" class="btn btn-lg btn-primary btn-invert" type="submit" value="Submit"/>
|
||||
</form>
|
||||
</div>
|
||||
<p>By registering & attending, you agree to the following policies (We are no longer MLH afilliated, but we agree with their policies):</p>
|
||||
<p>
|
||||
<a href="https://github.com/MLH/mlh-policies/blob/master/data-sharing.md">MLH's Data Sharing Notice</a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://mlh.io/privacy">MLH's Privacy Policy</a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://github.com/MLH/mlh-policies/blob/master/prize-terms-and-conditions/contest-terms.md">MLH's
|
||||
Contest Terms and Conditions</a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://static.mlh.io/docs/mlh-code-of-conduct.pdf">MLH's Code of Conduct</a>
|
||||
</p>
|
||||
<br>
|
||||
<input type="checkbox" id="checkboxid" required><label for="checkboxid"><b style="color:black;">Do you agree with these MLH Rules?</b></label>
|
||||
<br><br>
|
||||
<input name="submit" class="btn btn-lg btn-primary btn-invert" type="submit" value="Submit"/>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Reference in a new issue