0.12.28 localization routines
This commit is contained in:
@@ -21,6 +21,9 @@ def get_articles_block_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
from GeneralApp.funcs import get_and_set_lang
|
||||
lang = get_and_set_lang(request)
|
||||
|
||||
try:
|
||||
|
||||
data = request.POST.dict()
|
||||
|
||||
@@ -18,7 +18,7 @@ from django.core.files import File
|
||||
import base64
|
||||
from django.core.validators import validate_email
|
||||
from django.urls import reverse
|
||||
|
||||
from GeneralApp.funcs import get_and_set_lang
|
||||
|
||||
# @login_required(login_url='/profile/login/')
|
||||
# def subscribe_ajax(request):
|
||||
@@ -36,6 +36,8 @@ def mailing_subscribe_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
lang = get_and_set_lang(request)
|
||||
|
||||
try:
|
||||
|
||||
email = request.POST['email']
|
||||
@@ -80,6 +82,8 @@ def send_message_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
lang = get_and_set_lang(request)
|
||||
|
||||
try:
|
||||
|
||||
data = request.POST
|
||||
@@ -212,6 +216,8 @@ def chats_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
lang = get_and_set_lang(request)
|
||||
|
||||
from ChatServiceApp.funcs import get_chat_receivers_for_user, get_msgs_for_chat_w_users
|
||||
|
||||
receivers, unread_msgs_count = get_chat_receivers_for_user(request.user)
|
||||
@@ -242,6 +248,8 @@ def support_tickets_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
lang = get_and_set_lang(request)
|
||||
|
||||
html = get_profile_support_page_content_html(request)
|
||||
|
||||
return JsonResponse({'html': html}, status=200)
|
||||
@@ -255,6 +263,8 @@ def change_avatar_confirm_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
lang = get_and_set_lang(request)
|
||||
|
||||
try:
|
||||
|
||||
file_data = json.loads(request.body)
|
||||
@@ -281,6 +291,8 @@ def change_profile_confirm_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
lang = get_and_set_lang(request)
|
||||
|
||||
data = request.POST
|
||||
if not data:
|
||||
data = json.loads(request.body)
|
||||
@@ -354,6 +366,8 @@ def dashboard_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
lang = get_and_set_lang(request)
|
||||
|
||||
try:
|
||||
|
||||
from .funcs import get_dashboard_page_content_html
|
||||
@@ -372,6 +386,7 @@ def change_profile_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
lang = get_and_set_lang(request)
|
||||
|
||||
html = get_profile_change_page_content_html(request)
|
||||
return JsonResponse({'html': html}, status=200)
|
||||
@@ -382,6 +397,8 @@ def my_routes_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
lang = get_and_set_lang(request)
|
||||
|
||||
Dict = {
|
||||
}
|
||||
|
||||
@@ -396,6 +413,8 @@ def login_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
lang = get_and_set_lang(request)
|
||||
|
||||
try:
|
||||
|
||||
data = request.POST
|
||||
@@ -483,6 +502,9 @@ def registration_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
from GeneralApp.funcs import get_and_set_lang
|
||||
lang = get_and_set_lang(request)
|
||||
|
||||
try:
|
||||
|
||||
data = request.POST
|
||||
|
||||
@@ -24,6 +24,9 @@ def get_file_from_msg_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
from GeneralApp.funcs import get_and_set_lang
|
||||
lang = get_and_set_lang(request)
|
||||
|
||||
try:
|
||||
|
||||
data = json.loads(request.body)
|
||||
@@ -49,6 +52,9 @@ def show_chat_w_user_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
from GeneralApp.funcs import get_and_set_lang
|
||||
lang = get_and_set_lang(request)
|
||||
|
||||
try:
|
||||
|
||||
data = json.loads(request.body)
|
||||
@@ -74,6 +80,9 @@ def update_chat_ajax2(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
from GeneralApp.funcs import get_and_set_lang
|
||||
lang = get_and_set_lang(request)
|
||||
|
||||
res_Dict = {}
|
||||
msgs = []
|
||||
Dict = {}
|
||||
@@ -163,6 +172,9 @@ def update_chat_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
from GeneralApp.funcs import get_and_set_lang
|
||||
lang = get_and_set_lang(request)
|
||||
|
||||
res_Dict = {}
|
||||
msgs = []
|
||||
Dict = {}
|
||||
@@ -381,6 +393,9 @@ def support_show_chat_by_ticket_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
from GeneralApp.funcs import get_and_set_lang
|
||||
lang = get_and_set_lang(request)
|
||||
|
||||
try:
|
||||
|
||||
data = json.loads(request.body)
|
||||
@@ -434,6 +449,8 @@ def support_create_ticket_form_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
from GeneralApp.funcs import get_and_set_lang
|
||||
lang = get_and_set_lang(request)
|
||||
|
||||
Dict = {
|
||||
'form': TicketForm()
|
||||
@@ -454,6 +471,9 @@ def create_ticket_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
from GeneralApp.funcs import get_and_set_lang
|
||||
lang = get_and_set_lang(request)
|
||||
|
||||
try:
|
||||
|
||||
data = request.POST
|
||||
|
||||
@@ -1,6 +1,29 @@
|
||||
from django.http import HttpResponse, Http404, FileResponse
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
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]
|
||||
|
||||
if not lang:
|
||||
lang = get_language()
|
||||
|
||||
if not lang:
|
||||
lang = 'en'
|
||||
|
||||
return activate(lang)
|
||||
|
||||
|
||||
|
||||
def get_inter_Dict(user):
|
||||
|
||||
from SubscribesApp.funcs import get_cur_user_subscribe
|
||||
|
||||
@@ -14,6 +14,7 @@ from django.urls import reverse
|
||||
from django.db.models import Q
|
||||
import json
|
||||
from GeneralApp.funcs import get_inter_http_respose
|
||||
from GeneralApp.funcs import get_and_set_lang
|
||||
|
||||
def get_address_point_ajax(request):
|
||||
from .funcs import search_cities_in_db, search_airports_in_db
|
||||
@@ -21,6 +22,9 @@ def get_address_point_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
|
||||
lang = get_and_set_lang(request)
|
||||
|
||||
try:
|
||||
|
||||
data = json.loads(request.body)
|
||||
|
||||
@@ -15,12 +15,16 @@ from django.template.loader import render_to_string
|
||||
from django.urls import reverse
|
||||
from .forms import *
|
||||
from .funcs import *
|
||||
from GeneralApp.funcs import get_and_set_lang
|
||||
|
||||
|
||||
|
||||
def del_route_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
lang = get_and_set_lang(request)
|
||||
|
||||
try:
|
||||
|
||||
data = json.loads(request.body)
|
||||
@@ -54,6 +58,8 @@ def edit_route_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
lang = get_and_set_lang(request)
|
||||
|
||||
data = json.loads(request.body)
|
||||
|
||||
Dict = {}
|
||||
@@ -99,6 +105,8 @@ def new_route_view_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
lang = get_and_set_lang(request)
|
||||
|
||||
# form = RouteForm()
|
||||
# Dict = {
|
||||
# 'form': form
|
||||
@@ -132,6 +140,8 @@ def find_routes_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
lang = get_and_set_lang(request)
|
||||
|
||||
try:
|
||||
|
||||
|
||||
@@ -175,6 +185,8 @@ def get_my_routes_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
lang = get_and_set_lang(request)
|
||||
|
||||
try:
|
||||
routes_Dict = get_routes_Dict(request.user)
|
||||
if 'errors' in routes_Dict:
|
||||
@@ -206,6 +218,8 @@ def create_or_change_route_ajax(request, route_id=None):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
lang = get_and_set_lang(request)
|
||||
|
||||
Dict = {}
|
||||
|
||||
try:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from .models import *
|
||||
from django.template.loader import render_to_string
|
||||
from django.utils.translation import get_language, activate
|
||||
|
||||
def get_cur_user_subscribe(user):
|
||||
|
||||
@@ -26,6 +27,9 @@ def get_profile_subscribe_page_content_html(request):
|
||||
|
||||
try:
|
||||
|
||||
from GeneralApp.funcs import get_and_set_lang
|
||||
lang = get_and_set_lang(request)
|
||||
|
||||
# data = json.loads(request.body)
|
||||
# all_options = SubscribeOption.objects.filter(enable=True)
|
||||
subscribes, all_options = get_subsribes_w_options()
|
||||
|
||||
@@ -16,7 +16,7 @@ import json
|
||||
from datetime import datetime, time, timedelta
|
||||
from channels.layers import get_channel_layer
|
||||
from asgiref.sync import async_to_sync
|
||||
|
||||
from GeneralApp.funcs import get_and_set_lang
|
||||
|
||||
|
||||
@login_required(login_url='/profile/login/')
|
||||
@@ -25,6 +25,8 @@ def subscribe_now_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
lang = get_and_set_lang(request)
|
||||
|
||||
try:
|
||||
|
||||
data = json.loads(request.body)
|
||||
@@ -77,6 +79,8 @@ def show_cur_subscribe_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
lang = get_and_set_lang(request)
|
||||
|
||||
html = get_profile_subscribe_page_content_html(request)
|
||||
return JsonResponse({'html': html}, status=200)
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user