From 962e621feeed3d0caaf228243e2aad0334e94bd1 Mon Sep 17 00:00:00 2001 From: cedrick2711 Date: Wed, 29 Jul 2026 17:17:11 -0400 Subject: [PATCH] =?UTF-8?q?r=C3=A9gler=20probl=C3=A8me=20ou=20on=20ne=20vo?= =?UTF-8?q?yait=20pas=20les=20dates=20pour=20book=20un=20One=20on=20One?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/routes/users.py | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/app/routes/users.py b/app/routes/users.py index a2dfd33..d94e29c 100644 --- a/app/routes/users.py +++ b/app/routes/users.py @@ -709,7 +709,15 @@ def one_on_one(): coach_availability = [] if coach: - coach_availability = CoachAvailability.query.filter_by(coach_id=coach.id).all() + availabilities = CoachAvailability.query.filter_by(coach_id=coach.id).all() + coach_availability = [ + { + 'day_of_week': av.day_of_week, + 'start_time': av.start_time.strftime('%H:%M'), + 'end_time': av.end_time.strftime('%H:%M'), + } + for av in availabilities + ] if request.method == 'POST': date_str = request.form.get('date') @@ -733,7 +741,9 @@ def one_on_one(): day_of_week = check_date.weekday() is_available = any( - av.day_of_week == day_of_week and av.start_time <= start_time and av.end_time >= end_time + av['day_of_week'] == day_of_week + and av['start_time'] <= start_time_str + and av['end_time'] >= end_time_str for av in coach_availability ) @@ -764,10 +774,25 @@ def one_on_one(): flash('Your One on One request has been submitted!', 'success') return redirect(url_for('users.one_on_one')) + # Build list of upcoming dates that have coach availability + from datetime import date as date_cls, timedelta as td + today = date_cls.today() + available_days = {av['day_of_week'] for av in coach_availability} + dates = [] + for i in range(14): # Next 14 days + d = today + td(days=i) + if d.weekday() in available_days: + dates.append({ + 'value': d.strftime('%Y-%m-%d'), + 'day_of_week': d.weekday(), + 'display': d.strftime('%B %d, %Y (%A)'), + }) + return render_template('pages/one_on_one.html', org_team=org_team, coach=coach, team_notes=team_notes, personal_notes=personal_notes, - coach_availability=coach_availability) + coach_availability=coach_availability, + dates=dates) # ---------------------------------------------------------------------------