2018-01-13 14:45:54 +00:00
|
|
|
from django.utils.translation import get_language
|
|
|
|
from django.http import HttpResponseRedirect
|
|
|
|
from django.views import generic
|
|
|
|
from django.urls import reverse
|
2018-01-27 22:12:09 +00:00
|
|
|
from .models import Page, PageContent
|
2018-01-13 14:45:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
def index(request):
|
|
|
|
default_page = Page.objects.filter(default=True).first()
|
|
|
|
return HttpResponseRedirect(reverse('page', args=(default_page.slug, )))
|
|
|
|
|
2018-01-27 22:12:09 +00:00
|
|
|
|
2018-01-13 14:45:54 +00:00
|
|
|
class PageView(generic.DetailView):
|
|
|
|
model = PageContent
|
|
|
|
context_object_name = 'page'
|
|
|
|
template_name = 'pages/page.html'
|
|
|
|
|
|
|
|
def get_object(self):
|
2018-01-27 22:12:09 +00:00
|
|
|
return PageContent.objects.filter(
|
|
|
|
language=get_language(),
|
|
|
|
page__slug=self.kwargs['slug']
|
|
|
|
).first()
|