diff --git a/orchestra/contrib/musician/templates/musician/base.html b/orchestra/contrib/musician/templates/musician/base.html
index bfe32585..537b08db 100644
--- a/orchestra/contrib/musician/templates/musician/base.html
+++ b/orchestra/contrib/musician/templates/musician/base.html
@@ -94,7 +94,7 @@
diff --git a/orchestra/contrib/musician/templates/musician/profile.html b/orchestra/contrib/musician/templates/musician/profile.html
index f6bdbced..8c76c514 100644
--- a/orchestra/contrib/musician/templates/musician/profile.html
+++ b/orchestra/contrib/musician/templates/musician/profile.html
@@ -18,7 +18,7 @@
{{ profile.username }}
{{ profile.type }}
-
{% trans "Preferred language:" %} {{ profile.language|language_name_local }}
+
{% trans "Preferred language:" %} {{ preferred_language_code|language_name_local }}
{% comment %}
diff --git a/orchestra/contrib/musician/views.py b/orchestra/contrib/musician/views.py
index b48f1c6a..05beac5f 100644
--- a/orchestra/contrib/musician/views.py
+++ b/orchestra/contrib/musician/views.py
@@ -1,4 +1,3 @@
-import datetime
import logging
import smtplib
@@ -123,13 +122,10 @@ class ProfileView(CustomContextMixin, UserTokenRequiredMixin, TemplateView):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
- try:
- pay_source = self.orchestra.retrieve_service_list(
- PaymentSource.api_name)[0]
- except IndexError:
- pay_source = {}
+ user = self.request.user
context.update({
- 'payment': PaymentSource.new_from_json(pay_source)
+ 'payment': user.paymentsources.first(),
+ 'preferred_language_code': user.language.lower(),
})
return context
@@ -139,11 +135,19 @@ def profile_set_language(request, code):
# set user language as active language
if any(x[0] == code for x in settings.LANGUAGES):
- # http://127.0.0.1:8080/profile/setLang/es
user_language = code
translation.activate(user_language)
- response = HttpResponseRedirect('/dashboard')
+ redirect_to = request.GET.get('next', '')
+ url_is_safe = is_safe_url(
+ url=redirect_to,
+ allowed_hosts={request.get_host()},
+ require_https=request.is_secure(),
+ )
+ if not url_is_safe:
+ redirect_to = reverse_lazy(settings.LOGIN_REDIRECT_URL)
+
+ response = HttpResponseRedirect(redirect_to)
response.set_cookie(settings.LANGUAGE_COOKIE_NAME, user_language)
return response