From 7521a05db9d568a4b880cef0f066b18890e81ec5 Mon Sep 17 00:00:00 2001 From: yann Date: Thu, 26 Jun 2025 11:37:02 +0200 Subject: [PATCH] added now to every welcome template call --- server.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/server.py b/server.py index 2fa57b6..7cd5485 100644 --- a/server.py +++ b/server.py @@ -20,6 +20,8 @@ app.secret_key = 'something_special' competitions = loadCompetitions() clubs = loadClubs() +now = datetime.strftime(datetime.now(), "%Y-%m-%d %H:%M:%S") + @app.route('/') def index(): @@ -28,7 +30,6 @@ def index(): @app.route('/showSummary',methods=['POST']) def showSummary(): club = [club for club in clubs if club['email'] == request.form['email']] - now = datetime.strftime(datetime.now(), "%Y-%m-%d %H:%M:%S") if club: return render_template('welcome.html', club=club[0], competitions=competitions, now=now) flash("The email isn't found") @@ -38,17 +39,16 @@ def showSummary(): def book(competition,club): foundClub = [c for c in clubs if c['name'] == club][0] foundCompetition = [c for c in competitions if c['name'] == competition][0] - now = datetime.strftime(datetime.now(), "%Y-%m-%d %H:%M:%S") if foundClub and foundCompetition: - if competition['date'] > now: + if foundCompetition['date'] > now: return render_template('booking.html',club=foundClub,competition=foundCompetition) else: flash("You cannot book for a past competition") return render_template('welcome.html', club=club, - competitions=competitions) + competitions=competitions, now=now) else: flash("Something went wrong-please try again") - return render_template('welcome.html', club=club, competitions=competitions) + return render_template('welcome.html', club=club, competitions=competitions, now=now) @app.route('/purchasePlaces',methods=['POST']) @@ -69,7 +69,7 @@ def purchasePlaces(): club['points'] = int(club['points']) - placesRequired if not competition['name'] in session: session[competition['name']] = placesRequired - flash('Great-booking complete!') + flash(f"Great ! {placesRequired} places booked for {competition['name']}") else: flash("You don't have enough points") else: @@ -77,7 +77,7 @@ def purchasePlaces(): else: flash("You can't book more than 12 places") return render_template('welcome.html', club=club, - competitions=competitions) + competitions=competitions, now=now) # TODO: Add route for points display