Skip to content

Commit bd76900

Browse files
committed
Support for CheckResult.locale and check(useOrderLocale)
1 parent 3e58a93 commit bd76900

File tree

5 files changed

+21
-3
lines changed

5 files changed

+21
-3
lines changed

Diff for: libpretixsync/src/main/java/eu/pretix/libpretixsync/check/AsyncCheckProvider.kt

+2
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,7 @@ class AsyncCheckProvider(private val config: ConfigStore, private val dataStore:
540540
type: TicketCheckProvider.CheckInType,
541541
nonce: String?,
542542
allowQuestions: Boolean,
543+
useOrderLocale: Boolean
543544
): TicketCheckProvider.CheckResult {
544545
val ticketid_cleaned = cleanInput(ticketid, source_type)
545546

@@ -680,6 +681,7 @@ class AsyncCheckProvider(private val config: ConfigStore, private val dataStore:
680681
res.variation = variation.stringValue
681682
}
682683

684+
res.locale = position.getOrder().locale
683685
res.attendee_name = position.attendee_name
684686
res.seat = position.seatName
685687
res.orderCode = position.getOrder().getCode()

Diff for: libpretixsync/src/main/java/eu/pretix/libpretixsync/check/OnlineCheckProvider.kt

+5-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ class OnlineCheckProvider(
4949
with_badge_data: Boolean,
5050
type: TicketCheckProvider.CheckInType,
5151
nonce: String?,
52-
allowQuestions: Boolean
52+
allowQuestions: Boolean,
53+
useOrderLocale: Boolean
5354
): TicketCheckProvider.CheckResult {
5455
val ticketid_cleaned = cleanInput(ticketid, source_type)
5556
val nonce_cleaned = nonce ?: NonceGenerator.nextNonce()
@@ -187,6 +188,9 @@ class OnlineCheckProvider(
187188
}
188189
res.orderCode = posjson.optString("order")
189190
res.positionId = posjson.optLong("positionid")
191+
if (posjson.has("order__locale")) {
192+
res.locale = posjson.getString("order__locale")
193+
}
190194
res.position = posjson
191195
val checkins = posjson.getJSONArray("checkins")
192196
for (i in 0 until checkins.length()) {

Diff for: libpretixsync/src/main/java/eu/pretix/libpretixsync/check/ProxyCheckProvider.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ class ProxyCheckProvider(private val config: ConfigStore, httpClientFactory: Htt
104104
with_badge_data: Boolean,
105105
type: TicketCheckProvider.CheckInType,
106106
nonce: String?,
107-
allowQuestions: Boolean
107+
allowQuestions: Boolean,
108+
useOrderLocale: Boolean
108109
): TicketCheckProvider.CheckResult {
109110
val data: MutableMap<String, Any> = HashMap()
110111
data["events_and_checkin_lists"] = eventsAndCheckinLists
@@ -115,6 +116,7 @@ class ProxyCheckProvider(private val config: ConfigStore, httpClientFactory: Htt
115116
data["source_type"] = source_type
116117
data["type"] = type
117118
data["allowQuestions"] = allowQuestions
119+
data["useOrderLocale"] = useOrderLocale
118120
if (nonce != null) {
119121
data["nonce"] = nonce
120122
}

Diff for: libpretixsync/src/main/java/eu/pretix/libpretixsync/check/TicketCheckProvider.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ interface TicketCheckProvider {
5454
var position: JSONObject? = null
5555
var eventSlug: String? = null
5656
var offline: Boolean = false
57+
var locale: String? = null
5758

5859
constructor(type: Type?, message: String?, offline: Boolean = false) {
5960
this.type = type
@@ -131,7 +132,7 @@ interface TicketCheckProvider {
131132
class StatusResult(var eventName: String?, var totalTickets: Int, var alreadyScanned: Int, var currentlyInside: Int?, var items: List<StatusResultItem>?) {
132133
}
133134

134-
fun check(eventsAndCheckinLists: Map<String, Long>, ticketid: String, source_type: String, answers: List<Answer>?, ignore_unpaid: Boolean, with_badge_data: Boolean, type: CheckInType, nonce: String? = null, allowQuestions: Boolean = true): CheckResult
135+
fun check(eventsAndCheckinLists: Map<String, Long>, ticketid: String, source_type: String, answers: List<Answer>?, ignore_unpaid: Boolean, with_badge_data: Boolean, type: CheckInType, nonce: String? = null, allowQuestions: Boolean = true, useOrderLocale: Boolean = false): CheckResult
135136
fun check(eventsAndCheckinLists: Map<String, Long>, ticketid: String): CheckResult
136137
@Throws(CheckException::class)
137138
fun search(eventsAndCheckinLists: Map<String, Long>, query: String, page: Int): List<SearchResult>

Diff for: libpretixsync/src/main/java/eu/pretix/libpretixsync/db/AbstractOrder.java

+9
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ public boolean isValidStatus() {
7070
return false;
7171
}
7272

73+
public String getLocale() {
74+
try {
75+
return getJSON().getString("locale");
76+
} catch (JSONException e) {
77+
e.printStackTrace();
78+
return null;
79+
}
80+
}
81+
7382
public String getPaymentProvider() {
7483
try {
7584
return getJSON().getString("payment_provider");

0 commit comments

Comments
 (0)