Add exchanging tickets to reusable media#78
Conversation
…anged behind reusableMediaUsageEnforced setting
| val reusableMediaUsageEnforced = (settings?.json?.optBoolean("reusable_media_usage_enforced", false) == true) | ||
|
|
||
| val linkedReusableMedium = db.reusableMediumQueries.selectByLinkedOrderPosition(position.positionId) | ||
| .executeAsOneOrNull()?.toModel() |
There was a problem hiding this comment.
What happens if this has multiple results?
There was a problem hiding this comment.
Could change it to a query that just counts, but do we want to check expired/active here too? Or more like: in which state is a ticket that already has a linked medium, but that medium is no longer active anymore?
There was a problem hiding this comment.
Could change it to a query that just counts, but do we want to check expired/active here too?
No, I think we don't need to check it here
Or more like: in which state is a ticket that already has a linked medium, but that medium is no longer active anymore?
For now, in an unusuable state, I guess, which is the safest option. We should figure that out once we have a real-world use case for ReusableMedium.expires, I really have no idea why it's in there. Maybe the idea was that e.g. a printed season ticket card should be re-printed every 5-10 years to get an updated photo instead of an old photo being carried around for decades? In that case the expiry should sync with the ticket expiry.
| val reusableMediaUsageEnforced = (settings?.json?.optBoolean("reusable_media_usage_enforced", false) == true) | ||
|
|
||
| val linkedReusableMedium = db.reusableMediumQueries.selectByLinkedOrderPosition(position.positionId) | ||
| .executeAsOneOrNull()?.toModel() |
There was a problem hiding this comment.
Could change it to a query that just counts, but do we want to check expired/active here too?
No, I think we don't need to check it here
Or more like: in which state is a ticket that already has a linked medium, but that medium is no longer active anymore?
For now, in an unusuable state, I guess, which is the safest option. We should figure that out once we have a real-world use case for ReusableMedium.expires, I really have no idea why it's in there. Maybe the idea was that e.g. a printed season ticket card should be re-printed every 5-10 years to get an updated photo instead of an old photo being carried around for decades? In that case the expiry should sync with the ticket expiry.
| if (linkedReusableMedium == null) { | ||
| res.type = TicketCheckProvider.CheckResult.Type.EXCHANGE_REQUIRED | ||
| res.isCheckinAllowed = false | ||
| storeFailedCheckin(eventSlug, list.serverId, "exchange", position.secret!!, type, position = position.serverId, item = positionItem.serverId, variation = position.variationServerId, subevent = position.subEventServerId, nonce = nonce) | ||
| return res | ||
| } else if (reusableMediaUsageEnforced) { | ||
| res.type = TicketCheckProvider.CheckResult.Type.ALREADY_EXCHANGED | ||
| res.isCheckinAllowed = false | ||
| storeFailedCheckin(eventSlug, list.serverId, "already_exchanged", position.secret!!, type, position = position.serverId, item = positionItem.serverId, variation = position.variationServerId, subevent = position.subEventServerId, nonce = nonce) | ||
| return res |
There was a problem hiding this comment.
For a reason I don't yet understand, both of these cases trigger the error message reusable_media_exchange_not_implemented in my test, which is the wrong error message?
| if (!hasLinkedReusableMedium) { | ||
| res.type = TicketCheckProvider.CheckResult.Type.ERROR // EXCHANGE_REQUIRED, but not in offline mode | ||
| res.isCheckinAllowed = false | ||
| res.reasonExplanation = "This ticket needs to be exchanged, but this isn't possible while offline" |
There was a problem hiding this comment.
Can we translate that in the ui? → pretixSCAN
This requires pretix/pretix#6115
TODO: