33 lines
931 B
Python
33 lines
931 B
Python
from django.shortcuts import render, redirect, get_object_or_404
|
|
|
|
from . import models
|
|
|
|
def fallback(request):
|
|
context = {}
|
|
return render(request, 'fallback.html', context)
|
|
|
|
def index(request):
|
|
context = {}
|
|
return render(request, 'index.html', context)
|
|
|
|
def page(request, slug=''):
|
|
context = {}
|
|
page = models.Page.objects.filter(slug=slug, public=True).first()
|
|
if page:
|
|
context['page'] = page
|
|
return render(request, 'page.html', context)
|
|
else:
|
|
return render(request, 'fallback.html', context)
|
|
|
|
def about(request):
|
|
return page(request, 'about')
|
|
|
|
def texts(request):
|
|
context = {}
|
|
context['texts'] = models.Text.objects.filter(public=True).order_by('created')
|
|
return render(request, 'texts.html', context)
|
|
|
|
def text(request, slug):
|
|
context = {}
|
|
context['text'] = get_object_or_404(models.Text, slug=slug)
|
|
return render(request, 'text.html', context)
|