Skip to content

Commit efd4204

Browse files
committed
Bug OpenClassrooms-Student-Center#2 fixed - max number of points to use to book places
equals the available points of the club
1 parent 328e68f commit efd4204

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

server.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,17 @@ def purchasePlaces():
4949
competition = [c for c in competitions if c['name'] == request.form['competition']][0]
5050
club = [c for c in clubs if c['name'] == request.form['club']][0]
5151
placesRequired = int(request.form['places'])
52-
competition['numberOfPlaces'] = int(competition['numberOfPlaces'])-placesRequired
53-
flash('Great-booking complete!')
52+
53+
# Bug #2 fixed - max number of points to use to book places
54+
# equals the available points of the club
55+
if int(club['points']) >= placesRequired:
56+
competition['numberOfPlaces'] = int(competition['numberOfPlaces'])-placesRequired
57+
# deduct redeemed points after successful booking of places
58+
club['points'] = int(club['points']) - placesRequired
59+
flash('Great-booking complete!')
60+
return render_template(
61+
'welcome.html', club=club, competitions=competitions)
62+
flash("Your club doesn't have enough points")
5463
return render_template(
5564
'welcome.html', club=club, competitions=competitions)
5665

0 commit comments

Comments
 (0)