Compare commits
1 Commits
main
...
closed_eve
| Author | SHA1 | Date | |
|---|---|---|---|
| 755e752084 |
@@ -70,41 +70,7 @@ def index():
|
|||||||
spots_left = max_spots - confirmed_count
|
spots_left = max_spots - confirmed_count
|
||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
name = request.form['name']
|
flash("Event has already started")
|
||||||
email = request.form['email'].lower().strip()
|
|
||||||
looking_for_team = True if request.form.get('looking_for_team') else False
|
|
||||||
|
|
||||||
tum_domains = current_app.config['TUM_DOMAINS']
|
|
||||||
if not email.endswith(tum_domains):
|
|
||||||
domains_str = ", ".join(tum_domains)
|
|
||||||
flash(f"Error: You must use one of these email addresses: {domains_str}", "error")
|
|
||||||
return redirect(url_for('main.index'))
|
|
||||||
existing_user = Participant.query.filter_by(email=email).first()
|
|
||||||
|
|
||||||
if existing_user:
|
|
||||||
if existing_user.confirmed:
|
|
||||||
flash("You are already registered and confirmed!", "info")
|
|
||||||
elif existing_user.on_waitlist:
|
|
||||||
if confirmed_count < max_spots:
|
|
||||||
existing_user.on_waitlist = False
|
|
||||||
db.session.commit()
|
|
||||||
send_verification_email(existing_user)
|
|
||||||
else:
|
|
||||||
flash("You are already on the waitlist", "info")
|
|
||||||
else:
|
|
||||||
send_verification_email(existing_user, is_new=False)
|
|
||||||
return redirect(url_for('main.index'))
|
|
||||||
else:
|
|
||||||
new_user = add_user(name, email, looking_for_team)
|
|
||||||
|
|
||||||
if confirmed_count < max_spots:
|
|
||||||
send_verification_email(new_user)
|
|
||||||
else:
|
|
||||||
new_user.on_waitlist = True
|
|
||||||
db.session.commit()
|
|
||||||
send_waitlist_email(new_user)
|
|
||||||
flash("The event is already full!\nYou have been placed on the waitlist", "info")
|
|
||||||
return redirect(url_for('main.index'))
|
|
||||||
|
|
||||||
return render_template('index.html', spots_left=spots_left, max_spots=max_spots)
|
return render_template('index.html', spots_left=spots_left, max_spots=max_spots)
|
||||||
|
|
||||||
@@ -112,57 +78,12 @@ def index():
|
|||||||
@bp.route('/verify/<token>')
|
@bp.route('/verify/<token>')
|
||||||
@limiter.limit("50 per hour")
|
@limiter.limit("50 per hour")
|
||||||
def verify_email(token):
|
def verify_email(token):
|
||||||
s = URLSafeTimedSerializer(current_app.config['SECRET_KEY'])
|
return render_template("error.html", error_message="Sorry! The event has already started")
|
||||||
try:
|
|
||||||
email = s.loads(token, salt='email-confirm-h4tum-ctf-2025', max_age=1209600)
|
|
||||||
except SignatureExpired:
|
|
||||||
return render_template("error.html", error_message="Token expired. Please register again.")
|
|
||||||
except BadSignature:
|
|
||||||
return render_template("error.html", error_message="Invalid token.")
|
|
||||||
|
|
||||||
user = Participant.query.filter_by(email=email).first_or_404()
|
|
||||||
|
|
||||||
if get_confirmed_count() >= current_app.config['MAX_SPOTS']:
|
|
||||||
if user.confirmed:
|
|
||||||
return render_template('success.html', message="You are confirmed", discord_link=current_app.config['DISCORD_LINK'], discord_token=user.discord_token)
|
|
||||||
else:
|
|
||||||
return render_template("error.html", error_message="Sorry! The event filled up while you were claiming the last spot.")
|
|
||||||
else:
|
|
||||||
user.confirmed = True
|
|
||||||
if user.on_waitlist:
|
|
||||||
user.on_waitlist = False
|
|
||||||
db.session.commit()
|
|
||||||
|
|
||||||
discord_link = current_app.config['DISCORD_LINK']
|
|
||||||
discord_token = user.discord_token
|
|
||||||
msg = "You are confirmed!"
|
|
||||||
if user.looking_for_team:
|
|
||||||
msg += " Since you need a team, please join the #team-search channel."
|
|
||||||
|
|
||||||
return render_template('success.html', message=msg, discord_link=discord_link, discord_token=discord_token)
|
|
||||||
|
|
||||||
@bp.route('/remove/<token>')
|
@bp.route('/remove/<token>')
|
||||||
@limiter.limit("5 per hour")
|
@limiter.limit("5 per hour")
|
||||||
def remove_registration(token):
|
def remove_registration(token):
|
||||||
s = URLSafeTimedSerializer(current_app.config['SECRET_KEY'])
|
return render_template("error.html", error_message="The event already started you can not deregister")
|
||||||
try:
|
|
||||||
email = s.loads(token, salt='email-remove-h4tum-ctf-2026', max_age=1209600)
|
|
||||||
except SignatureExpired:
|
|
||||||
return render_template("error.html", error_message="Token expired. Please register again.")
|
|
||||||
except BadSignature:
|
|
||||||
return render_template("error.html", error_message="Invalid token.")
|
|
||||||
|
|
||||||
user = Participant.query.filter_by(email=email).first_or_404()
|
|
||||||
|
|
||||||
if not user:
|
|
||||||
return render_template("error.html", error_message="No user found.")
|
|
||||||
db.session.delete(user)
|
|
||||||
db.session.commit()
|
|
||||||
|
|
||||||
if get_confirmed_count() == current_app.config['MAX_SPOTS'] - 1:
|
|
||||||
send_waitlist_newsletter()
|
|
||||||
|
|
||||||
return render_template("deregistered.html", message="Sad to see you go. Comeback next time :D")
|
|
||||||
|
|
||||||
@bp.route('/dsgvo')
|
@bp.route('/dsgvo')
|
||||||
@limiter.exempt
|
@limiter.exempt
|
||||||
|
|||||||
@@ -95,28 +95,7 @@
|
|||||||
{% endwith %}
|
{% endwith %}
|
||||||
|
|
||||||
<div class="status">
|
<div class="status">
|
||||||
{% if spots_left > 0 %}
|
<h3>Event already started</h3>
|
||||||
<h2>Spots Remaining: {{ spots_left }} / {{max_spots}}</h2>
|
|
||||||
{% else %}
|
|
||||||
<h2>Register for Waitlist</h2>
|
|
||||||
<p>This event is currently full.</p>
|
|
||||||
<p>Join the mailing list to be automatically notified of free spots.</p>
|
|
||||||
{%endif %}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form method="POST">
|
|
||||||
<label>Name</label>
|
|
||||||
<input type="text" name="name" required>
|
|
||||||
|
|
||||||
<label>TUM Email</label>
|
|
||||||
<input type="email" name="email" placeholder="@tum.de" required>
|
|
||||||
|
|
||||||
<label style="display:block; margin: 20px 0; line-height: 1.4;">
|
|
||||||
<input type="checkbox" name="looking_for_team" style="transform: scale(1.2); margin-right: 10px;">
|
|
||||||
I need a team / looking for group
|
|
||||||
</label>
|
|
||||||
|
|
||||||
<button type="submit">INITIALIZE_REGISTRATION</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
Reference in New Issue
Block a user