From 25e288355acc7b85544bb7de251a990a3ed191e3 Mon Sep 17 00:00:00 2001 From: ACM Date: Wed, 16 Dec 2020 23:27:21 -0500 Subject: [PATCH] open registration --- flask_app.py | 39 ++++++++++-------- templates/dashboard.html | 87 +++++++++++++++++++++------------------- 2 files changed, 69 insertions(+), 57 deletions(-) diff --git a/flask_app.py b/flask_app.py index 278c3ef..f65d8a5 100644 --- a/flask_app.py +++ b/flask_app.py @@ -367,28 +367,29 @@ def check_in(): @app.route('/drop', methods=['GET']) def drop(): + mlh_id = request.args.get('mlh_id') # Drop a hacker's registration... - if request.args.get('mlh_id') is None: + if mlh_id is None: return jsonify({'status': 'error', 'action': 'drop', 'more_info': 'Missing required field...'}) - if not is_admin() and not is_self(request.args.get('mlh_id')): + if not is_admin() and not is_self(mlh_id): return jsonify({'status': 'error', 'action': 'drop', 'more_info': 'You do not have permissions to perform this action...'}) - row = db.session.query(Hacker.checked_in, Hacker.waitlisted).filter( - Hacker.mlh_id == request.args.get('mlh_id')).one_or_none() + row = db.session.query(Hacker.checked_in, Hacker.waitlisted, Hacker.first_name, Hacker.last_name, Hacker.email).filter( + Hacker.mlh_id == mlh_id).one_or_none() if row is None: return jsonify({'status': 'error', 'action': 'drop', 'more_info': 'Could not find hacker...'}) - (checked_in, waitlisted) = row + (checked_in, waitlisted, first_name, last_name, email) = row if checked_in: return jsonify({'status': 'error', 'action': 'drop', 'more_info': 'Cannot drop, already checked in...'}) - mlh_info = get_mlh_user(request.args.get('mlh_id')) - print(mlh_info['first_name'] + " trying to drop.") + # mlh_info = get_mlh_user(request.args.get('mlh_id')) + print(first_name + " trying to drop.") # Delete from db... @@ -398,24 +399,24 @@ def drop(): # Delete resume... for ext in ALLOWED_EXTENSIONS: - filename = mlh_info['first_name'].lower() + '_' + mlh_info['last_name'].lower() + '_' + request.args.get( - 'mlh_id') + '.' + ext + filename = first_name.lower() + '_' + last_name.lower() + '_' + mlh_id + '.' + ext try: os.remove(app.config['UPLOAD_FOLDER'] + '/' + filename) except OSError: pass # Send a goodbye email... - msg = 'Dear ' + mlh_info['first_name'] + ',\n\n' + msg = 'Dear ' + first_name + ',\n\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) + send_email(email, 'Hack@WPI - Application Dropped', msg) - if is_self(request.args.get('mlh_id')): + print(first_name + " dropped successfully.") + if is_self(mlh_id): session.clear() + return redirect('https://hack.wpi.edu') - print(mlh_info['first_name'] + " dropped successfully.") - return jsonify({'status': 'success', 'action': 'drop', 'more_info': '', 'id': request.args.get('mlh_id')}) + return jsonify({'status': 'success', 'action': 'drop', 'more_info': '', 'id': mlh_id}) @app.route('/promote_from_waitlist', methods=['GET']) @@ -476,9 +477,15 @@ def dashboard(): return redirect(url_for('register')) hacker = db.session.query(Hacker).filter(Hacker.mlh_id == session['mymlh']['id']).one_or_none() - print(hacker) + + # In case application dropped but user not logged out properly + if not hacker: + session.clear() + return redirect(url_for('register')) + + shirt_size = (hacker.shirt_size or 'None').upper() return render_template('dashboard.html', name=session['mymlh']['first_name'], id=session['mymlh']['id'], - admin=is_admin(), shirt_size=hacker.shirt_size, special_needs=hacker.special_needs) + admin=is_admin(), shirt_size=shirt_size, special_needs=hacker.special_needs) @app.route('/tos', methods=['GET']) def tos(): diff --git a/templates/dashboard.html b/templates/dashboard.html index f43354b..feb545c 100644 --- a/templates/dashboard.html +++ b/templates/dashboard.html @@ -1,6 +1,49 @@ {% include 'header.html' %} +
@@ -10,7 +53,7 @@

You are waitlisted, if space opens up we will let you know...

{% else %}

You are fully registered! We look forward to seeing you!

- Let us know if you have any questions by sending them to hack@wpi.edu + Let us know if you have any questions by sending them to hack@wpi.edu
Forgot to upload your resume while registering? No worries, submit it below.
@@ -19,7 +62,7 @@

Optional Info:

-

Shirt Size (Currently selected: {{shirt_size.upper()}})

+

Shirt Size (Currently selected: {{shirt_size}})

@@ -69,7 +112,7 @@


-

Drop Application if you can't make it :(

+

Drop Application if you can't make it :(

{% include 'footer.html' %}