Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Bug 12places max #216

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
virtualenv
bin
include
lib
Expand Down
34 changes: 26 additions & 8 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ def index():

@app.route('/showSummary',methods=['POST'])
def showSummary():
club = [club for club in clubs if club['email'] == request.form['email']][0]
return render_template('welcome.html',club=club,competitions=competitions)
try:
club = [club for club in clubs if club['email'] == request.form['email']][0]
return render_template('welcome.html',club=club,competitions=competitions)
except Exception:
return render_template('index.html')


@app.route('/book/<competition>/<club>')
Expand All @@ -41,14 +44,29 @@ def book(competition,club):
return render_template('welcome.html', club=club, competitions=competitions)



@app.route('/purchasePlaces',methods=['POST'])
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!')
return render_template('welcome.html', club=club, competitions=competitions)
try:
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'])
max_places = 12
if placesRequired <= max_places:
if placesRequired <= int(club['points']):
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)
else:
flash('You do not have enougth points')
return render_template('welcome.html', club=club, competitions=competitions)
else:
flash('You can not buy more than 12 places')
return render_template('welcome.html', club=club, competitions=competitions)
except Exception:
flash("Something went wrong-please try again")
return render_template('welcome.html', club=club, competitions=competitions)


# TODO: Add route for points display
Expand Down