|
|
|
@ -2779,7 +2779,10 @@ def test_recurring_events_display(freezer):
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_event_triggered_fields():
|
|
|
|
|
@pytest.mark.parametrize('partial_bookings', [True, False])
|
|
|
|
|
def test_event_triggered_fields(partial_bookings):
|
|
|
|
|
full_flags_true_value = not (partial_bookings)
|
|
|
|
|
|
|
|
|
|
# alter event pk sequence to have a bigint
|
|
|
|
|
with connection.cursor() as cursor:
|
|
|
|
|
cursor.execute("SELECT nextval('agendas_event_id_seq')")
|
|
|
|
@ -2787,7 +2790,7 @@ def test_event_triggered_fields():
|
|
|
|
|
if row[0] < 2**31:
|
|
|
|
|
cursor.execute("ALTER SEQUENCE agendas_event_id_seq RESTART WITH %s;" % 2**31)
|
|
|
|
|
|
|
|
|
|
agenda = Agenda.objects.create(label='Agenda', kind='events')
|
|
|
|
|
agenda = Agenda.objects.create(label='Agenda', kind='events', partial_bookings=partial_bookings)
|
|
|
|
|
event = Event.objects.create(
|
|
|
|
|
agenda=agenda, start_datetime=now() + datetime.timedelta(days=10), places=10, label='Event'
|
|
|
|
|
)
|
|
|
|
@ -2826,30 +2829,30 @@ def test_event_triggered_fields():
|
|
|
|
|
event.refresh_from_db()
|
|
|
|
|
assert event.booked_places == 9
|
|
|
|
|
assert event.booked_waiting_list_places == 0
|
|
|
|
|
assert event.almost_full is True
|
|
|
|
|
assert event.almost_full == full_flags_true_value
|
|
|
|
|
assert event.full is False
|
|
|
|
|
|
|
|
|
|
Booking.objects.create(event=event)
|
|
|
|
|
event.refresh_from_db()
|
|
|
|
|
assert event.booked_places == 10
|
|
|
|
|
assert event.booked_waiting_list_places == 0
|
|
|
|
|
assert event.almost_full is True
|
|
|
|
|
assert event.full is True
|
|
|
|
|
assert event.almost_full == full_flags_true_value
|
|
|
|
|
assert event.full == full_flags_true_value
|
|
|
|
|
|
|
|
|
|
# cancel bookings for other event: no impact
|
|
|
|
|
event2.booking_set.filter(cancellation_datetime__isnull=True).first().cancel()
|
|
|
|
|
event.refresh_from_db()
|
|
|
|
|
assert event.booked_places == 10
|
|
|
|
|
assert event.booked_waiting_list_places == 0
|
|
|
|
|
assert event.almost_full is True
|
|
|
|
|
assert event.full is True
|
|
|
|
|
assert event.almost_full == full_flags_true_value
|
|
|
|
|
assert event.full == full_flags_true_value
|
|
|
|
|
|
|
|
|
|
# cancel bookings
|
|
|
|
|
event.booking_set.filter(cancellation_datetime__isnull=True).first().cancel()
|
|
|
|
|
event.refresh_from_db()
|
|
|
|
|
assert event.booked_places == 9
|
|
|
|
|
assert event.booked_waiting_list_places == 0
|
|
|
|
|
assert event.almost_full is True
|
|
|
|
|
assert event.almost_full == full_flags_true_value
|
|
|
|
|
assert event.full is False
|
|
|
|
|
event.booking_set.filter(cancellation_datetime__isnull=True).first().cancel()
|
|
|
|
|
event.refresh_from_db()
|
|
|
|
@ -2874,8 +2877,8 @@ def test_event_triggered_fields():
|
|
|
|
|
event.refresh_from_db()
|
|
|
|
|
assert event.booked_places == 10
|
|
|
|
|
assert event.booked_waiting_list_places == 0
|
|
|
|
|
assert event.almost_full is True
|
|
|
|
|
assert event.full is True
|
|
|
|
|
assert event.almost_full == full_flags_true_value
|
|
|
|
|
assert event.full == full_flags_true_value
|
|
|
|
|
|
|
|
|
|
# with a waiting list
|
|
|
|
|
event.waiting_list_places = 5
|
|
|
|
@ -2883,7 +2886,7 @@ def test_event_triggered_fields():
|
|
|
|
|
event.refresh_from_db()
|
|
|
|
|
assert event.booked_places == 10
|
|
|
|
|
assert event.booked_waiting_list_places == 0
|
|
|
|
|
assert event.almost_full is True
|
|
|
|
|
assert event.almost_full == full_flags_true_value
|
|
|
|
|
assert event.full is False
|
|
|
|
|
|
|
|
|
|
# add bookings for other event: no impact
|
|
|
|
@ -2892,7 +2895,7 @@ def test_event_triggered_fields():
|
|
|
|
|
event.refresh_from_db()
|
|
|
|
|
assert event.booked_places == 10
|
|
|
|
|
assert event.booked_waiting_list_places == 0
|
|
|
|
|
assert event.almost_full is True
|
|
|
|
|
assert event.almost_full == full_flags_true_value
|
|
|
|
|
assert event.full is False
|
|
|
|
|
|
|
|
|
|
# add bookings
|
|
|
|
@ -2900,30 +2903,30 @@ def test_event_triggered_fields():
|
|
|
|
|
event.refresh_from_db()
|
|
|
|
|
assert event.booked_places == 10
|
|
|
|
|
assert event.booked_waiting_list_places == 1
|
|
|
|
|
assert event.almost_full is True
|
|
|
|
|
assert event.almost_full == full_flags_true_value
|
|
|
|
|
assert event.full is False
|
|
|
|
|
for _ in range(1, 5):
|
|
|
|
|
Booking.objects.create(event=event, in_waiting_list=True)
|
|
|
|
|
event.refresh_from_db()
|
|
|
|
|
assert event.booked_places == 10
|
|
|
|
|
assert event.booked_waiting_list_places == 5
|
|
|
|
|
assert event.almost_full is True
|
|
|
|
|
assert event.full is True
|
|
|
|
|
assert event.almost_full == full_flags_true_value
|
|
|
|
|
assert event.full == full_flags_true_value
|
|
|
|
|
|
|
|
|
|
# cancel bookings for other event: no impact
|
|
|
|
|
event2.booking_set.filter(in_waiting_list=True, cancellation_datetime__isnull=True).first().cancel()
|
|
|
|
|
event.refresh_from_db()
|
|
|
|
|
assert event.booked_places == 10
|
|
|
|
|
assert event.booked_waiting_list_places == 5
|
|
|
|
|
assert event.almost_full is True
|
|
|
|
|
assert event.full is True
|
|
|
|
|
assert event.almost_full == full_flags_true_value
|
|
|
|
|
assert event.full == full_flags_true_value
|
|
|
|
|
|
|
|
|
|
# cancel bookings
|
|
|
|
|
event.booking_set.filter(in_waiting_list=True, cancellation_datetime__isnull=True).first().cancel()
|
|
|
|
|
event.refresh_from_db()
|
|
|
|
|
assert event.booked_places == 10
|
|
|
|
|
assert event.booked_waiting_list_places == 4
|
|
|
|
|
assert event.almost_full is True
|
|
|
|
|
assert event.almost_full == full_flags_true_value
|
|
|
|
|
assert event.full is False
|
|
|
|
|
|
|
|
|
|
# update waiting list places
|
|
|
|
@ -2932,21 +2935,21 @@ def test_event_triggered_fields():
|
|
|
|
|
event.refresh_from_db()
|
|
|
|
|
assert event.booked_places == 10
|
|
|
|
|
assert event.booked_waiting_list_places == 4
|
|
|
|
|
assert event.almost_full is True
|
|
|
|
|
assert event.full is True
|
|
|
|
|
assert event.almost_full == full_flags_true_value
|
|
|
|
|
assert event.full == full_flags_true_value
|
|
|
|
|
|
|
|
|
|
# delete bookings
|
|
|
|
|
event.booking_set.filter(in_waiting_list=True, cancellation_datetime__isnull=True).first().delete()
|
|
|
|
|
event.refresh_from_db()
|
|
|
|
|
assert event.booked_places == 10
|
|
|
|
|
assert event.booked_waiting_list_places == 3
|
|
|
|
|
assert event.almost_full is True
|
|
|
|
|
assert event.almost_full == full_flags_true_value
|
|
|
|
|
assert event.full is False
|
|
|
|
|
event.booking_set.filter(in_waiting_list=False, cancellation_datetime__isnull=True).first().delete()
|
|
|
|
|
event.refresh_from_db()
|
|
|
|
|
assert event.booked_places == 9
|
|
|
|
|
assert event.booked_waiting_list_places == 3
|
|
|
|
|
assert event.almost_full is True
|
|
|
|
|
assert event.almost_full == full_flags_true_value
|
|
|
|
|
assert event.full is False
|
|
|
|
|
event.booking_set.filter(in_waiting_list=False, cancellation_datetime__isnull=True).first().delete()
|
|
|
|
|
event.refresh_from_db()
|
|
|
|
|