forked from CGM_Public/pretix_original
Add support for multiple linked_orderpositions on reusable media (#5666)
* change linked orderpositions to many-to-many * Update media views to list ops * return last op as fallback for linked_orderposition * add multi-op to export * update media-API * fix media-view filter * update control media forms * fix API orders * fix API orders matching media * remove cached_property linked_orderposition - keep only in API * fix media-issue signal * adapt checkin API for multiple orderpositions * remove unneeded comment * fix create/update logging * fix tests * fix more tests * fix code style * add label to reusablemedium * fix migration NOT NULL * fix tests * update docs * clarify docs updating multiple linked_orderpositions * clarify docs * no need to prefetch linked_orderpositions * improve readability * select_related order instead prefetch * add filter based on op.valid_from/until * rename secret to claim_token * Update docs for claim_token * unifiy deprecated style * Update reusablemedia.rst * Update reusablemedia.rst * Update reusablemedia.rst * fix missing claim_token in serializer * fix flake8 * add add_to_reusable_medium to order-serializer * fix tests regarding claim_token * fix flake8 * Clarify docs * list ops comma-separated in export * Add test for order-API add_to_reusable_medium * fix linked_orderpositions filter in checkinrpc * add test * Add help-text * fix multi-op media filter * fix flake8 * improve check * Fix sorting of reusable media type in overview * Add copy and qr button to reusable medium detail view * Rebase against origin/master * Add logentrytype reusable_medium.linked_orderposition.removed * add missing label_from_instance for SafeOrderPositionMultipleChoiceField * add tests for create with linked_orderposition * API add test for fallback-values in medium patch * fix flake8 * Fix indentation * fix migrations numbering * fix test * unify qutation marks * fix flake8 * micro-improve linked_op-removal-logging * simplify filter instead of annotate/get * Do not translate API-errors Co-authored-by: Raphael Michel <michel@pretix.eu> * Fix typos in doc Co-authored-by: Raphael Michel <mail@raphaelmichel.de> * Update versionchanged in docs Co-authored-by: Raphael Michel <michel@pretix.eu> * Change log to always added not changed * Add test for checkinrpc for ops out of timerang or canceled * improve tests mixing ops from different organizers * Fix logging of changed order_positions * properly log added/removed when using UI * refactor logging code * unify logging adding/removing ops via API * fix flake8 * remove unnecessary prefetch as already prefetched * optimize fetching ops * combine addon match and time-based validity match * fix combined valid and product check * re-number migrations * Apply suggestion from @raphaelm Co-authored-by: Raphael Michel <michel@pretix.eu> * fix flake8 * New attempt at logic * Improve op_candidate-selection for error message if no op matches check-in * Fix typo * fix valid_from start time being included * use the datetime parameter for the comparison time so that the simulator works too --------- Co-authored-by: Maximilian Richt <richt@pretix.eu> Co-authored-by: Martin Gross <gross@rami.io> Co-authored-by: Raphael Michel <michel@pretix.eu> Co-authored-by: Raphael Michel <mail@raphaelmichel.de>
This commit is contained in:
committed by
GitHub
parent
d3151f978d
commit
721b179521
@@ -3121,9 +3121,78 @@ def test_order_create_use_medium(token_client, organizer, event, item, quota, qu
|
||||
with scopes_disabled():
|
||||
o = Order.objects.get(code=resp.data['code'])
|
||||
medium.refresh_from_db()
|
||||
assert o.positions.first() == medium.linked_orderposition
|
||||
assert o.positions.first() == medium.linked_orderpositions.first()
|
||||
assert resp.data['positions'][0]['pdf_data']['medium_identifier'] == medium.identifier
|
||||
|
||||
resp = token_client.post(
|
||||
'/api/v1/organizers/{}/events/{}/orders/?pdf_data=true'.format(
|
||||
organizer.slug, event.slug
|
||||
), format='json', data=res
|
||||
)
|
||||
assert resp.status_code == 201
|
||||
with scopes_disabled():
|
||||
o = Order.objects.get(code=resp.data['code'])
|
||||
medium.refresh_from_db()
|
||||
assert medium.linked_orderpositions.count() == 1
|
||||
assert o.positions.first() == medium.linked_orderpositions.first()
|
||||
assert resp.data['positions'][0]['pdf_data']['medium_identifier'] == medium.identifier
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_order_create_add_to_medium(token_client, organizer, event, item, quota, question, medium):
|
||||
item.media_type = medium.type
|
||||
item.media_policy = Item.MEDIA_POLICY_REUSE_OR_NEW
|
||||
item.save()
|
||||
res = copy.deepcopy(ORDER_CREATE_PAYLOAD)
|
||||
res['positions'][0]['item'] = item.pk
|
||||
res['positions'][0]['use_reusable_medium'] = medium.pk
|
||||
res['positions'][0]['add_to_reusable_medium'] = medium.pk
|
||||
res['positions'][0]['answers'][0]['question'] = question.pk
|
||||
|
||||
# do not use use_reusable_medium and add_to_reusable_medium
|
||||
resp = token_client.post(
|
||||
'/api/v1/organizers/{}/events/{}/orders/?pdf_data=true'.format(
|
||||
organizer.slug, event.slug
|
||||
), format='json', data=res
|
||||
)
|
||||
assert resp.status_code == 400
|
||||
|
||||
del res['positions'][0]['use_reusable_medium']
|
||||
|
||||
resp = token_client.post(
|
||||
'/api/v1/organizers/{}/events/{}/orders/?pdf_data=true'.format(
|
||||
organizer.slug, event.slug
|
||||
), format='json', data=res
|
||||
)
|
||||
assert resp.status_code == 201
|
||||
with scopes_disabled():
|
||||
medium.refresh_from_db()
|
||||
assert medium.linked_orderpositions.count() == 1
|
||||
|
||||
resp = token_client.post(
|
||||
'/api/v1/organizers/{}/events/{}/orders/?pdf_data=true'.format(
|
||||
organizer.slug, event.slug
|
||||
), format='json', data=res
|
||||
)
|
||||
assert resp.status_code == 201
|
||||
with scopes_disabled():
|
||||
medium.refresh_from_db()
|
||||
assert medium.linked_orderpositions.count() == 2
|
||||
|
||||
res['positions'][0]['use_reusable_medium'] = medium.pk
|
||||
del res['positions'][0]['add_to_reusable_medium']
|
||||
resp = token_client.post(
|
||||
'/api/v1/organizers/{}/events/{}/orders/?pdf_data=true'.format(
|
||||
organizer.slug, event.slug
|
||||
), format='json', data=res
|
||||
)
|
||||
assert resp.status_code == 201
|
||||
with scopes_disabled():
|
||||
o = Order.objects.get(code=resp.data['code'])
|
||||
medium.refresh_from_db()
|
||||
assert medium.linked_orderpositions.count() == 1
|
||||
assert o.positions.first() == medium.linked_orderpositions.first()
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_order_create_use_medium_other_organizer(token_client, organizer, event, item, quota, question, medium2):
|
||||
@@ -3168,7 +3237,7 @@ def test_order_create_create_medium(token_client, organizer, event, item, quota,
|
||||
i = resp.data['positions'][0]['pdf_data']['medium_identifier']
|
||||
assert i
|
||||
m = organizer.reusable_media.get(identifier=i)
|
||||
assert m.linked_orderposition == o.positions.first()
|
||||
assert m.linked_orderpositions.first() == o.positions.first()
|
||||
assert m.type == "barcode"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user