manager: display computed period for partial bookings (#80842)
gitea/chrono/pipeline/head This commit looks good
Details
gitea/chrono/pipeline/head This commit looks good
Details
This commit is contained in:
parent
16e3602391
commit
2b288340b6
|
@ -686,12 +686,15 @@ div#appbar a.active {
|
|||
&.booking {
|
||||
--background: #1066bc;
|
||||
}
|
||||
&.check.present {
|
||||
&.check.present, &.computed.present {
|
||||
--background: hsl(120, 57%, 35%);
|
||||
}
|
||||
&.check.absent {
|
||||
&.check.absent, &.computed.absent {
|
||||
--background: hsl(355, 80%, 45%);
|
||||
}
|
||||
&.computed {
|
||||
opacity: 0.6;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,6 +71,20 @@
|
|||
{% if booking.user_check_type_label %}<span>{{ booking.user_check_type_label }}</span>{% endif %}
|
||||
</p>
|
||||
</div>
|
||||
{% if booking.computed_start_time != None and booking.computed_end_time != None %}
|
||||
<div class="registrant--bar-container">
|
||||
<p
|
||||
class="registrant--bar computed {{ booking.check_css_class }}"
|
||||
title="{% trans "Computed period" %}"
|
||||
style="left: {{ booking.computed_css_left }}%; width: {{ booking.computed_css_width }}%;"
|
||||
>
|
||||
<strong class="sr-only">{% trans "Computed period:" %}</strong>
|
||||
<time datetime="{{ booking.computed_start_time|time:"H:i" }}">{{ booking.computed_start_time|time:"H:i" }}</time>
|
||||
–
|
||||
<time datetime="{{ booking.computed_end_time|time:"H:i" }}">{{ booking.computed_end_time|time:"H:i" }}</time>
|
||||
</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
|
|
|
@ -1656,6 +1656,13 @@ class AgendaDayView(EventChecksMixin, AgendaDateView, DayArchiveView):
|
|||
booking.check_css_width = get_time_ratio(
|
||||
booking.user_check_end_time, booking.user_check_start_time
|
||||
)
|
||||
booking.computed_start_time = booking.get_computed_start_time()
|
||||
booking.computed_end_time = booking.get_computed_end_time()
|
||||
if booking.computed_start_time is not None and booking.computed_end_time is not None:
|
||||
booking.computed_css_left = get_time_ratio(booking.computed_start_time, start_time)
|
||||
booking.computed_css_width = get_time_ratio(
|
||||
booking.computed_end_time, booking.computed_start_time
|
||||
)
|
||||
|
||||
|
||||
agenda_day_view = AgendaDayView.as_view()
|
||||
|
|
|
@ -238,13 +238,21 @@ def test_manager_partial_bookings_check(check_types, app, admin_user):
|
|||
resp.form['user_was_present'] = 'True'
|
||||
resp = resp.form.submit().follow()
|
||||
|
||||
assert len(resp.pyquery('.registrant--bar')) == 2
|
||||
assert len(resp.pyquery('.registrant--bar')) == 3
|
||||
assert len(resp.pyquery('.registrant--bar.booking')) == 1
|
||||
assert len(resp.pyquery('.registrant--bar.check.present')) == 1
|
||||
assert resp.pyquery('.registrant--bar.check time')[0].text == '11:01'
|
||||
assert resp.pyquery('.registrant--bar.check time')[1].text == '13:15'
|
||||
assert resp.pyquery('.registrant--bar.check')[0].attrib['style'] == 'left: 30.9%; width: 17.18%;'
|
||||
assert resp.pyquery('.registrant--bar span').text() == ''
|
||||
assert len(resp.pyquery('.registrant--bar.computed.present')) == 1
|
||||
assert resp.pyquery('.registrant--bar.computed time')[0].text == '11:00'
|
||||
assert resp.pyquery('.registrant--bar.computed time')[1].text == '14:00'
|
||||
assert resp.pyquery('.registrant--bar.computed')[0].attrib['style'] == 'left: 30.77%; width: 23.08%;'
|
||||
|
||||
agenda.invoicing_unit = 'half_hour'
|
||||
agenda.invoicing_tolerance = 10
|
||||
agenda.save()
|
||||
|
||||
check_types.return_value = [
|
||||
CheckType(slug='foo-reason', label='Foo reason', kind='absence'),
|
||||
|
@ -264,13 +272,17 @@ def test_manager_partial_bookings_check(check_types, app, admin_user):
|
|||
resp.form['presence_check_type'] = 'bar-reason'
|
||||
resp = resp.form.submit().follow()
|
||||
|
||||
assert len(resp.pyquery('.registrant--bar')) == 2
|
||||
assert len(resp.pyquery('.registrant--bar')) == 3
|
||||
assert len(resp.pyquery('.registrant--bar.booking')) == 1
|
||||
assert len(resp.pyquery('.registrant--bar.check.present')) == 1
|
||||
assert resp.pyquery('.registrant--bar.check time')[0].text == '11:01'
|
||||
assert resp.pyquery('.registrant--bar.check time')[1].text == '13:15'
|
||||
assert resp.pyquery('.registrant--bar.check')[0].attrib['style'] == 'left: 30.9%; width: 17.18%;'
|
||||
assert resp.pyquery('.registrant--bar span').text() == 'Bar reason'
|
||||
assert len(resp.pyquery('.registrant--bar.computed.present')) == 1
|
||||
assert resp.pyquery('.registrant--bar.computed time')[0].text == '11:00'
|
||||
assert resp.pyquery('.registrant--bar.computed time')[1].text == '13:30'
|
||||
assert resp.pyquery('.registrant--bar.computed')[0].attrib['style'] == 'left: 30.77%; width: 19.23%;'
|
||||
|
||||
resp = resp.click('Jane Doe')
|
||||
assert resp.form['presence_check_type'].value == 'bar-reason'
|
||||
|
@ -278,9 +290,10 @@ def test_manager_partial_bookings_check(check_types, app, admin_user):
|
|||
resp.form['user_was_present'] = 'False'
|
||||
resp = resp.form.submit().follow()
|
||||
|
||||
assert len(resp.pyquery('.registrant--bar')) == 2
|
||||
assert len(resp.pyquery('.registrant--bar')) == 3
|
||||
assert len(resp.pyquery('.registrant--bar.booking')) == 1
|
||||
assert len(resp.pyquery('.registrant--bar.check.absent')) == 1
|
||||
assert len(resp.pyquery('.registrant--bar.computed.absent')) == 1
|
||||
assert resp.pyquery('.registrant--bar span').text() == ''
|
||||
|
||||
resp = resp.click('Jane Doe')
|
||||
|
|
Loading…
Reference in New Issue