manager: allow editing event recurrence (#52112)
This commit is contained in:
parent
f792b808c1
commit
1294566ad8
|
@ -214,6 +214,9 @@ class EventForm(forms.ModelForm):
|
|||
self.fields[field].help_text = _(
|
||||
'This field cannot be modified because some recurrences have bookings attached to them.'
|
||||
)
|
||||
if self.instance.primary_event:
|
||||
for field in ('slug', 'repeat', 'recurrence_end_date', 'publication_date'):
|
||||
del self.fields[field]
|
||||
|
||||
def clean(self):
|
||||
super().clean()
|
||||
|
@ -221,7 +224,7 @@ class EventForm(forms.ModelForm):
|
|||
after=self.cleaned_data['recurrence_end_date']
|
||||
):
|
||||
raise ValidationError(_('Bookings exist after this date.'))
|
||||
if self.cleaned_data['recurrence_end_date'] and not self.cleaned_data['repeat']:
|
||||
if self.cleaned_data.get('recurrence_end_date') and not self.cleaned_data.get('repeat'):
|
||||
raise ValidationError(_('Recurrence end date makes no sense without repetition.'))
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
|
|
|
@ -35,10 +35,8 @@
|
|||
{% if not event.cancellation_status %}
|
||||
<a rel="popup" href="{% url 'chrono-manager-event-cancel' pk=agenda.pk event_pk=event.pk %}?next={{ request.path }}">{% trans "Cancel" %}</a>
|
||||
{% endif %}
|
||||
{% if not object.primary_event %}
|
||||
<a href="{% url 'chrono-manager-event-edit' pk=agenda.id event_pk=object.id %}">{% trans "Options" %}</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if object.agenda.booking_form_url %}
|
||||
<a href="{{ object.agenda.get_booking_form_url }}?agenda={{ object.agenda.slug }}&event={{ event.slug }}">{% trans "Booking form" %}</a>
|
||||
{% endif %}
|
||||
|
|
|
@ -1586,12 +1586,13 @@ def test_edit_recurring_event(settings, app, admin_user, freezer):
|
|||
resp = resp.form.submit()
|
||||
assert not Event.objects.filter(slug='changed').exists()
|
||||
|
||||
# individually editing event recurrence is not supported, except for cancellation
|
||||
# deletion of event recurrence is not allowed
|
||||
resp = app.get('/manage/agendas/%s/events/%s/' % (agenda.id, event_recurrence.id))
|
||||
assert 'Cancel' in resp.text
|
||||
assert 'Options' not in resp.text
|
||||
assert 'Delete' not in resp.text
|
||||
|
||||
resp = resp.click('Options')
|
||||
assert {'slug', 'repeat', 'recurrence_end_date', 'publication_date'}.isdisjoint(resp.form.fields)
|
||||
|
||||
|
||||
def test_edit_recurring_event_with_end_date(settings, app, admin_user, freezer):
|
||||
freezer.move_to('2021-01-12 12:10')
|
||||
|
@ -4102,7 +4103,7 @@ def test_agenda_events_month_view(app, admin_user):
|
|||
# trying to access event recurrence creates it
|
||||
event_count = Event.objects.count()
|
||||
time = localtime(event.start_datetime).strftime('%H%M')
|
||||
resp = resp.click(href='abc:2020-12-02-%s' % time)
|
||||
resp = resp.click(href='abc:2020-12-02-%s' % time).follow()
|
||||
assert Event.objects.count() == event_count + 1
|
||||
|
||||
resp = app.get('/manage/agendas/%s/%s/%s/' % (agenda.id, 2020, 12))
|
||||
|
@ -4117,6 +4118,15 @@ def test_agenda_events_month_view(app, admin_user):
|
|||
# the event occurence in DB does not hide recurrence of the second recurrent event
|
||||
assert len(resp.pyquery.find('.event-info')) == 10
|
||||
|
||||
resp = resp.click(href='abc:2020-12-09-%s' % time).follow()
|
||||
resp = resp.click('Options')
|
||||
resp.form['start_datetime_1'] = '13:12'
|
||||
resp = resp.form.submit(status=302).follow()
|
||||
|
||||
resp = app.get('/manage/agendas/%s/%s/%s/' % (agenda.id, 2020, 12))
|
||||
assert len(resp.pyquery.find('.event-info')) == 10
|
||||
assert '1:12 p.m.' in resp.text
|
||||
|
||||
Event.objects.get(slug='abc--2020-12-02-%s' % time).cancel()
|
||||
resp = app.get('/manage/agendas/%s/%s/%s/' % (agenda.id, 2020, 12))
|
||||
assert 'Cancelled' in resp.text
|
||||
|
|
Loading…
Reference in New Issue