From 1efa52c0ff1df13f818ef94ce16eb5b106eb2bf0 Mon Sep 17 00:00:00 2001 From: AlexBotswana Date: Tue, 20 Feb 2024 10:38:59 +0200 Subject: [PATCH 1/4] Update .gitignore (add virtualanv) --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 2cba99d87..5fd951e55 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +virtualenv bin include lib From bc1233a868470ca69a198fd76c8aa0b5e75b5f14 Mon Sep 17 00:00:00 2001 From: AlexBotswana Date: Tue, 20 Feb 2024 10:47:08 +0200 Subject: [PATCH 2/4] Fix error unknown email --- server.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/server.py b/server.py index 4084baeac..c304d3e3e 100644 --- a/server.py +++ b/server.py @@ -26,8 +26,11 @@ 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) + try: + club = [club for club in clubs if club['email'] == request.form['email']][0] + return render_template('welcome.html',club=club,competitions=competitions) + except Exception: + return render_template('index.html') @app.route('/book//') From d085d328117768541597d8c651c7ed96bae0972d Mon Sep 17 00:00:00 2001 From: AlexBotswana Date: Tue, 20 Feb 2024 22:19:22 +0200 Subject: [PATCH 3/4] Fix Bug No negative account #2 --- server.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/server.py b/server.py index c304d3e3e..721f1568b 100644 --- a/server.py +++ b/server.py @@ -46,12 +46,21 @@ def book(competition,club): @app.route('/purchasePlaces',methods=['POST']) 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!') - return render_template('welcome.html', club=club, competitions=competitions) + try: + 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 <= int(club['points']): + competition['numberOfPlaces'] = int(competition['numberOfPlaces'])-placesRequired + club['points'] = int(club['points'])-placesRequired + flash('Great-booking complete!') + return render_template('welcome.html', club=club, competitions=competitions) + else: + flash("You don't have enougth points") + return render_template('welcome.html', club=club, competitions=competitions) + except Exception: + flash("Something went wrong-please try again") + return render_template('welcome.html', club=club, competitions=competitions) # TODO: Add route for points display From f7fa180d7f214d99f28c775aa9b370a91af4c404 Mon Sep 17 00:00:00 2001 From: AlexBotswana Date: Wed, 21 Feb 2024 22:36:43 +0200 Subject: [PATCH 4/4] Fix bug 12places max Issue #4 --- server.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/server.py b/server.py index 721f1568b..5209f4ca8 100644 --- a/server.py +++ b/server.py @@ -44,19 +44,25 @@ def book(competition,club): return render_template('welcome.html', club=club, competitions=competitions) + @app.route('/purchasePlaces',methods=['POST']) def purchasePlaces(): try: 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 <= int(club['points']): - competition['numberOfPlaces'] = int(competition['numberOfPlaces'])-placesRequired - club['points'] = int(club['points'])-placesRequired - flash('Great-booking complete!') - return render_template('welcome.html', club=club, competitions=competitions) + max_places = 12 + if placesRequired <= max_places: + if placesRequired <= int(club['points']): + competition['numberOfPlaces'] = int(competition['numberOfPlaces'])-placesRequired + club['points'] = int(club['points'])-placesRequired + flash('Great-booking complete!') + return render_template('welcome.html', club=club, competitions=competitions) + else: + flash('You do not have enougth points') + return render_template('welcome.html', club=club, competitions=competitions) else: - flash("You don't have enougth points") + flash('You can not buy more than 12 places') return render_template('welcome.html', club=club, competitions=competitions) except Exception: flash("Something went wrong-please try again")