manager: avoid crash in partial bookings month view if multiple checks (#82234)
gitea/chrono/pipeline/head This commit looks good Details

This commit is contained in:
Valentin Deniaud 2023-11-22 11:22:48 +01:00
parent 7182871b9f
commit faccc579c5
2 changed files with 11 additions and 2 deletions

View File

@ -1956,7 +1956,10 @@ class AgendaWeekMonthMixin:
)
user_bookings = booking_info['bookings']
if booking.user_check:
if len(booking.user_checks.all()) == 2:
# one of the checks must be presence, display it
booking.check_css_class = 'present'
elif booking.user_check:
booking.check_css_class = 'present' if booking.user_check.presence else 'absent'
user_bookings[localtime(booking.event.start_datetime).day - 1] = booking

View File

@ -1014,7 +1014,13 @@ def test_manager_partial_bookings_month_view(app, admin_user, freezer):
end_time=datetime.time(10, 00),
event=event,
)
booking.mark_user_presence(start_time=datetime.time(8, 00), end_time=datetime.time(10, 00))
booking.mark_user_presence(start_time=datetime.time(8, 00), end_time=datetime.time(9, 00))
BookingCheck.objects.create(
booking=booking,
start_time=datetime.time(9, 00),
end_time=datetime.time(10, 00),
presence=False, # second 'absence' check will be ignored
)
booking = Booking.objects.create(
user_external_id='user:3',
user_first_name='User',