papiez_ipsum/src/papiezator/views.py

35 lines
1019 B
Python

# Create your views here.
from django.shortcuts import render
from django.core.urlresolvers import reverse
from papiezator.papiezator_settings import LOLGITHUB_URL
from papiezator.pope_utils import get_pope, http_return_image
from papiezator.models import Pope
from django.utils import translation
def index(request, pope=None):
translation.deactivate()
if pope:
if pope == 'Benedictus_XVI':
translation.activate('de')
pope = Pope.objects.filter(name=pope.replace('_', ' ')).first()
if pope:
pope = pope.id
if not pope:
pope = 0
c = {
"absolute_url": request.build_absolute_uri(reverse("papiezator:conclave", args=[200, 300])),
"absolute_url_exp": request.build_absolute_uri("width/height/"),
"github_url": LOLGITHUB_URL,
"pope": pope
}
return render(request, "papiezator/index.html", c)
@http_return_image
def conclave(request, width, height, pope_id=0):
return get_pope(width, height, pope_id)