open registration
This commit is contained in:
parent
c335d1bdab
commit
25e288355a
2 changed files with 69 additions and 57 deletions
39
flask_app.py
39
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():
|
||||
|
|
|
@ -1,6 +1,49 @@
|
|||
{% include 'header.html' %}
|
||||
<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">
|
||||
<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="container">
|
||||
|
@ -10,7 +53,7 @@
|
|||
<h1>You are waitlisted, if space opens up we will let you know...</h1>
|
||||
{% else %}
|
||||
<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>
|
||||
Forgot to upload your resume while registering? No worries, submit it below.
|
||||
</div>
|
||||
|
@ -19,7 +62,7 @@
|
|||
<br>
|
||||
<p><b>Optional Info:</b></p>
|
||||
<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">
|
||||
<label for="shirtxs">XS</label>
|
||||
<input type="radio" id="shirts" name="size" value="s">
|
||||
|
@ -69,7 +112,7 @@
|
|||
</div>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
|
||||
{% include 'footer.html' %}
|
||||
|
|
Loading…
Add table
Reference in a new issue