régler problème ou on ne voyait pas les dates pour book un One on One
This commit is contained in:
+28
-3
@@ -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)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user