manager: allow more precise time check for partial bookings (#80046)
gitea/chrono/pipeline/head Build queued... Details

This commit is contained in:
Valentin Deniaud 2023-07-27 15:06:20 +02:00
parent 6b964d708b
commit a70045ea5b
3 changed files with 7 additions and 6 deletions

View File

@ -597,8 +597,8 @@ class PartialBookingCheckForm(forms.ModelForm):
model = Booking
fields = ['user_check_start_time', 'user_check_end_time', 'user_was_present']
widgets = {
'user_check_start_time': widgets.TimeWidget(),
'user_check_end_time': widgets.TimeWidget(),
'user_check_start_time': widgets.TimeWidget(step=60),
'user_check_end_time': widgets.TimeWidget(step=60),
}
def __init__(self, *args, **kwargs):

View File

@ -57,9 +57,10 @@ class TimeWidget(TimeInput):
input_type = 'time'
def __init__(self, **kwargs):
step = kwargs.pop('step', 300) # 5 minutes by default
kwargs['format'] = '%H:%M'
super().__init__(**kwargs)
self.attrs['step'] = '300' # 5 minutes
self.attrs['step'] = step
self.attrs['pattern'] = '[0-9]{2}:[0-9]{2}'

View File

@ -192,7 +192,7 @@ def test_manager_partial_bookings_check(check_types, app, admin_user):
('foo-reason', False, 'Foo reason'),
]
resp.form['user_check_start_time'] = '11:00'
resp.form['user_check_start_time'] = '11:01'
resp.form['user_check_end_time'] = '13:15'
resp.form['user_was_present'] = 'True'
resp.form['presence_check_type'] = 'bar-reason'
@ -201,9 +201,9 @@ def test_manager_partial_bookings_check(check_types, app, admin_user):
assert len(resp.pyquery('.registrant--bar')) == 2
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:00'
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.77%; width: 17.31%;'
assert resp.pyquery('.registrant--bar.check')[0].attrib['style'] == 'left: 30.9%; width: 17.18%;'
assert resp.pyquery('.registrant--bar span').text() == 'Bar reason'
resp = resp.click('Jane Doe')