0001-manager-it-is-not-possible-to-cancel-secondary-booki.patch
chrono/manager/templates/chrono/manager_event_detail_fragment.html | ||
---|---|---|
29 | 29 |
<ul class="objects-list single-links"> |
30 | 30 |
{% for booking in booked %} |
31 | 31 |
<li><a {% if booking.backoffice_url %}href="{{ booking.backoffice_url }}"{% endif %}>{{ booking.events_display }}</a> |
32 |
{% if not booking.primary_booking %} |
|
32 | 33 |
<a rel="popup" class="delete" href="{% url 'chrono-manager-booking-cancel' pk=agenda.id booking_pk=booking.id %}?next={{ request.path }}">{% trans "Cancel" %}</a> |
34 |
{% endif %} |
|
33 | 35 |
</li> |
34 | 36 |
{% endfor %} |
35 | 37 |
</ul> |
chrono/manager/views.py | ||
---|---|---|
2238 | 2238 |
self.booking = self.get_object() |
2239 | 2239 |
return super().dispatch(request, *args, **kwargs) |
2240 | 2240 | |
2241 |
def get_queryset(self): |
|
2242 |
queryset = super().get_queryset() |
|
2243 |
return queryset.filter(cancellation_datetime__isnull=True, primary_booking__isnull=True) |
|
2244 | ||
2241 | 2245 |
def form_valid(self, form): |
2242 | 2246 |
trigger_callback = not form.cleaned_data['disable_trigger'] |
2243 | 2247 |
try: |
2244 | 2248 |
self.booking.cancel(trigger_callback) |
2245 |
except requests.RequestException as e:
|
|
2249 |
except requests.RequestException: |
|
2246 | 2250 |
form.add_error(None, _('There has been an error sending cancellation notification to form.')) |
2247 | 2251 |
form.add_error(None, _('Check this box if you are sure you want to proceed anyway.')) |
2248 | 2252 |
form.show_trigger_checkbox() |
tests/test_manager.py | ||
---|---|---|
4546 | 4546 |
booking4 = Booking.objects.get(pk=booking_json4['booking_id']) |
4547 | 4547 |
assert booking4.cancellation_datetime |
4548 | 4548 | |
4549 |
# again |
|
4550 |
app.get('/manage/agendas/%s/bookings/%s/cancel' % (agenda.pk, booking4.pk), status=404) |
|
4551 | ||
4549 | 4552 | |
4550 | 4553 |
def test_booking_cancellation_events_agenda(app, admin_user): |
4551 | 4554 |
agenda = Agenda.objects.create(label='Events', kind='events') |
... | ... | |
4567 | 4570 |
resp = resp.follow() |
4568 | 4571 |
assert 'Bookings (0/10)' in resp.text |
4569 | 4572 | |
4573 |
# again |
|
4574 |
app.get('/manage/agendas/%s/bookings/%s/cancel' % (agenda.pk, booking.pk), status=404) |
|
4575 | ||
4576 |
# test secondary booking |
|
4577 |
primary = Booking.objects.create(event=event) |
|
4578 |
secondary = Booking.objects.create(event=event, primary_booking=primary) |
|
4579 |
resp = app.get('/manage/agendas/%s/events/%s/' % (agenda.pk, event.pk)) |
|
4580 |
assert 'Bookings (2/10)' in resp.text |
|
4581 |
assert '/manage/agendas/%s/bookings/%s/cancel' % (agenda.pk, primary.pk) in resp.text |
|
4582 |
assert '/manage/agendas/%s/bookings/%s/cancel' % (agenda.pk, secondary.pk) not in resp.text |
|
4583 |
app.get('/manage/agendas/%s/bookings/%s/cancel' % (agenda.pk, secondary.pk), status=404) |
|
4584 |
app.get('/manage/agendas/%s/bookings/%s/cancel' % (agenda.pk, primary.pk)).form.submit() |
|
4585 |
primary.refresh_from_db() |
|
4586 |
secondary.refresh_from_db() |
|
4587 |
assert primary.cancellation_datetime |
|
4588 |
assert secondary.cancellation_datetime |
|
4589 | ||
4570 | 4590 | |
4571 | 4591 |
def test_event_cancellation(app, admin_user): |
4572 | 4592 |
agenda = Agenda.objects.create(label='Events', kind='events') |
4573 |
- |