added now to every welcome template call
This commit is contained in:
parent
364bdb3d9f
commit
7521a05db9
14
server.py
14
server.py
@ -20,6 +20,8 @@ app.secret_key = 'something_special'
|
|||||||
|
|
||||||
competitions = loadCompetitions()
|
competitions = loadCompetitions()
|
||||||
clubs = loadClubs()
|
clubs = loadClubs()
|
||||||
|
now = datetime.strftime(datetime.now(), "%Y-%m-%d %H:%M:%S")
|
||||||
|
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def index():
|
def index():
|
||||||
@ -28,7 +30,6 @@ 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']]
|
club = [club for club in clubs if club['email'] == request.form['email']]
|
||||||
now = datetime.strftime(datetime.now(), "%Y-%m-%d %H:%M:%S")
|
|
||||||
if club:
|
if club:
|
||||||
return render_template('welcome.html', club=club[0], competitions=competitions, now=now)
|
return render_template('welcome.html', club=club[0], competitions=competitions, now=now)
|
||||||
flash("The email isn't found")
|
flash("The email isn't found")
|
||||||
@ -38,17 +39,16 @@ def showSummary():
|
|||||||
def book(competition,club):
|
def book(competition,club):
|
||||||
foundClub = [c for c in clubs if c['name'] == club][0]
|
foundClub = [c for c in clubs if c['name'] == club][0]
|
||||||
foundCompetition = [c for c in competitions if c['name'] == competition][0]
|
foundCompetition = [c for c in competitions if c['name'] == competition][0]
|
||||||
now = datetime.strftime(datetime.now(), "%Y-%m-%d %H:%M:%S")
|
|
||||||
if foundClub and foundCompetition:
|
if foundClub and foundCompetition:
|
||||||
if competition['date'] > now:
|
if foundCompetition['date'] > now:
|
||||||
return render_template('booking.html',club=foundClub,competition=foundCompetition)
|
return render_template('booking.html',club=foundClub,competition=foundCompetition)
|
||||||
else:
|
else:
|
||||||
flash("You cannot book for a past competition")
|
flash("You cannot book for a past competition")
|
||||||
return render_template('welcome.html', club=club,
|
return render_template('welcome.html', club=club,
|
||||||
competitions=competitions)
|
competitions=competitions, now=now)
|
||||||
else:
|
else:
|
||||||
flash("Something went wrong-please try again")
|
flash("Something went wrong-please try again")
|
||||||
return render_template('welcome.html', club=club, competitions=competitions)
|
return render_template('welcome.html', club=club, competitions=competitions, now=now)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/purchasePlaces',methods=['POST'])
|
@app.route('/purchasePlaces',methods=['POST'])
|
||||||
@ -69,7 +69,7 @@ def purchasePlaces():
|
|||||||
club['points'] = int(club['points']) - placesRequired
|
club['points'] = int(club['points']) - placesRequired
|
||||||
if not competition['name'] in session:
|
if not competition['name'] in session:
|
||||||
session[competition['name']] = placesRequired
|
session[competition['name']] = placesRequired
|
||||||
flash('Great-booking complete!')
|
flash(f"Great ! {placesRequired} places booked for {competition['name']}")
|
||||||
else:
|
else:
|
||||||
flash("You don't have enough points")
|
flash("You don't have enough points")
|
||||||
else:
|
else:
|
||||||
@ -77,7 +77,7 @@ def purchasePlaces():
|
|||||||
else:
|
else:
|
||||||
flash("You can't book more than 12 places")
|
flash("You can't book more than 12 places")
|
||||||
return render_template('welcome.html', club=club,
|
return render_template('welcome.html', club=club,
|
||||||
competitions=competitions)
|
competitions=competitions, now=now)
|
||||||
|
|
||||||
# TODO: Add route for points display
|
# TODO: Add route for points display
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user