Compare commits
4 Commits
main
...
d3e9eda937
| Author | SHA1 | Date | |
|---|---|---|---|
| d3e9eda937 | |||
| b70f80f3cb | |||
| 2317006de9 | |||
| a50d1946ce |
24
server.py
24
server.py
@@ -26,9 +26,11 @@ def index():
|
|||||||
|
|
||||||
@app.route('/showSummary',methods=['POST'])
|
@app.route('/showSummary',methods=['POST'])
|
||||||
def showSummary():
|
def showSummary():
|
||||||
club = [club for club in clubs if club['email'] == request.form['email']][0]
|
club = [club for club in clubs if club['email'] == request.form['email']]
|
||||||
return render_template('welcome.html',club=club,competitions=competitions)
|
if club:
|
||||||
|
return render_template('welcome.html', club=club[0], competitions=competitions)
|
||||||
|
flash("The email isn't found")
|
||||||
|
return redirect(url_for('index'))
|
||||||
|
|
||||||
@app.route('/book/<competition>/<club>')
|
@app.route('/book/<competition>/<club>')
|
||||||
def book(competition,club):
|
def book(competition,club):
|
||||||
@@ -46,9 +48,17 @@ def purchasePlaces():
|
|||||||
competition = [c for c in competitions if c['name'] == request.form['competition']][0]
|
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]
|
club = [c for c in clubs if c['name'] == request.form['club']][0]
|
||||||
placesRequired = int(request.form['places'])
|
placesRequired = int(request.form['places'])
|
||||||
competition['numberOfPlaces'] = int(competition['numberOfPlaces'])-placesRequired
|
points = int(club['points'])
|
||||||
flash('Great-booking complete!')
|
if placesRequired <= points:
|
||||||
return render_template('welcome.html', club=club, competitions=competitions)
|
competition['numberOfPlaces'] = int(competition['numberOfPlaces']) - placesRequired
|
||||||
|
if competition['numberOfPlaces'] < 0:
|
||||||
|
competition['numberOfPlaces'] = 0
|
||||||
|
flash('Great-booking complete!')
|
||||||
|
else:
|
||||||
|
flash("You don't have enough points")
|
||||||
|
return render_template('welcome.html', club=club,
|
||||||
|
competitions=competitions)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# TODO: Add route for points display
|
# TODO: Add route for points display
|
||||||
@@ -56,4 +66,4 @@ def purchasePlaces():
|
|||||||
|
|
||||||
@app.route('/logout')
|
@app.route('/logout')
|
||||||
def logout():
|
def logout():
|
||||||
return redirect(url_for('index'))
|
return redirect(url_for('index'))
|
||||||
|
|||||||
@@ -6,6 +6,16 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Welcome to the GUDLFT Registration Portal!</h1>
|
<h1>Welcome to the GUDLFT Registration Portal!</h1>
|
||||||
|
{% with messages = get_flashed_messages()%}
|
||||||
|
{% if messages %}
|
||||||
|
<ul>
|
||||||
|
{% for message in messages %}
|
||||||
|
<li>{{message}}</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% endif%}
|
||||||
|
{% endwith %}
|
||||||
|
|
||||||
Please enter your secretary email to continue:
|
Please enter your secretary email to continue:
|
||||||
<form action="showSummary" method="post">
|
<form action="showSummary" method="post">
|
||||||
<label for="email">Email:</label>
|
<label for="email">Email:</label>
|
||||||
@@ -13,4 +23,4 @@
|
|||||||
<button type="submit">Enter</button>
|
<button type="submit">Enter</button>
|
||||||
</form>
|
</form>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user