Fix getting defaults from cookie for region field in password form
Since the normal form doesn't have a request attribute, we have to pass the initial value for the region from the view. Change-Id: Icea647ad13718b74528922f362ad665be1392e9b Closes-bug: #1957926
This commit is contained in:
@@ -209,9 +209,6 @@ class Password(forms.Form):
|
|||||||
if len(self.fields['region'].choices) == 1:
|
if len(self.fields['region'].choices) == 1:
|
||||||
self.fields['region'].initial = self.fields['region'].choices[0][0]
|
self.fields['region'].initial = self.fields['region'].choices[0][0]
|
||||||
self.fields['region'].widget = forms.widgets.HiddenInput()
|
self.fields['region'].widget = forms.widgets.HiddenInput()
|
||||||
elif len(self.fields['region'].choices) > 1:
|
|
||||||
self.fields['region'].initial = self.request.COOKIES.get(
|
|
||||||
'login_region')
|
|
||||||
|
|
||||||
@sensitive_variables('password', 'confirm_password', 'original_password')
|
@sensitive_variables('password', 'confirm_password', 'original_password')
|
||||||
def clean(self):
|
def clean(self):
|
||||||
|
|||||||
@@ -460,7 +460,10 @@ class PasswordView(edit_views.FormView):
|
|||||||
success_url = settings.LOGIN_URL
|
success_url = settings.LOGIN_URL
|
||||||
|
|
||||||
def get_initial(self):
|
def get_initial(self):
|
||||||
return {'user_id': self.kwargs['user_id']}
|
return {
|
||||||
|
'user_id': self.kwargs['user_id'],
|
||||||
|
'region': self.request.COOKIES.get('login_region'),
|
||||||
|
}
|
||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
# We have no session here, so regular messages don't work.
|
# We have no session here, so regular messages don't work.
|
||||||
|
|||||||
Reference in New Issue
Block a user