Web-based check-in interface (#1985)

This commit is contained in:
Raphael Michel
2021-03-30 09:34:11 +02:00
committed by GitHub
parent b06cded172
commit 92a50cb2d1
56 changed files with 3578 additions and 58 deletions

View File

@@ -10,7 +10,8 @@ from freezegun import freeze_time
from pretix.base.models import Checkin, Event, Order, OrderPosition, Organizer
from pretix.base.services.checkin import (
CheckInError, RequiredQuestionsError, perform_checkin, process_exit_all,
CheckInError, RequiredQuestionsError, SQLLogic, perform_checkin,
process_exit_all,
)
@@ -369,6 +370,8 @@ def test_rules_simple(position, clist):
clist.rules = {'and': [True, True]}
clist.save()
assert OrderPosition.objects.filter(SQLLogic(clist).apply(clist.rules), pk=position.pk).exists()
perform_checkin(position, clist, {})
@@ -385,6 +388,7 @@ def test_rules_product(event, position, clist):
]
}
clist.save()
assert not OrderPosition.objects.filter(SQLLogic(clist).apply(clist.rules), pk=position.pk).exists()
with pytest.raises(CheckInError) as excinfo:
perform_checkin(position, clist, {})
assert excinfo.value.code == 'rules'
@@ -400,6 +404,7 @@ def test_rules_product(event, position, clist):
]
}
clist.save()
assert OrderPosition.objects.filter(SQLLogic(clist).apply(clist.rules), pk=position.pk).exists()
perform_checkin(position, clist, {})
@@ -421,6 +426,7 @@ def test_rules_variation(item, position, clist):
clist.save()
with pytest.raises(CheckInError) as excinfo:
perform_checkin(position, clist, {})
assert not OrderPosition.objects.filter(SQLLogic(clist).apply(clist.rules), pk=position.pk).exists()
assert excinfo.value.code == 'rules'
clist.rules = {
@@ -434,6 +440,7 @@ def test_rules_variation(item, position, clist):
]
}
clist.save()
assert OrderPosition.objects.filter(SQLLogic(clist).apply(clist.rules), pk=position.pk).exists()
perform_checkin(position, clist, {})
@@ -443,10 +450,13 @@ def test_rules_scan_number(position, clist):
clist.allow_multiple_entries = True
clist.rules = {"<": [{"var": "entries_number"}, 3]}
clist.save()
assert OrderPosition.objects.filter(SQLLogic(clist).apply(clist.rules), pk=position.pk).exists()
perform_checkin(position, clist, {})
perform_checkin(position, clist, {})
perform_checkin(position, clist, {}, type=Checkin.TYPE_EXIT)
assert OrderPosition.objects.filter(SQLLogic(clist).apply(clist.rules), pk=position.pk).exists()
perform_checkin(position, clist, {})
assert not OrderPosition.objects.filter(SQLLogic(clist).apply(clist.rules), pk=position.pk).exists()
with pytest.raises(CheckInError) as excinfo:
perform_checkin(position, clist, {})
assert excinfo.value.code == 'rules'
@@ -463,20 +473,25 @@ def test_rules_scan_today(event, position, clist):
perform_checkin(position, clist, {})
perform_checkin(position, clist, {})
perform_checkin(position, clist, {}, type=Checkin.TYPE_EXIT)
assert OrderPosition.objects.filter(SQLLogic(clist).apply(clist.rules), pk=position.pk).exists()
perform_checkin(position, clist, {})
assert not OrderPosition.objects.filter(SQLLogic(clist).apply(clist.rules), pk=position.pk).exists()
with pytest.raises(CheckInError) as excinfo:
perform_checkin(position, clist, {})
assert excinfo.value.code == 'rules'
with freeze_time("2020-01-01 22:50:00"):
assert not OrderPosition.objects.filter(SQLLogic(clist).apply(clist.rules), pk=position.pk).exists()
with pytest.raises(CheckInError) as excinfo:
perform_checkin(position, clist, {})
assert excinfo.value.code == 'rules'
with freeze_time("2020-01-01 23:10:00"):
assert OrderPosition.objects.filter(SQLLogic(clist).apply(clist.rules), pk=position.pk).exists()
perform_checkin(position, clist, {})
perform_checkin(position, clist, {})
perform_checkin(position, clist, {})
assert not OrderPosition.objects.filter(SQLLogic(clist).apply(clist.rules), pk=position.pk).exists()
with pytest.raises(CheckInError) as excinfo:
perform_checkin(position, clist, {})
assert excinfo.value.code == 'rules'
@@ -492,18 +507,22 @@ def test_rules_scan_days(event, position, clist):
with freeze_time("2020-01-01 10:00:00"):
perform_checkin(position, clist, {})
perform_checkin(position, clist, {})
assert OrderPosition.objects.filter(SQLLogic(clist).apply(clist.rules), pk=position.pk).exists()
perform_checkin(position, clist, {})
with freeze_time("2020-01-03 10:00:00"):
perform_checkin(position, clist, {})
perform_checkin(position, clist, {})
perform_checkin(position, clist, {})
assert OrderPosition.objects.filter(SQLLogic(clist).apply(clist.rules), pk=position.pk).exists()
perform_checkin(position, clist, {})
with freeze_time("2020-01-03 22:50:00"):
assert OrderPosition.objects.filter(SQLLogic(clist).apply(clist.rules), pk=position.pk).exists()
perform_checkin(position, clist, {})
with freeze_time("2020-01-03 23:50:00"):
assert not OrderPosition.objects.filter(SQLLogic(clist).apply(clist.rules), pk=position.pk).exists()
with pytest.raises(CheckInError) as excinfo:
perform_checkin(position, clist, {})
assert excinfo.value.code == 'rules'
@@ -518,11 +537,13 @@ def test_rules_time_isafter_tolerance(event, position, clist):
clist.rules = {"isAfter": [{"var": "now"}, {"buildTime": ["date_admission"]}, 10]}
clist.save()
with freeze_time("2020-01-01 10:45:00"):
assert not OrderPosition.objects.filter(SQLLogic(clist).apply(clist.rules), pk=position.pk).exists()
with pytest.raises(CheckInError) as excinfo:
perform_checkin(position, clist, {})
assert excinfo.value.code == 'rules'
with freeze_time("2020-01-01 10:51:00"):
assert OrderPosition.objects.filter(SQLLogic(clist).apply(clist.rules), pk=position.pk).exists()
perform_checkin(position, clist, {})
@@ -536,11 +557,13 @@ def test_rules_time_isafter_no_tolerance(event, position, clist):
clist.rules = {"isAfter": [{"var": "now"}, {"buildTime": ["date_admission"]}]}
clist.save()
with freeze_time("2020-01-01 10:51:00"):
assert not OrderPosition.objects.filter(SQLLogic(clist).apply(clist.rules), pk=position.pk).exists()
with pytest.raises(CheckInError) as excinfo:
perform_checkin(position, clist, {})
assert excinfo.value.code == 'rules'
with freeze_time("2020-01-01 11:01:00"):
assert OrderPosition.objects.filter(SQLLogic(clist).apply(clist.rules), pk=position.pk).exists()
perform_checkin(position, clist, {})
@@ -553,11 +576,13 @@ def test_rules_time_isbefore_with_tolerance(event, position, clist):
clist.rules = {"isBefore": [{"var": "now"}, {"buildTime": ["date_to"]}, 10]}
clist.save()
with freeze_time("2020-01-01 11:11:00"):
assert not OrderPosition.objects.filter(SQLLogic(clist).apply(clist.rules), pk=position.pk).exists()
with pytest.raises(CheckInError) as excinfo:
perform_checkin(position, clist, {})
assert excinfo.value.code == 'rules'
with freeze_time("2020-01-01 11:09:00"):
assert OrderPosition.objects.filter(SQLLogic(clist).apply(clist.rules), pk=position.pk).exists()
perform_checkin(position, clist, {})
@@ -568,11 +593,13 @@ def test_rules_time_isafter_custom_time(event, position, clist):
clist.rules = {"isAfter": [{"var": "now"}, {"buildTime": ["custom", "2020-01-01T22:00:00.000Z"]}, None]}
clist.save()
with freeze_time("2020-01-01 21:55:00"):
assert not OrderPosition.objects.filter(SQLLogic(clist).apply(clist.rules), pk=position.pk).exists()
with pytest.raises(CheckInError) as excinfo:
perform_checkin(position, clist, {})
assert excinfo.value.code == 'rules'
with freeze_time("2020-01-01 22:05:00"):
assert OrderPosition.objects.filter(SQLLogic(clist).apply(clist.rules), pk=position.pk).exists()
perform_checkin(position, clist, {})
@@ -587,11 +614,13 @@ def test_rules_isafter_subevent(position, clist, event):
clist.rules = {"isAfter": [{"var": "now"}, {"buildTime": ["date_admission"]}]}
clist.save()
with freeze_time("2020-02-01 10:51:00"):
assert not OrderPosition.objects.filter(SQLLogic(clist).apply(clist.rules), pk=position.pk).exists()
with pytest.raises(CheckInError) as excinfo:
perform_checkin(position, clist, {})
assert excinfo.value.code == 'rules'
with freeze_time("2020-02-01 11:01:00"):
assert OrderPosition.objects.filter(SQLLogic(clist).apply(clist.rules), pk=position.pk).exists()
perform_checkin(position, clist, {})