0001-manager-don-t-crash-on-empty-time-period-exception-d.patch
chrono/agendas/models.py | ||
---|---|---|
542 | 542 |
raise ValidationError(_('One or several bookings exists within this time slot.')) |
543 | 543 | |
544 | 544 |
def has_booking_within_time_slot(self): |
545 |
if not (self.start_datetime and self.end_datetime): |
|
546 |
# incomplete time period, can't tell |
|
547 |
return False |
|
545 | 548 |
for event in Event.objects.filter(agenda=self.desk.agenda, |
546 | 549 |
booking__isnull=False, |
547 | 550 |
booking__cancellation_datetime__isnull=True): |
tests/test_manager.py | ||
---|---|---|
796 | 796 |
resp = app.get('/manage/agendas/%d/' % agenda.pk).follow() |
797 | 797 |
resp = resp.click('Settings') |
798 | 798 |
resp = resp.click('Add a time period exception') |
799 |
resp = resp.form.submit() # submit empty form |
|
800 |
# fields should be marked with errors |
|
801 |
assert resp.body.count('This field is required.') == 2 |
|
802 |
# try again with data in fields |
|
799 | 803 |
resp.form['start_datetime'] = '2017-05-22 08:00' |
800 | 804 |
resp.form['end_datetime'] = '2017-05-26 17:30' |
801 | 805 |
resp = resp.form.submit() |
802 |
- |