From bcfb32fe13777bfda7d5de867186e2eb5e51bc7c Mon Sep 17 00:00:00 2001 From: devogs Date: Wed, 2 Jul 2025 10:32:40 +0200 Subject: [PATCH 1/3] Fix: Application crash on unknown email entry (IndexError) --- .gitignore | 3 ++- server.py | 10 +++++++--- templates/index.html | 12 ++++++++++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 2cba99d87..09821350e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ lib .Python tests/ .envrc -__pycache__ \ No newline at end of file +__pycache__ +venv/ \ No newline at end of file diff --git a/server.py b/server.py index 4084baeac..ddf6650c1 100644 --- a/server.py +++ b/server.py @@ -26,9 +26,13 @@ def index(): @app.route('/showSummary',methods=['POST']) def showSummary(): - club = [club for club in clubs if club['email'] == request.form['email']][0] - return render_template('welcome.html',club=club,competitions=competitions) - + found_clubs = [club for club in clubs if club['email'] == request.form['email']] + if found_clubs: + club = found_clubs[0] + return render_template('welcome.html',club=club,competitions=competitions) + else: + flash("Sorry, that email was not found.") + return redirect(url_for('index')) @app.route('/book//') def book(competition,club): diff --git a/templates/index.html b/templates/index.html index 926526b7d..2ee8e0e12 100644 --- a/templates/index.html +++ b/templates/index.html @@ -6,6 +6,18 @@

Welcome to the GUDLFT Registration Portal!

+ + {# Add this block to display flashed messages #} + {% with messages = get_flashed_messages()%} + {% if messages %} +
    + {% for message in messages %} +
  • {{message}}
  • + {% endfor %} +
+ {% endif%} + {%endwith%} + Please enter your secretary email to continue:
From 993590c38cfc5dacba3a3c187ae640e537fcf1b5 Mon Sep 17 00:00:00 2001 From: devogs Date: Wed, 2 Jul 2025 11:11:20 +0200 Subject: [PATCH 2/3] Fix: Prevent clubs from booking more places than their available points --- server.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/server.py b/server.py index ddf6650c1..c31eadc73 100644 --- a/server.py +++ b/server.py @@ -50,11 +50,17 @@ def purchasePlaces(): competition = [c for c in competitions if c['name'] == request.form['competition']][0] club = [c for c in clubs if c['name'] == request.form['club']][0] placesRequired = int(request.form['places']) - competition['numberOfPlaces'] = int(competition['numberOfPlaces'])-placesRequired - flash('Great-booking complete!') + if int(club['points']) >= placesRequired: + competition['numberOfPlaces'] = int(competition['numberOfPlaces'])-placesRequired + club['points'] = str(int(club['points']) - placesRequired) + flash('Great-booking complete!') + else: + flash(f"You do not have enough points to book {placesRequired} places. You currently have {club['points']} points.") + return render_template('welcome.html', club=club, competitions=competitions) + # TODO: Add route for points display From 8cf9b4b67dd7dce54dfe6513b63b53803dcb6598 Mon Sep 17 00:00:00 2001 From: devogs Date: Wed, 2 Jul 2025 11:20:07 +0200 Subject: [PATCH 3/3] Fix: Limit club bookings to a maximum of 12 places per competition --- server.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server.py b/server.py index c31eadc73..54a8f5fa8 100644 --- a/server.py +++ b/server.py @@ -50,6 +50,9 @@ def purchasePlaces(): competition = [c for c in competitions if c['name'] == request.form['competition']][0] club = [c for c in clubs if c['name'] == request.form['club']][0] placesRequired = int(request.form['places']) + if placesRequired > 12: + flash("You cannot book more than 12 places per competition.") + return render_template('welcome.html', club=club, competitions=competitions) if int(club['points']) >= placesRequired: competition['numberOfPlaces'] = int(competition['numberOfPlaces'])-placesRequired club['points'] = str(int(club['points']) - placesRequired)