From bcfb32fe13777bfda7d5de867186e2eb5e51bc7c Mon Sep 17 00:00:00 2001 From: devogs Date: Wed, 2 Jul 2025 10:32:40 +0200 Subject: [PATCH] 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: