Compare commits
No commits in common. "feature/issue7" and "main" have entirely different histories.
feature/is
...
main
@ -7,7 +7,7 @@
|
||||
{
|
||||
"name":"Iron Temple",
|
||||
"email": "admin@irontemple.com",
|
||||
"points":"47"
|
||||
"points":"4"
|
||||
},
|
||||
{ "name":"She Lifts",
|
||||
"email": "kate@shelifts.co.uk",
|
||||
|
57
server.py
57
server.py
@ -1,6 +1,5 @@
|
||||
import json
|
||||
from flask import Flask,render_template,request,redirect,flash,url_for,session
|
||||
from datetime import datetime
|
||||
from flask import Flask,render_template,request,redirect,flash,url_for
|
||||
|
||||
|
||||
def loadClubs():
|
||||
@ -20,8 +19,6 @@ app.secret_key = 'something_special'
|
||||
|
||||
competitions = loadCompetitions()
|
||||
clubs = loadClubs()
|
||||
now = datetime.strftime(datetime.now(), "%Y-%m-%d %H:%M:%S")
|
||||
|
||||
|
||||
@app.route('/')
|
||||
def index():
|
||||
@ -29,26 +26,19 @@ def index():
|
||||
|
||||
@app.route('/showSummary',methods=['POST'])
|
||||
def showSummary():
|
||||
club = [club for club in clubs if club['email'] == request.form['email']]
|
||||
if club:
|
||||
return render_template('welcome.html', club=club[0], competitions=competitions, now=now)
|
||||
flash("The email isn't found")
|
||||
return redirect(url_for('index'))
|
||||
club = [club for club in clubs if club['email'] == request.form['email']][0]
|
||||
return render_template('welcome.html',club=club,competitions=competitions)
|
||||
|
||||
|
||||
@app.route('/book/<competition>/<club>')
|
||||
def book(competition,club):
|
||||
foundClub = [c for c in clubs if c['name'] == club][0]
|
||||
foundCompetition = [c for c in competitions if c['name'] == competition][0]
|
||||
if foundClub and foundCompetition:
|
||||
if foundCompetition['date'] > now:
|
||||
return render_template('booking.html',club=foundClub,competition=foundCompetition)
|
||||
else:
|
||||
flash("You cannot book for a past competition")
|
||||
return render_template('welcome.html', club=foundClub,
|
||||
competitions=competitions, now=now)
|
||||
return render_template('booking.html',club=foundClub,competition=foundCompetition)
|
||||
else:
|
||||
flash("Something went wrong-please try again")
|
||||
return render_template('welcome.html', club=club, competitions=competitions, now=now)
|
||||
return render_template('welcome.html', club=club, competitions=competitions)
|
||||
|
||||
|
||||
@app.route('/purchasePlaces',methods=['POST'])
|
||||
@ -56,37 +46,14 @@ 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'])
|
||||
if competition['name'] in session:
|
||||
places = {competition['name']: session[competition['name']] + placesRequired}
|
||||
else:
|
||||
places = {competition['name']: placesRequired}
|
||||
points = int(club['points'])
|
||||
if placesRequired <= 12:
|
||||
if places[competition['name']] <= 12:
|
||||
if placesRequired <= points:
|
||||
competition['numberOfPlaces'] = int(competition['numberOfPlaces']) - placesRequired
|
||||
club['points'] = int(club['points']) - placesRequired
|
||||
print(club['points'])
|
||||
if not competition['name'] in session:
|
||||
session[competition['name']] = placesRequired
|
||||
flash(f"Great ! {placesRequired} places booked for {competition['name']}")
|
||||
else:
|
||||
flash("You don't have enough points")
|
||||
else:
|
||||
flash(f"You already booked 12 places for {competition['name']}")
|
||||
else:
|
||||
flash("You can't book more than 12 places")
|
||||
return render_template('welcome.html', club=club,
|
||||
competitions=competitions, now=now)
|
||||
competition['numberOfPlaces'] = int(competition['numberOfPlaces'])-placesRequired
|
||||
flash('Great-booking complete!')
|
||||
return render_template('welcome.html', club=club, competitions=competitions)
|
||||
|
||||
|
||||
# TODO: Add route for points display
|
||||
@app.route('/points')
|
||||
def displayPoints():
|
||||
return render_template('points.html', clubs=clubs)
|
||||
|
||||
|
||||
@app.route('/logout')
|
||||
def logout():
|
||||
return redirect(url_for('index'))
|
||||
|
||||
if (__name__ == "__main__"):
|
||||
app.run(debug=True)
|
||||
return redirect(url_for('index'))
|
@ -6,22 +6,11 @@
|
||||
</head>
|
||||
<body>
|
||||
<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:
|
||||
<form action="showSummary" method="post">
|
||||
<label for="email">Email:</label>
|
||||
<input type="email" name="email" id=""/>
|
||||
<button type="submit">Enter</button>
|
||||
</form>
|
||||
<a href="{{ url_for('displayPoints') }}">Board of points</a>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
@ -1,18 +0,0 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Board of clubs and points || GUDLFT</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Current points</h2>
|
||||
<ul>
|
||||
{% for club in clubs %}
|
||||
<li><strong>club : </strong> {{club['name']}} </br>
|
||||
<strong>Points : </strong>{{club['points']}}</br>
|
||||
</br>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<a href="{{ url_for('index') }}"> Back </a>
|
||||
</body>
|
||||
</html>
|
@ -10,10 +10,10 @@
|
||||
{% with messages = get_flashed_messages()%}
|
||||
{% if messages %}
|
||||
<ul>
|
||||
{% for message in messages %}
|
||||
{% for message in messages %}
|
||||
<li>{{message}}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</ul>
|
||||
{% endif%}
|
||||
Points available: {{club['points']}}
|
||||
<h3>Competitions:</h3>
|
||||
@ -23,7 +23,7 @@
|
||||
{{comp['name']}}<br />
|
||||
Date: {{comp['date']}}</br>
|
||||
Number of Places: {{comp['numberOfPlaces']}}
|
||||
{%if comp['numberOfPlaces']|int >0 and comp['date'] > now%}
|
||||
{%if comp['numberOfPlaces']|int >0%}
|
||||
<a href="{{ url_for('book',competition=comp['name'],club=club['name']) }}">Book Places</a>
|
||||
{%endif%}
|
||||
</li>
|
||||
|
Loading…
x
Reference in New Issue
Block a user