manager: forbid checking arrival after departure for partial bookings (#81619)
gitea/chrono/pipeline/head This commit looks good
Details
gitea/chrono/pipeline/head This commit looks good
Details
This commit is contained in:
parent
ec86a9bbcc
commit
33e53a694a
|
@ -634,6 +634,9 @@ class PartialBookingCheckForm(forms.ModelForm):
|
|||
self.fields.pop('absence_check_type', None)
|
||||
|
||||
def clean(self):
|
||||
if self.cleaned_data['user_check_end_time'] <= self.cleaned_data['user_check_start_time']:
|
||||
raise ValidationError(_('Arrival must be before departure.'))
|
||||
|
||||
if self.cleaned_data['user_was_present'] is not None:
|
||||
kind = 'presence' if self.cleaned_data['user_was_present'] else 'absence'
|
||||
if f'{kind}_check_type' in self.cleaned_data:
|
||||
|
|
|
@ -273,6 +273,13 @@ def test_manager_partial_bookings_check(check_types, app, admin_user):
|
|||
assert resp.pyquery('.time-widget-button')[0].text == 'Fill with booking start time'
|
||||
assert resp.pyquery('.time-widget-button')[1].text == 'Fill with booking end time'
|
||||
|
||||
resp.form['user_check_start_time'] = '11:01'
|
||||
resp.form['user_check_end_time'] = '11:00'
|
||||
resp.form['user_was_present'] = 'True'
|
||||
resp = resp.form.submit()
|
||||
|
||||
assert 'Arrival must be before departure.' in resp.text
|
||||
|
||||
resp.form['user_check_start_time'] = '11:01'
|
||||
resp.form['user_check_end_time'] = '13:15'
|
||||
resp.form['user_was_present'] = 'True'
|
||||
|
|
Loading…
Reference in New Issue