2017-05-20 12:45:26 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from __future__ import unicode_literals
|
2017-06-10 09:59:00 +00:00
|
|
|
from django.http import HttpResponse
|
|
|
|
from django.shortcuts import get_object_or_404, render
|
|
|
|
from .models import Content
|
2017-07-03 08:14:07 +00:00
|
|
|
from django.db.models import Q
|
|
|
|
from django.views.generic.list import ListView
|
|
|
|
from photologue.views import GalleryListView
|
|
|
|
from photologue.models import Photo, Gallery
|
|
|
|
from django.core.exceptions import ObjectDoesNotExist
|
2017-05-20 12:45:26 +00:00
|
|
|
|
|
|
|
# Create your views here.
|
2017-06-10 09:59:00 +00:00
|
|
|
|
|
|
|
def index(request):
|
2017-07-03 08:14:07 +00:00
|
|
|
latest_content_list = Content.objects.order_by('-datestart')[:8]
|
2017-06-10 09:59:00 +00:00
|
|
|
context = {'latest_content_list': latest_content_list}
|
|
|
|
return render(request, 'index.html', context)
|
|
|
|
|
|
|
|
def project(request):
|
|
|
|
content = Content.objects.filter(type=3)
|
2017-07-03 08:14:07 +00:00
|
|
|
return render(request, 'project.html', {'content': content})
|
|
|
|
|
|
|
|
def events(request, shortname):
|
|
|
|
events = get_object_or_404(Content, shortname=shortname)
|
|
|
|
gallery = get_or_none(Gallery, slug=shortname)
|
|
|
|
latest_content_list = Content.objects.filter(Q(type=0) | Q(type=1)).order_by('-datestart')
|
|
|
|
return render(request, 'events.html', {'events': events, 'latest_content_list': latest_content_list, 'gallery': gallery})
|
|
|
|
|
|
|
|
def projects(request, shortname):
|
|
|
|
projects = get_object_or_404(Content, shortname=shortname)
|
|
|
|
latest_content_list = Content.objects.filter(type=3)
|
|
|
|
return render(request, 'projects.html', {'projects': projects, 'latest_content_list': latest_content_list})
|
|
|
|
|
|
|
|
class GalleryListViews(ListView):
|
|
|
|
queryset = Gallery.objects.on_site().is_public()
|
|
|
|
paginate_by = 20
|
|
|
|
template_name = 'gallery_list.html'
|
|
|
|
|
|
|
|
def get_or_none(classmodel, **kwargs):
|
|
|
|
try:
|
|
|
|
return classmodel.objects.get(**kwargs)
|
|
|
|
except classmodel.DoesNotExist:
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
|