Add URL and detect if languague exist
This commit is contained in:
parent
6b7cad86f2
commit
feb591ea79
|
@ -19,6 +19,7 @@ urlpatterns = [
|
||||||
path('billing/', views.BillingView.as_view(), name='billing'),
|
path('billing/', views.BillingView.as_view(), name='billing'),
|
||||||
path('bills/<int:pk>/download/', views.BillDownloadView.as_view(), name='bill-download'),
|
path('bills/<int:pk>/download/', views.BillDownloadView.as_view(), name='bill-download'),
|
||||||
path('profile/', views.ProfileView.as_view(), name='profile'),
|
path('profile/', views.ProfileView.as_view(), name='profile'),
|
||||||
|
path('profile/setLang/<lang>', views.ProfileSetLang, name='profile'),
|
||||||
path('address/', views.MailView.as_view(), name='address-list'),
|
path('address/', views.MailView.as_view(), name='address-list'),
|
||||||
path('address/new/', views.MailCreateView.as_view(), name='address-create'),
|
path('address/new/', views.MailCreateView.as_view(), name='address-create'),
|
||||||
path('address/<int:pk>/', views.MailUpdateView.as_view(), name='address-update'),
|
path('address/<int:pk>/', views.MailUpdateView.as_view(), name='address-update'),
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from audioop import reverse
|
||||||
import logging
|
import logging
|
||||||
from os import stat
|
from os import stat
|
||||||
import smtplib
|
import smtplib
|
||||||
|
@ -6,7 +7,7 @@ from django.conf import settings
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.core.exceptions import ImproperlyConfigured
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
from django.core.mail import mail_managers
|
from django.core.mail import mail_managers
|
||||||
from django.http import HttpResponse, HttpResponseRedirect
|
from django.http import HttpResponse, HttpResponseNotFound, HttpResponseRedirect
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.urls import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
from django.utils import translation
|
from django.utils import translation
|
||||||
|
@ -125,6 +126,22 @@ class ProfileView(CustomContextMixin, UserTokenRequiredMixin, TemplateView):
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
def ProfileSetLang(request, lang):
|
||||||
|
# set user language as active language
|
||||||
|
|
||||||
|
if any(x[0] == lang for x in settings.LANGUAGES):
|
||||||
|
# http://127.0.0.1:8080/profile/setLang/es
|
||||||
|
user_language = lang
|
||||||
|
translation.activate(user_language)
|
||||||
|
|
||||||
|
response = HttpResponseRedirect('/dashboard')
|
||||||
|
response.set_cookie(settings.LANGUAGE_COOKIE_NAME, user_language)
|
||||||
|
|
||||||
|
return response
|
||||||
|
else:
|
||||||
|
response = HttpResponseNotFound('Languague not found')
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
class ServiceListView(CustomContextMixin, ExtendedPaginationMixin, UserTokenRequiredMixin, ListView):
|
class ServiceListView(CustomContextMixin, ExtendedPaginationMixin, UserTokenRequiredMixin, ListView):
|
||||||
"""Base list view to all services"""
|
"""Base list view to all services"""
|
||||||
|
|
Loading…
Reference in a new issue