0.12.31 fix switch langs

This commit is contained in:
SDE
2024-04-04 23:16:26 +03:00
parent 46fdda269f
commit c2d021a516
4 changed files with 23 additions and 13 deletions

View File

@@ -14,7 +14,7 @@ from datetime import datetime
from django.contrib.auth.decorators import login_required
from .funcs import *
from GeneralApp.funcs import get_inter_http_respose
from django.urls import reverse
from GeneralApp.funcs import get_and_set_lang
def registration_View(request):
@@ -44,6 +44,9 @@ def registration_View(request):
@login_required()#login_url='/profile/login/')
def profile_page_View(request, page_name, id=None):
lang = get_and_set_lang(request)
Dict = {
'page_html': get_profile_page_content_html(request, page_name, id),
'page_name': page_name,
@@ -55,7 +58,7 @@ def profile_page_View(request, page_name, id=None):
request.user.user_profile.save(update_fields=['mailing_on'])
del request.session['mailingSubscribeRequired']
title = f"{_('Личный кабинет пользователя')} {request.user.first_name} {request.user.last_name}"
title = _('Личный кабинет пользователя') + ' ' + request.user.first_name + ' ' + request.user.last_name
Dict.update({
'page': {

View File

@@ -6,13 +6,18 @@ def get_and_set_lang(request):
from django.utils.translation import activate, get_language
lang = None
referer_url = request.META.get('HTTP_REFERER')
if referer_url:
url_list = referer_url.split('//')
if len(url_list) > 1:
url_list = url_list[1].split('/')
if len(url_list) > 1 and url_list[1] in settings.MODELTRANSLATION_LANGUAGES:
lang = url_list[1]
cur_url_list = request.path.split('/')
if len(cur_url_list) > 1 and cur_url_list[1] in settings.MODELTRANSLATION_LANGUAGES:
lang = cur_url_list[1]
if not lang:
referer_url = request.META.get('HTTP_REFERER')
if referer_url:
url_list = referer_url.split('//')
if len(url_list) > 1:
url_list = url_list[1].split('/')
if len(url_list) > 1 and url_list[1] in settings.MODELTRANSLATION_LANGUAGES:
lang = url_list[1]
if not lang:
lang = get_language()
@@ -20,7 +25,9 @@ def get_and_set_lang(request):
if not lang:
lang = 'en'
return activate(lang)
activate(lang)
return lang

View File

@@ -20,7 +20,7 @@ function SendLoginForm(el){
data: formData,
success: function(data){
location.href = `/profile/page/dashboard/`
location.href = data.redirect_url//`/profile/page/dashboard/`
window.sessionStorage.removeItem('mailingSubscribeRequired')
window.sessionStorage.removeItem('email')

View File

@@ -9,14 +9,14 @@
{% if page_type and page_type == 'profile' or not sel_page_name %}
{% if sel_page_name == 'logout' %}
<a href="/profile/logout/" class="text_btn_profile logout">
<a href="{% url "logout_profile" %}" class="text_btn_profile logout">
<span class="logout_span">
{% else %}
<span class="text_btn_profile">
{% endif %}
{% else %}
{% if sel_page_name == 'logout' %}
<a href="/profile/logout/" class="text_btn_profile logout">
<a href="{% url "logout_profile" %}" class="text_btn_profile logout">
<span class="logout_span">
{% elif sel_page_name != 'logoout' %}
<a onclick="changeHrefCl(this)" data-href="{% url "profile_page" sel_page_name %}" class="text_btn_profile">