manager: handle only one partial booking by user (#78081)
This commit is contained in:
parent
e6b5ace001
commit
beb31a38ca
|
@ -16,24 +16,22 @@
|
|||
</div>
|
||||
|
||||
<div class="partial-booking--registrant-items">
|
||||
{% for user, bookings in bookings_by_user.items %}
|
||||
{% for booking in bookings %}
|
||||
<section class="partial-booking--registrant">
|
||||
<h3 class="registrant--name">{{ bookings.0.get_user_block }}</h3>
|
||||
<h3 class="registrant--name">{{ booking.get_user_block }}</h3>
|
||||
<div class="registrant--datas">
|
||||
{% for booking in bookings %}
|
||||
<div class="registrant--bar-container">
|
||||
<p
|
||||
class="registrant--bar booking"
|
||||
title="{% trans "Booked period" %}"
|
||||
style="left: {{ booking.css_left }}%; width: {{ booking.css_width }}%;"
|
||||
>
|
||||
<strong class="sr-only">{% trans "Booked period:" %}</strong>
|
||||
<time datetime="{{ booking.start_time|time:"H:i" }}">{{ booking.start_time|time:"H:i" }}</time>
|
||||
–
|
||||
<time datetime="{{ booking.end_time|time:"H:i" }}">{{ booking.end_time|time:"H:i" }}</time>
|
||||
</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
<div class="registrant--bar-container">
|
||||
<p
|
||||
class="registrant--bar booking"
|
||||
title="{% trans "Booked period" %}"
|
||||
style="left: {{ booking.css_left }}%; width: {{ booking.css_width }}%;"
|
||||
>
|
||||
<strong class="sr-only">{% trans "Booked period:" %}</strong>
|
||||
<time datetime="{{ booking.start_time|time:"H:i" }}">{{ booking.start_time|time:"H:i" }}</time>
|
||||
–
|
||||
<time datetime="{{ booking.end_time|time:"H:i" }}">{{ booking.end_time|time:"H:i" }}</time>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
|
|
@ -1518,13 +1518,10 @@ class AgendaDayView(AgendaDateView, DayArchiveView):
|
|||
round(100 * ((t1.hour - t2.hour) * 60 + t1.minute - t2.minute) / opening_range_minutes, 2)
|
||||
)
|
||||
|
||||
bookings_by_user = collections.defaultdict(list)
|
||||
for booking in event.booking_set.all():
|
||||
context['bookings'] = list(event.booking_set.all())
|
||||
for booking in context['bookings']:
|
||||
booking.css_left = get_time_ratio(booking.start_time, start_time)
|
||||
booking.css_width = get_time_ratio(booking.end_time, booking.start_time)
|
||||
bookings_by_user[booking.user_external_id].append(booking)
|
||||
|
||||
context['bookings_by_user'] = dict(bookings_by_user)
|
||||
|
||||
|
||||
agenda_day_view = AgendaDayView.as_view()
|
||||
|
|
|
@ -89,8 +89,8 @@ def test_manager_partial_bookings_day_view(app, admin_user, freezer):
|
|||
event=event,
|
||||
)
|
||||
Booking.objects.create(
|
||||
user_external_id='yyy',
|
||||
user_first_name='Jon',
|
||||
user_external_id='zzz',
|
||||
user_first_name='Bruce',
|
||||
user_last_name='Doe',
|
||||
start_time=datetime.time(12, 00),
|
||||
end_time=datetime.time(14, 00),
|
||||
|
@ -110,9 +110,10 @@ def test_manager_partial_bookings_day_view(app, admin_user, freezer):
|
|||
range(7, 20)
|
||||
)
|
||||
|
||||
assert len(resp.pyquery('.partial-booking--registrant')) == 2
|
||||
assert len(resp.pyquery('.partial-booking--registrant')) == 3
|
||||
assert resp.pyquery('.registrant--name')[0].text == 'Jane Doe'
|
||||
assert resp.pyquery('.registrant--name')[1].text == 'Jon Doe'
|
||||
assert resp.pyquery('.registrant--name')[2].text == 'Bruce Doe'
|
||||
|
||||
assert resp.pyquery('.registrant--bar')[0].findall('time')[0].text == '11:00'
|
||||
assert resp.pyquery('.registrant--bar')[0].findall('time')[1].text == '13:30'
|
||||
|
|
Loading…
Reference in New Issue