0002-manager-allow-editing-event-recurrence-51778.patch
chrono/manager/forms.py | ||
---|---|---|
211 | 211 |
self.fields[field].help_text = _( |
212 | 212 |
'This field cannot be modified because some recurrences have bookings attached to them.' |
213 | 213 |
) |
214 |
if self.instance.primary_event: |
|
215 |
for field in ('slug', 'repeat', 'recurrence_end_date', 'publication_date'): |
|
216 |
del self.fields[field] |
|
214 | 217 | |
215 | 218 |
def clean(self): |
216 | 219 |
super().clean() |
... | ... | |
218 | 221 |
after=self.cleaned_data['recurrence_end_date'] |
219 | 222 |
): |
220 | 223 |
raise ValidationError(_('Bookings exist after this date.')) |
221 |
if self.cleaned_data['recurrence_end_date'] and not self.cleaned_data['repeat']:
|
|
224 |
if self.cleaned_data.get('recurrence_end_date') and not self.cleaned_data.get('repeat'):
|
|
222 | 225 |
raise ValidationError(_('Recurrence end date makes no sense without repetition.')) |
223 | 226 | |
224 | 227 |
def save(self, *args, **kwargs): |
chrono/manager/templates/chrono/manager_event_detail.html | ||
---|---|---|
35 | 35 |
{% if not event.cancellation_status %} |
36 | 36 |
<a rel="popup" href="{% url 'chrono-manager-event-cancel' pk=agenda.pk event_pk=event.pk %}?next={{ request.path }}">{% trans "Cancel" %}</a> |
37 | 37 |
{% endif %} |
38 |
{% if not object.primary_event %} |
|
39 | 38 |
<a href="{% url 'chrono-manager-event-edit' pk=agenda.id event_pk=object.id %}">{% trans "Options" %}</a> |
40 | 39 |
{% endif %} |
41 |
{% endif %} |
|
42 | 40 |
{% if object.agenda.booking_form_url %} |
43 | 41 |
<a href="{{ object.agenda.get_booking_form_url }}?agenda={{ object.agenda.slug }}&event={{ event.slug }}">{% trans "Booking form" %}</a> |
44 | 42 |
{% endif %} |
tests/test_manager.py | ||
---|---|---|
1515 | 1515 |
resp = resp.form.submit() |
1516 | 1516 |
assert not Event.objects.filter(slug='changed').exists() |
1517 | 1517 | |
1518 |
# individually editing event recurrence is not supported, except for cancellation
|
|
1518 |
# deletion of event recurrence is not allowed
|
|
1519 | 1519 |
resp = app.get('/manage/agendas/%s/events/%s/' % (agenda.id, event_recurrence.id)) |
1520 |
assert 'Cancel' in resp.text |
|
1521 |
assert 'Options' not in resp.text |
|
1522 | 1520 |
assert 'Delete' not in resp.text |
1523 | 1521 | |
1522 |
resp = resp.click('Options') |
|
1523 |
assert {'slug', 'repeat', 'recurrence_end_date', 'publication_date'}.isdisjoint(resp.form.fields) |
|
1524 | ||
1524 | 1525 | |
1525 | 1526 |
def test_edit_recurring_event_with_end_date(settings, app, admin_user, freezer): |
1526 | 1527 |
freezer.move_to('2021-01-12 12:10') |
... | ... | |
3967 | 3968 |
# trying to access event recurrence creates it |
3968 | 3969 |
event_count = Event.objects.count() |
3969 | 3970 |
time = localtime(event.start_datetime).strftime('%H%M') |
3970 |
resp = resp.click(href='abc:2020-12-02-%s' % time) |
|
3971 |
resp = resp.click(href='abc:2020-12-02-%s' % time).follow()
|
|
3971 | 3972 |
assert Event.objects.count() == event_count + 1 |
3972 | 3973 | |
3973 | 3974 |
resp = app.get('/manage/agendas/%s/%s/%s/' % (agenda.id, 2020, 12)) |
... | ... | |
3982 | 3983 |
# the event occurence in DB does not hide recurrence of the second recurrent event |
3983 | 3984 |
assert len(resp.pyquery.find('.event-info')) == 10 |
3984 | 3985 | |
3986 |
resp = resp.click('Options') |
|
3987 |
resp.form['start_datetime_1'] = '13:12' |
|
3988 |
resp = resp.form.submit(status=302).follow() |
|
3989 | ||
3990 |
resp = app.get('/manage/agendas/%s/%s/%s/' % (agenda.id, 2020, 12)) |
|
3991 |
assert len(resp.pyquery.find('.event-info')) == 5 |
|
3992 |
assert '1:12 p.m.' in resp.text |
|
3993 | ||
3985 | 3994 |
Event.objects.get(slug='abc--2020-12-02-%s' % time).cancel() |
3986 | 3995 |
resp = app.get('/manage/agendas/%s/%s/%s/' % (agenda.id, 2020, 12)) |
3987 | 3996 |
assert 'Cancelled' in resp.text |
3988 |
- |