open registration

This commit is contained in:
ACM 2020-12-16 23:27:21 -05:00
parent c335d1bdab
commit 25e288355a
2 changed files with 69 additions and 57 deletions

View file

@ -367,28 +367,29 @@ def check_in():
@app.route('/drop', methods=['GET']) @app.route('/drop', methods=['GET'])
def drop(): def drop():
mlh_id = request.args.get('mlh_id')
# Drop a hacker's registration... # 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...'}) 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', return jsonify({'status': 'error', 'action': 'drop',
'more_info': 'You do not have permissions to perform this action...'}) 'more_info': 'You do not have permissions to perform this action...'})
row = db.session.query(Hacker.checked_in, Hacker.waitlisted).filter( row = db.session.query(Hacker.checked_in, Hacker.waitlisted, Hacker.first_name, Hacker.last_name, Hacker.email).filter(
Hacker.mlh_id == request.args.get('mlh_id')).one_or_none() Hacker.mlh_id == mlh_id).one_or_none()
if row is None: if row is None:
return jsonify({'status': 'error', 'action': 'drop', return jsonify({'status': 'error', 'action': 'drop',
'more_info': 'Could not find hacker...'}) 'more_info': 'Could not find hacker...'})
(checked_in, waitlisted) = row (checked_in, waitlisted, first_name, last_name, email) = row
if checked_in: if checked_in:
return jsonify({'status': 'error', 'action': 'drop', 'more_info': 'Cannot drop, already 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')) # mlh_info = get_mlh_user(request.args.get('mlh_id'))
print(mlh_info['first_name'] + " trying to drop.") print(first_name + " trying to drop.")
# Delete from db... # Delete from db...
@ -398,24 +399,24 @@ def drop():
# Delete resume... # Delete resume...
for ext in ALLOWED_EXTENSIONS: for ext in ALLOWED_EXTENSIONS:
filename = mlh_info['first_name'].lower() + '_' + mlh_info['last_name'].lower() + '_' + request.args.get( filename = first_name.lower() + '_' + last_name.lower() + '_' + mlh_id + '.' + ext
'mlh_id') + '.' + ext
try: try:
os.remove(app.config['UPLOAD_FOLDER'] + '/' + filename) os.remove(app.config['UPLOAD_FOLDER'] + '/' + filename)
except OSError: except OSError:
pass pass
# Send a goodbye email... # 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' 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() session.clear()
return redirect('https://hack.wpi.edu')
print(mlh_info['first_name'] + " dropped successfully.") return jsonify({'status': 'success', 'action': 'drop', 'more_info': '', 'id': mlh_id})
return jsonify({'status': 'success', 'action': 'drop', 'more_info': '', 'id': request.args.get('mlh_id')})
@app.route('/promote_from_waitlist', methods=['GET']) @app.route('/promote_from_waitlist', methods=['GET'])
@ -476,9 +477,15 @@ def dashboard():
return redirect(url_for('register')) return redirect(url_for('register'))
hacker = db.session.query(Hacker).filter(Hacker.mlh_id == session['mymlh']['id']).one_or_none() 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'], 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']) @app.route('/tos', methods=['GET'])
def tos(): def tos():

View file

@ -1,6 +1,49 @@
{% include 'header.html' %} {% include 'header.html' %}
<script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.min.js"></script>
<link href="../static/css/materialize.min.css" rel="stylesheet"> <link href="../static/css/materialize.min.css" rel="stylesheet">
<script>
const drop = (id) =>
{
if(window.confirm("Are you sure you wish to drop your application? This cannot be undone. (patiently wait after clicking the button)")) {
window.location.href = "/drop?mlh_id=" + id;
}
// swal({
// title: 'Drop your application?',
// text: 'Are you sure you wish to drop your application? This cannot be undone. (patiently wait after clicking the button)',
// type: 'warning',
// showCancelButton: true,
// closeOnConfirm: false,
// confirmButtonText: 'Yes, drop!',
// confirmButtonColor: errColor
// }, () => {
// $.get('/drop?mlh_id=' + id, (data) => {
// let title = ''
// let msg = ''
// let type = ''
// if (data.status === 'success'
// )
// {
// title = 'Dropped!'
// msg = 'Your application was successfully dropped!'
// type = 'success'
// }
// else
// {
// title = 'Error!'
// msg = JSON.stringify(data)
// type = 'error'
// }
// swal(title, msg, type)
// if (data.status === 'success') {
// setTimeout(() => {window.location = '/'
// },
// 5000
// )
// }
// })
// })
}
</script>
<div class="contact-section" style="height: 100%;"> <div class="contact-section" style="height: 100%;">
<div class="container"> <div class="container">
@ -10,7 +53,7 @@
<h1>You are waitlisted, if space opens up we will let you know...</h1> <h1>You are waitlisted, if space opens up we will let you know...</h1>
{% else %} {% else %}
<h1>You are fully registered! We look forward to seeing you!</h1> <h1>You are fully registered! We look forward to seeing you!</h1>
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 <a href="mailto:hack@wpi.edu">hack@wpi.edu</a>
<br> <br>
Forgot to upload your resume while registering? No worries, submit it below. Forgot to upload your resume while registering? No worries, submit it below.
</div> </div>
@ -19,7 +62,7 @@
<br> <br>
<p><b>Optional Info:</b></p> <p><b>Optional Info:</b></p>
<div> <div>
<p>Shirt Size (Currently selected: {{shirt_size.upper()}})</p> <p>Shirt Size (Currently selected: {{shirt_size}})</p>
<input type="radio" id="shirtxs" name="size" value="xs"> <input type="radio" id="shirtxs" name="size" value="xs">
<label for="shirtxs">XS</label> <label for="shirtxs">XS</label>
<input type="radio" id="shirts" name="size" value="s"> <input type="radio" id="shirts" name="size" value="s">
@ -69,7 +112,7 @@
</div> </div>
<br> <br>
<br> <br>
<center><a href="#" id="drop-link"><p class="btn">Drop Application if you can't make it :(</p></a></center> <center><a onclick="drop('{{id}}')" id="drop-link"><p class="btn">Drop Application if you can't make it :(</p></a></center>
</div> </div>
<script> <script>
@ -84,44 +127,6 @@
}) })
}) })
const drop = (id) =>
{
swal({
title: 'Drop your application?',
text: 'Are you sure you wish to drop your application? This cannot be undone. (patiently wait after clicking the button)',
type: 'warning',
showCancelButton: true,
closeOnConfirm: false,
confirmButtonText: 'Yes, drop!',
confirmButtonColor: errColor
}, () => {
$.get('/drop?mlh_id=' + id, (data) => {
let title = ''
let msg = ''
let type = ''
if (data.status === 'success'
)
{
title = 'Dropped!'
msg = 'Your application was successfully dropped!'
type = 'success'
}
else
{
title = 'Error!'
msg = JSON.stringify(data)
type = 'error'
}
swal(title, msg, type)
if (data.status === 'success') {
setTimeout(() => {window.location = '/'
},
5000
)
}
})
})
}
</script> </script>
{% include 'footer.html' %} {% include 'footer.html' %}