forked from CGM_Public/pretix_original
Add print logs (#4475)
* Add print logs * Add attribute successful * Rebase migration * Fix tests on postgres
This commit is contained in:
@@ -123,6 +123,7 @@ TEST_ORDERPOSITION1_RES = {
|
||||
"secret": "z3fsn8jyufm5kpk768q69gkbyr5f4h6w",
|
||||
"addon_to": None,
|
||||
"checkins": [],
|
||||
"print_logs": [],
|
||||
"downloads": [],
|
||||
"answers": [],
|
||||
"seat": None,
|
||||
@@ -160,6 +161,7 @@ TEST_ORDERPOSITION2_RES = {
|
||||
"secret": "sf4HZG73fU6kwddgjg2QOusFbYZwVKpK",
|
||||
"addon_to": None,
|
||||
"checkins": [],
|
||||
"print_logs": [],
|
||||
"downloads": [],
|
||||
"answers": [],
|
||||
"seat": None,
|
||||
@@ -197,6 +199,7 @@ TEST_ORDERPOSITION3_RES = {
|
||||
"secret": "3u4ez6vrrbgb3wvezxhq446p548dt2wn",
|
||||
"addon_to": None,
|
||||
"checkins": [],
|
||||
"print_logs": [],
|
||||
"downloads": [],
|
||||
"answers": [],
|
||||
"seat": None,
|
||||
@@ -467,7 +470,7 @@ def test_list_all_items_positions(token_client, organizer, event, clist, clist_a
|
||||
p3["addon_to"] = p1["id"]
|
||||
|
||||
# All items
|
||||
with django_assert_num_queries(23):
|
||||
with django_assert_num_queries(24):
|
||||
resp = token_client.get('/api/v1/organizers/{}/events/{}/checkinlists/{}/positions/?ordering=positionid'.format(
|
||||
organizer.slug, event.slug, clist_all.pk
|
||||
))
|
||||
@@ -1359,7 +1362,7 @@ def test_search(token_client, organizer, event, clist, clist_all, item, other_it
|
||||
p1["id"] = order.positions.get(positionid=1).pk
|
||||
p1["item"] = item.pk
|
||||
|
||||
with django_assert_max_num_queries(17):
|
||||
with django_assert_max_num_queries(18):
|
||||
resp = token_client.get('/api/v1/organizers/{}/events/{}/checkinlists/{}/positions/?search=z3fsn8jyu'.format(
|
||||
organizer.slug, event.slug, clist_all.pk
|
||||
))
|
||||
|
||||
@@ -163,6 +163,7 @@ TEST_ORDERPOSITION1_RES = {
|
||||
"secret": "z3fsn8jyufm5kpk768q69gkbyr5f4h6w",
|
||||
"addon_to": None,
|
||||
"checkins": [],
|
||||
"print_logs": [],
|
||||
"downloads": [],
|
||||
"answers": [],
|
||||
"seat": None,
|
||||
|
||||
@@ -155,6 +155,7 @@ def test_giftcard_detail_expand(token_client, organizer, event, giftcard):
|
||||
"addon_to": None,
|
||||
"subevent": None,
|
||||
"checkins": [],
|
||||
"print_logs": [],
|
||||
"downloads": [],
|
||||
"answers": [],
|
||||
"tax_rule": None,
|
||||
|
||||
@@ -463,6 +463,7 @@ def test_order_create_simulate(token_client, organizer, event, item, quota, ques
|
||||
'subevent': None,
|
||||
'discount': None,
|
||||
'checkins': [],
|
||||
'print_logs': [],
|
||||
'downloads': [],
|
||||
"valid_from": None,
|
||||
"valid_until": None,
|
||||
@@ -535,13 +536,13 @@ def test_order_create_positionids_addons_simulated(token_client, organizer, even
|
||||
'attendee_name': 'Peter', 'attendee_name_parts': {'full_name': 'Peter', '_scheme': 'full'}, 'company': None,
|
||||
'street': None, 'zipcode': None, 'city': None, 'country': None, 'state': None, 'attendee_email': None,
|
||||
'voucher': None, 'tax_rate': '0.00', 'tax_value': '0.00', 'discount': None, 'voucher_budget_use': None,
|
||||
'addon_to': None, 'subevent': None, 'checkins': [], 'downloads': [], 'answers': [], 'tax_rule': None,
|
||||
'addon_to': None, 'subevent': None, 'checkins': [], 'print_logs': [], 'downloads': [], 'answers': [], 'tax_rule': None,
|
||||
'pseudonymization_id': 'PREVIEW', 'seat': None, 'canceled': False, 'valid_from': None, 'valid_until': None, 'blocked': None},
|
||||
{'id': 0, 'order': '', 'positionid': 2, 'item': item.pk, 'variation': None, 'price': '23.00',
|
||||
'attendee_name': 'Peter', 'attendee_name_parts': {'full_name': 'Peter', '_scheme': 'full'}, 'company': None,
|
||||
'street': None, 'zipcode': None, 'city': None, 'country': None, 'state': None, 'attendee_email': None,
|
||||
'voucher': None, 'tax_rate': '0.00', 'tax_value': '0.00', 'discount': None, 'voucher_budget_use': None,
|
||||
'addon_to': 1, 'subevent': None, 'checkins': [], 'downloads': [], 'answers': [], 'tax_rule': None,
|
||||
'addon_to': 1, 'subevent': None, 'checkins': [], 'print_logs': [], 'downloads': [], 'answers': [], 'tax_rule': None,
|
||||
'pseudonymization_id': 'PREVIEW', 'seat': None, 'canceled': False, 'valid_from': None, 'valid_until': None, 'blocked': None}
|
||||
]
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ def quota(event, item):
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def order(event, item, taxrule, question):
|
||||
def order(event, item, device, taxrule, question):
|
||||
testtime = datetime.datetime(2017, 12, 1, 10, 0, 0, tzinfo=datetime.timezone.utc)
|
||||
event.plugins += ",pretix.plugins.stripe"
|
||||
event.save()
|
||||
@@ -137,6 +137,13 @@ def order(event, item, taxrule, question):
|
||||
canceled=True,
|
||||
positionid=2,
|
||||
)
|
||||
op.print_logs.create(
|
||||
device=device,
|
||||
type="badge",
|
||||
source="pretixpos",
|
||||
info={"cashier": 1234},
|
||||
datetime=datetime.datetime(2017, 12, 1, 12, 0, 0, tzinfo=datetime.timezone.utc),
|
||||
)
|
||||
op.answers.create(question=question, answer='S')
|
||||
return o
|
||||
|
||||
@@ -200,6 +207,19 @@ TEST_ORDERPOSITION_RES = {
|
||||
"addon_to": None,
|
||||
"pseudonymization_id": "ABCDEFGHKL",
|
||||
"checkins": [],
|
||||
"print_logs": [
|
||||
{
|
||||
"id": -1,
|
||||
"device_id": -1,
|
||||
"successful": True,
|
||||
"datetime": "2017-12-01T12:00:00Z",
|
||||
"source": "pretixpos",
|
||||
"type": "badge",
|
||||
"info": {
|
||||
"cashier": 1234
|
||||
},
|
||||
}
|
||||
],
|
||||
"downloads": [],
|
||||
"seat": None,
|
||||
"company": None,
|
||||
@@ -321,7 +341,7 @@ TEST_ORDER_RES = {
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_order_list_filter_subevent_date(token_client, organizer, event, order, item, taxrule, subevent, question):
|
||||
def test_order_list_filter_subevent_date(token_client, device, organizer, event, order, item, taxrule, subevent, question):
|
||||
res = copy.deepcopy(TEST_ORDER_RES)
|
||||
with scopes_disabled():
|
||||
res["positions"][0]["id"] = order.positions.first().pk
|
||||
@@ -329,6 +349,9 @@ def test_order_list_filter_subevent_date(token_client, organizer, event, order,
|
||||
p.subevent = subevent
|
||||
p.save()
|
||||
fee = order.fees.first()
|
||||
pl = p.print_logs.first()
|
||||
res["positions"][0]["print_logs"][0]["id"] = pl.pk
|
||||
res["positions"][0]["print_logs"][0]["device_id"] = device.device_id
|
||||
res["positions"][0]["item"] = item.pk
|
||||
res["positions"][0]["subevent"] = subevent.pk
|
||||
res["positions"][0]["answers"][0]["question"] = question.pk
|
||||
@@ -379,11 +402,13 @@ def test_order_list_filter_subevent_date(token_client, organizer, event, order,
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_order_list(token_client, organizer, event, order, item, taxrule, question):
|
||||
def test_order_list(token_client, organizer, event, order, item, taxrule, question, device):
|
||||
res = dict(TEST_ORDER_RES)
|
||||
with scopes_disabled():
|
||||
res["positions"][0]["id"] = order.positions.first().pk
|
||||
res["fees"][0]["id"] = order.fees.first().pk
|
||||
res["positions"][0]["print_logs"][0]["id"] = order.positions.first().print_logs.first().pk
|
||||
res["positions"][0]["print_logs"][0]["device_id"] = device.device_id
|
||||
res["positions"][0]["item"] = item.pk
|
||||
res["positions"][0]["answers"][0]["question"] = question.pk
|
||||
res["last_modified"] = order.last_modified.isoformat().replace('+00:00', 'Z')
|
||||
@@ -497,6 +522,7 @@ def test_order_detail(token_client, organizer, event, order, item, taxrule, ques
|
||||
res = dict(TEST_ORDER_RES)
|
||||
with scopes_disabled():
|
||||
res["positions"][0]["id"] = order.positions.first().pk
|
||||
res["positions"][0]["print_logs"][0]["id"] = order.positions.first().print_logs.first().pk
|
||||
res["fees"][0]["id"] = order.fees.first().pk
|
||||
res["positions"][0]["item"] = item.pk
|
||||
res["fees"][0]["tax_rule"] = taxrule.pk
|
||||
@@ -968,12 +994,14 @@ def test_orderposition_list(token_client, organizer, device, event, order, item,
|
||||
var2 = item.variations.create(value="Children")
|
||||
res = copy.copy(TEST_ORDERPOSITION_RES)
|
||||
op = order.positions.first()
|
||||
op.variation = var
|
||||
op.save()
|
||||
res["id"] = op.pk
|
||||
res["item"] = item.pk
|
||||
res["variation"] = var.pk
|
||||
res["answers"][0]["question"] = question.pk
|
||||
op.variation = var
|
||||
op.save()
|
||||
res["id"] = op.pk
|
||||
res["item"] = item.pk
|
||||
res["variation"] = var.pk
|
||||
res["answers"][0]["question"] = question.pk
|
||||
res["print_logs"][0]["id"] = op.print_logs.first().pk
|
||||
res["print_logs"][0]["device_id"] = device.device_id
|
||||
|
||||
resp = token_client.get('/api/v1/organizers/{}/events/{}/orderpositions/'.format(organizer.slug, event.slug))
|
||||
assert resp.status_code == 200
|
||||
@@ -1072,7 +1100,7 @@ def test_orderposition_list(token_client, organizer, device, event, order, item,
|
||||
'gate': None,
|
||||
'type': 'entry'
|
||||
}]
|
||||
with django_assert_num_queries(15):
|
||||
with django_assert_num_queries(16):
|
||||
resp = token_client.get(
|
||||
'/api/v1/organizers/{}/events/{}/orderpositions/?has_checkin=true'.format(organizer.slug, event.slug)
|
||||
)
|
||||
@@ -1107,6 +1135,7 @@ def test_orderposition_detail(token_client, organizer, event, order, item, quest
|
||||
res = dict(TEST_ORDERPOSITION_RES)
|
||||
with scopes_disabled():
|
||||
op = order.positions.first()
|
||||
res["print_logs"][0]["id"] = op.print_logs.first().pk
|
||||
res["id"] = op.pk
|
||||
res["item"] = item.pk
|
||||
res["answers"][0]["question"] = question.pk
|
||||
@@ -1171,6 +1200,30 @@ def test_orderposition_delete(token_client, organizer, event, order, item, quest
|
||||
assert order.total == Decimal('23.25')
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_orderposition_printlog(token_client, team, organizer, event, order, item, question):
|
||||
with scopes_disabled():
|
||||
op = order.positions.first()
|
||||
resp = token_client.post('/api/v1/organizers/{}/events/{}/orderpositions/{}/printlog/'.format(
|
||||
organizer.slug, event.slug, op.pk
|
||||
), data={
|
||||
"datetime": "2023-09-04T12:23:45+02:00",
|
||||
"source": "pretixscan",
|
||||
"type": "badge",
|
||||
"info": {
|
||||
"cashier": 1234,
|
||||
}
|
||||
}, format='json')
|
||||
assert resp.status_code == 201
|
||||
|
||||
with scopes_disabled():
|
||||
l = op.print_logs.get(source="pretixscan")
|
||||
assert l.type == "badge"
|
||||
assert l.info == {"cashier": 1234}
|
||||
assert l.api_token.team == team
|
||||
assert l.datetime.isoformat() == "2023-09-04T10:23:45+00:00"
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_order_mark_paid_pending(token_client, organizer, event, order):
|
||||
resp = token_client.post(
|
||||
@@ -1920,7 +1973,7 @@ def test_pdf_data(token_client, organizer, event, order, django_assert_max_num_q
|
||||
assert not resp.data['positions'][0].get('pdf_data')
|
||||
|
||||
# order list
|
||||
with django_assert_max_num_queries(30):
|
||||
with django_assert_max_num_queries(31):
|
||||
resp = token_client.get('/api/v1/organizers/{}/events/{}/orders/?pdf_data=true'.format(
|
||||
organizer.slug, event.slug
|
||||
))
|
||||
@@ -1935,7 +1988,7 @@ def test_pdf_data(token_client, organizer, event, order, django_assert_max_num_q
|
||||
assert not resp.data['results'][0]['positions'][0].get('pdf_data')
|
||||
|
||||
# position list
|
||||
with django_assert_max_num_queries(33):
|
||||
with django_assert_max_num_queries(34):
|
||||
resp = token_client.get('/api/v1/organizers/{}/events/{}/orderpositions/?pdf_data=true'.format(
|
||||
organizer.slug, event.slug
|
||||
))
|
||||
|
||||
@@ -192,6 +192,7 @@ def test_medium_detail(token_client, organizer, event, medium, giftcard, custome
|
||||
"addon_to": None,
|
||||
"subevent": None,
|
||||
"checkins": [],
|
||||
"print_logs": [],
|
||||
"downloads": [],
|
||||
"answers": [],
|
||||
"tax_rule": None,
|
||||
|
||||
Reference in New Issue
Block a user