past comp is displayed; condition on link and route
This commit is contained in:
parent
0345e8e8df
commit
364bdb3d9f
13
server.py
13
server.py
@ -28,10 +28,9 @@ 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']]
|
||||||
current_compet = [compet for compet in competitions if datetime.strptime(compet['date'], '%Y-%m-%d %H:%M:%S') > datetime.now()]
|
now = datetime.strftime(datetime.now(), "%Y-%m-%d %H:%M:%S")
|
||||||
print(current_compet)
|
|
||||||
if club:
|
if club:
|
||||||
return render_template('welcome.html', club=club[0], competitions=current_compet)
|
return render_template('welcome.html', club=club[0], competitions=competitions, now=now)
|
||||||
flash("The email isn't found")
|
flash("The email isn't found")
|
||||||
return redirect(url_for('index'))
|
return redirect(url_for('index'))
|
||||||
|
|
||||||
@ -39,8 +38,14 @@ 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:
|
||||||
return render_template('booking.html',club=foundClub,competition=foundCompetition)
|
if competition['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=club,
|
||||||
|
competitions=competitions)
|
||||||
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)
|
||||||
|
@ -23,11 +23,11 @@
|
|||||||
{{comp['name']}}<br />
|
{{comp['name']}}<br />
|
||||||
Date: {{comp['date']}}</br>
|
Date: {{comp['date']}}</br>
|
||||||
Number of Places: {{comp['numberOfPlaces']}}
|
Number of Places: {{comp['numberOfPlaces']}}
|
||||||
{%if comp['numberOfPlaces']|int >0%}
|
{%if comp['numberOfPlaces']|int >0 and comp['date'] > now%}
|
||||||
<a href="{{ url_for('book',competition=comp['name'],club=club['name']) }}">Book Places</a>
|
<a href="{{ url_for('book',competition=comp['name'],club=club['name']) }}">Book Places</a>
|
||||||
{%endif%}
|
{%endif%}
|
||||||
</li>
|
</li>
|
||||||
<hr />jinja
|
<hr />
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{%endwith%}
|
{%endwith%}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user