Skip to content

Commit 47df654

Browse files
first commit : purchase fix
1 parent 81e09c8 commit 47df654

File tree

4 files changed

+33
-18
lines changed

4 files changed

+33
-18
lines changed

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ bin
22
include
33
lib
44
.Python
5-
tests/
65
.envrc
7-
__pycache__
6+
__pycache__
7+
/env
8+
.idea/

server.py

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import json
2-
from flask import Flask,render_template,request,redirect,flash,url_for
2+
from flask import Flask, render_template, request, redirect, flash, url_for
33

44

55
def loadClubs():
66
with open('clubs.json') as c:
7-
listOfClubs = json.load(c)['clubs']
8-
return listOfClubs
7+
listOfClubs = json.load(c)['clubs']
8+
return listOfClubs
99

1010

1111
def loadCompetitions():
1212
with open('competitions.json') as comps:
13-
listOfCompetitions = json.load(comps)['competitions']
14-
return listOfCompetitions
13+
listOfCompetitions = json.load(comps)['competitions']
14+
return listOfCompetitions
1515

1616

1717
app = Flask(__name__)
@@ -20,40 +20,49 @@ def loadCompetitions():
2020
competitions = loadCompetitions()
2121
clubs = loadClubs()
2222

23+
2324
@app.route('/')
2425
def index():
2526
return render_template('index.html')
2627

27-
@app.route('/showSummary',methods=['POST'])
28+
29+
@app.route('/showSummary', methods=['POST'])
2830
def showSummary():
29-
club = [club for club in clubs if club['email'] == request.form['email']][0]
30-
return render_template('welcome.html',club=club,competitions=competitions)
31+
club = [club for club in clubs if club['email'] == request.form['email']][
32+
0]
33+
return render_template('welcome.html', club=club,
34+
competitions=competitions)
3135

3236

3337
@app.route('/book/<competition>/<club>')
34-
def book(competition,club):
38+
def book(competition, club):
3539
foundClub = [c for c in clubs if c['name'] == club][0]
3640
foundCompetition = [c for c in competitions if c['name'] == competition][0]
3741
if foundClub and foundCompetition:
38-
return render_template('booking.html',club=foundClub,competition=foundCompetition)
42+
return render_template('booking.html', club=foundClub,
43+
competition=foundCompetition)
3944
else:
4045
flash("Something went wrong-please try again")
41-
return render_template('welcome.html', club=club, competitions=competitions)
46+
return render_template('welcome.html', club=club,
47+
competitions=competitions)
4248

4349

44-
@app.route('/purchasePlaces',methods=['POST'])
50+
@app.route('/purchasePlaces', methods=['POST'])
4551
def purchasePlaces():
46-
competition = [c for c in competitions if c['name'] == request.form['competition']][0]
52+
competition = \
53+
[c for c in competitions if c['name'] == request.form['competition']][0]
4754
club = [c for c in clubs if c['name'] == request.form['club']][0]
4855
placesRequired = int(request.form['places'])
49-
competition['numberOfPlaces'] = int(competition['numberOfPlaces'])-placesRequired
56+
competition['numberOfPlaces'] = int(
57+
competition['numberOfPlaces']) - placesRequired
5058
flash('Great-booking complete!')
51-
return render_template('welcome.html', club=club, competitions=competitions)
59+
return render_template('welcome.html', club=club,
60+
competitions=competitions)
5261

5362

5463
# TODO: Add route for points display
5564

5665

5766
@app.route('/logout')
5867
def logout():
59-
return redirect(url_for('index'))
68+
return redirect(url_for('index'))

tests/__init__.py

Whitespace-only changes.

tests/test_server.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
3+
class PurchasePlaces:
4+
def test_purchase_places(self):
5+
assert False

0 commit comments

Comments
 (0)