past comp is displayed; condition on link and route

This commit is contained in:
yann 2025-06-26 11:26:57 +02:00
parent 0345e8e8df
commit 364bdb3d9f
2 changed files with 11 additions and 6 deletions

View File

@ -28,10 +28,9 @@ def index():
@app.route('/showSummary',methods=['POST'])
def showSummary():
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()]
print(current_compet)
now = datetime.strftime(datetime.now(), "%Y-%m-%d %H:%M:%S")
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")
return redirect(url_for('index'))
@ -39,8 +38,14 @@ def showSummary():
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]
now = datetime.strftime(datetime.now(), "%Y-%m-%d %H:%M:%S")
if foundClub and 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:
flash("Something went wrong-please try again")
return render_template('welcome.html', club=club, competitions=competitions)

View File

@ -23,11 +23,11 @@
{{comp['name']}}<br />
Date: {{comp['date']}}</br>
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>
{%endif%}
</li>
<hr />jinja
<hr />
{% endfor %}
</ul>
{%endwith%}