Skip to content

Bug/max 12 places per comp #300

New issue

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

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

Already on GitHub? Sign in to your account

Open
wants to merge 5 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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ lib
.Python
tests/
.envrc
__pycache__
__pycache__
venv/
23 changes: 18 additions & 5 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ 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)

found_clubs = [club for club in clubs if club['email'] == request.form['email']]
if found_clubs:
club = found_clubs[0]
return render_template('welcome.html',club=club,competitions=competitions)
else:
flash("Sorry, that email was not found.")
return redirect(url_for('index'))

@app.route('/book/<competition>/<club>')
def book(competition,club):
Expand All @@ -46,11 +50,20 @@ 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!')
if placesRequired > 12:
flash("You cannot book more than 12 places per competition.")
return render_template('welcome.html', club=club, competitions=competitions)
if int(club['points']) >= placesRequired:
competition['numberOfPlaces'] = int(competition['numberOfPlaces'])-placesRequired
club['points'] = str(int(club['points']) - placesRequired)
flash('Great-booking complete!')
else:
flash(f"You do not have enough points to book {placesRequired} places. You currently have {club['points']} points.")

return render_template('welcome.html', club=club, competitions=competitions)



# TODO: Add route for points display


Expand Down
12 changes: 12 additions & 0 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@
</head>
<body>
<h1>Welcome to the GUDLFT Registration Portal!</h1>

{# Add this block to display flashed messages #}
{% 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:
<form action="showSummary" method="post">
<label for="email">Email:</label>
Expand Down