users: Help set language cookie when user profile is edited

This patch only ensures that response object is send along with set_language()
call. In later changes, response object can be used by set_language() to set the
language cookie.

Tests:

- Relevant functional tests pass.

- Edit current user's language. The language is immediately set.

- Edit another user's language. The language of the current session is not changed.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa authored and James Valleroy committed 2021-10-09 21:03:23 -04:00
1 parent 79e5edb097
commit 45b5769ce6
2 files changed
+13 -6

No files matched your search

-5
View File
@@ -19,7 +19,6 @@ from plinth import actions
from plinth.errors import ActionError
from plinth.modules import first_boot
from plinth.modules.security import set_restricted_access
from plinth.translation import set_language
from plinth.utils import is_user_admin
from . import get_last_admin_user
@@ -244,10 +243,6 @@ class UserUpdateForm(ValidNewUsernameCheckMixin, PasswordConfirmForm,
auth_username = self.request.user.username
confirm_password = self.cleaned_data['confirm_password']
# If user is updating their own profile then only translate the pages
if self.username == auth_username:
set_language(self.request, None, user.userprofile.language)
if commit:
user.save()
self.save_m2m()