manager: fix exception form with error (#47983)

This commit is contained in:
Lauréline Guérin 2020-10-23 14:40:45 +02:00
parent c1d5eb32ee
commit 374af4e1e2
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
2 changed files with 9 additions and 2 deletions

View File

@ -1914,8 +1914,8 @@ class TimePeriodExceptionEditView(ManagedTimePeriodExceptionMixin, UpdateView):
model = TimePeriodException
form_class = TimePeriodExceptionForm
def get_context_data(self):
context = super().get_context_data()
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
if self.desk:
context['cancel_url'] = reverse(
'chrono-manager-agenda-settings', kwargs={'pk': self.desk.agenda.pk}

View File

@ -4645,6 +4645,13 @@ def test_unavailability_calendar_edit_time_period_exeptions(app, admin_user):
time_period_exception.refresh_from_db()
assert 'Exception foo' == time_period_exception.label
# with an error
resp = app.get('/manage/time-period-exceptions/%s/edit' % time_period_exception.pk)
resp.form['start_datetime_0'] = now().strftime('%Y-%m-%d')
resp.form['end_datetime_0'] = now().strftime('%Y-%m-%d')
resp = resp.form.submit()
assert '<ul class="errorlist">' in resp.text
def test_unavailability_calendar_delete_time_period_exeptions(app, admin_user):
unavailability_calendar = UnavailabilityCalendar.objects.create(label='Foo')