1 from django.views.generic import ListView, DetailView
2 from django.http import Http404
3 from photo.models import Album, Photo
5 class AlbumListView(ListView):
7 queryset = Album.objects.order_by('-name')
10 class PhotoListView(ListView):
17 def get_queryset(self):
19 album = Album.objects.get(slug__exact=self.kwargs['slug'])
20 return Photo.objects.filter(album=album).order_by('order', 'image')
24 class PhotoView(DetailView):
26 def get_queryset(self, **kwargs):
27 return Photo.objects.get(id=self.kwargs['id']).get_queryset()
29 def get_object(self, **kwargs):
31 photo = Photo.objects.get(id=self.kwargs['id'])
36 def get_context_data(self, **kwargs):
37 context = super(PhotoView, self).get_context_data(**kwargs)
38 album = Album.objects.get(slug__exact=self.kwargs['slug'])
39 photos = Photo.objects.filter(album=album).order_by('order', 'image')
48 if not photo.id == int(self.kwargs['id']):
55 if photo.id == int(self.kwargs['id']):
58 context['next_photo'] = next_photo
59 context['prev_photo'] = prev_photo