dynamicweb/alplora/views.py

43 lines
1,003 B
Python
Raw Normal View History

from django.views.generic import TemplateView
2017-03-24 02:59:17 +00:00
from django.utils.translation import get_language, get_language_info
class IndexView(TemplateView):
2017-03-24 02:59:17 +00:00
template_name = "alplora/index.html"
def get_context_data(self, *args, **kwargs):
context = super(IndexView, self).get_context_data(**kwargs)
languages = getlanguages()
context.update(languages)
return context
2017-02-16 07:15:00 +00:00
class LoginView(TemplateView):
2017-03-24 02:59:17 +00:00
template_name = "alplora/login.html"
def get_context_data(self, *args, **kwargs):
context = super(LoginView, self).get_context_data(**kwargs)
languages = getlanguages()
context.update(languages)
return context
def getlanguages():
language = get_language()
language_activate = get_language_info(language)
if language == 'de':
list_language = {
'name': 'English',
'code': 'en-us'
}
else:
list_language = {
'name': 'Deutsch',
'code': 'de'
}
return {
'language': language,
'list_language': list_language,
'language_activate': language_activate['name_local']
}