added checking and substracting points
This commit is contained in:
parent
2317006de9
commit
b70f80f3cb
13
server.py
13
server.py
@ -48,9 +48,18 @@ 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
|
||||
points = int(club['points'])
|
||||
if placesRequired <= points:
|
||||
competition['numberOfPlaces'] = int(competition['numberOfPlaces']) - placesRequired
|
||||
club['points'] = int(club['points']) - placesRequired
|
||||
if competition['numberOfPlaces'] < 0:
|
||||
competition['numberOfPlaces'] = 0
|
||||
flash('Great-booking complete!')
|
||||
return render_template('welcome.html', club=club, competitions=competitions)
|
||||
else:
|
||||
flash("You don't have enough points")
|
||||
return render_template('welcome.html', club=club,
|
||||
competitions=competitions)
|
||||
|
||||
|
||||
|
||||
# TODO: Add route for points display
|
||||
|
Loading…
x
Reference in New Issue
Block a user