mirror of
https://github.com/pretix/pretix.git
synced 2026-05-08 15:44:02 +00:00
Fix bug when modifying an order with an address in a country with a state
This commit is contained in:
@@ -452,14 +452,17 @@ class BaseQuestionsForm(forms.Form):
|
|||||||
types, form = COUNTRIES_WITH_STATE_IN_ADDRESS[cc]
|
types, form = COUNTRIES_WITH_STATE_IN_ADDRESS[cc]
|
||||||
statelist = [s for s in pycountry.subdivisions.get(country_code=cc) if s.type in types]
|
statelist = [s for s in pycountry.subdivisions.get(country_code=cc) if s.type in types]
|
||||||
c += sorted([(s.code[3:], s.name) for s in statelist], key=lambda s: s[1])
|
c += sorted([(s.code[3:], s.name) for s in statelist], key=lambda s: s[1])
|
||||||
|
state = (cartpos.state if cartpos else orderpos.state)
|
||||||
elif fprefix + 'state' in self.data:
|
elif fprefix + 'state' in self.data:
|
||||||
self.data = self.data.copy()
|
self.data = self.data.copy()
|
||||||
|
state = None
|
||||||
del self.data[fprefix + 'state']
|
del self.data[fprefix + 'state']
|
||||||
|
|
||||||
add_fields['state'] = forms.ChoiceField(
|
add_fields['state'] = forms.ChoiceField(
|
||||||
label=pgettext_lazy('address', 'State'),
|
label=pgettext_lazy('address', 'State'),
|
||||||
required=False,
|
required=False,
|
||||||
choices=c,
|
choices=c,
|
||||||
|
initial=state,
|
||||||
widget=forms.Select(attrs={
|
widget=forms.Select(attrs={
|
||||||
'autocomplete': 'address-level1',
|
'autocomplete': 'address-level1',
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -343,7 +343,7 @@ var form_handlers = function (el) {
|
|||||||
$("select[name$=state]:not([data-static])").each(function () {
|
$("select[name$=state]:not([data-static])").each(function () {
|
||||||
var dependent = $(this),
|
var dependent = $(this),
|
||||||
counter = 0,
|
counter = 0,
|
||||||
dependency = $(this).closest("form").find('select[name$=country]'),
|
dependency = $(this).closest(".panel-body, form").find('select[name$=country]'),
|
||||||
update = function (ev) {
|
update = function (ev) {
|
||||||
counter++;
|
counter++;
|
||||||
var curCounter = counter;
|
var curCounter = counter;
|
||||||
|
|||||||
Reference in New Issue
Block a user