Generated: Sun 2013-06-16 14:51 CEST
Source file: /home/dkaufhold/projects/cmsplugin-image-gallery/src/image_gallery/views.py
Stats: 11 executed, 0 missed, 3 excluded, 8 ignored
"""Views for the ``image_gallery`` app."""
from django.views.generic import ListView
from .app_settings import PAGINATION_AMOUNT
from .models import Gallery, GalleryCategory
class GalleryListView(ListView):
"""View to display a list of ``Gallery`` instances."""
paginate_by = PAGINATION_AMOUNT
def get_queryset(self):
category = self.request.GET.get('category')
if category:
return Gallery.objects.filter(category__slug=category).order_by(
'date')
return Gallery.objects.all().order_by('date')
def get_context_data(self, **kwargs):
ctx = super(GalleryListView, self).get_context_data(**kwargs)
ctx.update({'categories': GalleryCategory.objects.all()})
return ctx