]> git.sommitrealweird.co.uk Git - sommitrealweird.git/commitdiff
Clean up photos so that it does 404s django-1.7
authorBrett Parker <brettp@mythic-beasts.com>
Sun, 24 May 2015 10:19:19 +0000 (11:19 +0100)
committerBrett Parker <brettp@mythic-beasts.com>
Sun, 24 May 2015 10:19:19 +0000 (11:19 +0100)
sommitrealweird/photo/views.py
sommitrealweird/settings.py

index 28955abc072f3b32fa2a4880ef4976e92f308300..8501a6fef06677a1f74242a031f1912622a20832 100644 (file)
@@ -7,24 +7,29 @@ class AlbumListView(ListView):
     queryset = Album.objects.order_by('-name')
     paginate_by = 20
 
-    def get_context_data(self, **kwargs):
-        context = super(AlbumListView, self).get_context_data(**kwargs)
-        return context
-
 class PhotoListView(ListView):
     model = Photo
     paginate_by = 20
     order_by = 'order, image'
 
     def get_queryset(self):
-        album = Album.objects.get(slug__exact=self.kwargs['slug'])
-        return Photo.objects.filter(album=album)
+        try:
+            album = Album.objects.get(slug__exact=self.kwargs['slug'])
+            return Photo.objects.filter(album=album)
+        except:
+            raise Http404
 
 class PhotoView(DetailView):
-    model = Photo
+
+    def get_queryset(self, **kwargs):
+        return Photo.objects.get(id=self.kwargs['id']).get_queryset()
 
     def get_object(self, **kwargs):
-        return Photo.objects.get(id=self.kwargs['id'])
+        try:
+            photo = Photo.objects.get(id=self.kwargs['id'])
+            return photo
+        except:
+            raise Http404
 
     def get_context_data(self, **kwargs):
         context = super(PhotoView, self).get_context_data(**kwargs)
@@ -52,4 +57,3 @@ class PhotoView(DetailView):
         context['prev_photo'] = prev_photo
 
         return context
-
index 497cad1c73e48ba2d872a9e8eb33c7919a04cd83..723ff4d0eda2fd31e96379c2f708a76d1be2665a 100644 (file)
@@ -11,6 +11,11 @@ ADMINS = (
     ('Brett Parker', 'iDunno@sommitrealweird.co.uk'),
 )
 
+ALLOWED_HOSTS = [
+    "www.sommitrealweird.co.uk",
+    "www.sommitrealweird.co.uk.",
+]
+
 MANAGERS = ADMINS
 
 DATABASES = {