Skip to content

Commit

Permalink
Bug OpenClassrooms-Student-Center#2 fixed - max number of points to u…
Browse files Browse the repository at this point in the history
…se to book places

equals the available points of the club
  • Loading branch information
Pascal273 committed May 11, 2022
1 parent 328e68f commit efd4204
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,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!')

# Bug #2 fixed - max number of points to use to book places
# equals the available points of the club
if int(club['points']) >= placesRequired:
competition['numberOfPlaces'] = int(competition['numberOfPlaces'])-placesRequired
# deduct redeemed points after successful booking of places
club['points'] = int(club['points']) - placesRequired
flash('Great-booking complete!')
return render_template(
'welcome.html', club=club, competitions=competitions)
flash("Your club doesn't have enough points")
return render_template(
'welcome.html', club=club, competitions=competitions)

Expand Down

0 comments on commit efd4204

Please sign in to comment.