-class GalleryView(UploadView):
- def get_object(self, request, slug):
- return get_object_or_404(Book, slug=slug)
+class GalleryMixin(object):
+ def get_directory(self):
+ return "%s%s/" % (settings.IMAGE_DIR, self.object.gallery)
+
+ @staticmethod
+ def get_object(request, slug):
+ book = get_object_or_404(Book, slug=slug)
+ if not book.gallery:
+ raise Http404
+ return book
+
+
+class GalleryView(GalleryMixin, UploadView):