Skip to content
This repository has been archived by the owner on May 8, 2022. It is now read-only.

Commit

Permalink
Fixes OpenClassrooms-Student-Center#2 OpenClassrooms-Student-Center/P…
Browse files Browse the repository at this point in the history
…ython_Testing
  • Loading branch information
josayko committed Apr 19, 2022
1 parent 2b5c5f8 commit bce9c27
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,25 @@ def purchasePlaces():
]
club = [c for c in clubs if c["name"] == request.form["club"]][0]
placesRequired = int(request.form["places"])
competition["numberOfPlaces"] = int(competition["numberOfPlaces"]) - placesRequired
club["points"] = int(club["points"]) - placesRequired
club_points = int(club["points"])
if placesRequired <= 0:
flash("Error: places value can not be negative")
return (
render_template("welcome.html", club=club, competitions=competitions),
400,
)

elif club_points >= placesRequired:
competition["numberOfPlaces"] = (
int(competition["numberOfPlaces"]) - placesRequired
)
club["points"] = club_points - placesRequired
else:
flash("Error: no enough points")
return (
render_template("welcome.html", club=club, competitions=competitions),
400,
)
flash("Great-booking complete!")
return render_template("welcome.html", club=club, competitions=competitions)

Expand Down

0 comments on commit bce9c27

Please sign in to comment.