Skip to content

Commit

Permalink
Bug fixing: Booking places in past competitions OpenClassrooms-Studen…
Browse files Browse the repository at this point in the history
  • Loading branch information
selaouni committed Dec 6, 2022
1 parent 41403fd commit 93b6f23
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion server.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import json
from flask import Flask, render_template, request, redirect, flash, url_for
from datetime import datetime



def loadClubs():
Expand Down Expand Up @@ -37,7 +39,10 @@ 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:
return render_template('booking.html',club=foundClub,competition=foundCompetition)
# if datetime.strptime(competition['date'], '%Y-%m-%d %H:%M:%S') < datetime.now():
# return flash("You cannot book places in a past competition")
# else:
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)
Expand Down

0 comments on commit 93b6f23

Please sign in to comment.