Skip to content

Commit

Permalink
Resolution of bug #2
Browse files Browse the repository at this point in the history
  • Loading branch information
CeeG33 committed Sep 11, 2023
1 parent 530f51e commit cf3598d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,23 @@ def book(competition,club):
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]
club_points = int(club["points"])
placesRequired = int(request.form['places'])

if placesRequired > club_points:
flash("You don't have enough points to book this quantity. Please try again.")
return render_template('welcome.html', club=club, competitions=competitions)

elif placesRequired <= 0:
flash("This is not a correct value. Please try again.")
return render_template('welcome.html', club=club, competitions=competitions)

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)


Expand Down

0 comments on commit cf3598d

Please sign in to comment.