]> git.sommitrealweird.co.uk Git - sommitrealweird.git/commitdiff
Merge branch 'master' of /home/brettp/sommitrealweird
authorBrett Parker <iDunno@sommitrealweird.co.uk>
Sun, 8 Nov 2009 19:42:02 +0000 (19:42 +0000)
committerBrett Parker <iDunno@sommitrealweird.co.uk>
Sun, 8 Nov 2009 19:42:02 +0000 (19:42 +0000)
sommitrealweird/django.wsgi [new file with mode: 0644]
sommitrealweird/photo/views.py

diff --git a/sommitrealweird/django.wsgi b/sommitrealweird/django.wsgi
new file mode 100644 (file)
index 0000000..3fa5191
--- /dev/null
@@ -0,0 +1,9 @@
+import os, sys
+sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
+sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '.')))
+sys.path.append('/usr/local/django')
+os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
+
+import django.core.handlers.wsgi
+
+application = django.core.handlers.wsgi.WSGIHandler()
index 920b1da04e8fe556d97ebd08e58778c991c581be..02d80e67be0435a7dd04554ac6f9cc5b5b7be9f6 100644 (file)
@@ -3,28 +3,34 @@ from django.http import Http404
 from models import Album, Photo
 
 def album_view(request, slug):
-    album = Album.objects.get(slug__exact=slug)
-    photos = Photo.objects.filter(album=album).order_by('order', 'image')
-    return django.views.generic.list_detail.object_list(request, photos, paginate_by=20, template_name='photo/photo_index.html')
+    try:
+        album = Album.objects.get(slug__exact=slug)
+        photos = Photo.objects.filter(album=album).order_by('order', 'image')
+    except:
+        raise Http404
+    return django.views.generic.list_detail.object_list(request, photos, paginate_by=20, template_name='photo/photo_index.html', allow_empty=False)
 
 def photo_view(request, slug, id):
-    id = int(id)
-    album = Album.objects.get(slug__exact=slug)
-    photos = Photo.objects.filter(album=album).order_by('order', 'image')
-    photo_qs = Photo.objects.filter(id=id)
-    found_prev = False
-    prev_photo = None
-    found_next = False
-    next_photo = None
-    for photo in photos:
-        if not found_prev:
-            if not photo.id == id:
-                prev_photo = photo
-            else:
-                found_prev = True
-        if found_next:
-            next_photo = photo
-            break
-        if photo.id == id:
-            found_next = True
+    try:
+        id = int(id)
+        album = Album.objects.get(slug__exact=slug)
+        photos = Photo.objects.filter(album=album).order_by('order', 'image')
+        photo_qs = Photo.objects.filter(id=id)
+        found_prev = False
+        prev_photo = None
+        found_next = False
+        next_photo = None
+        for photo in photos:
+            if not found_prev:
+                if not photo.id == id:
+                    prev_photo = photo
+                else:
+                    found_prev = True
+            if found_next:
+                next_photo = photo
+                break
+            if photo.id == id:
+                found_next = True
+    except:
+        raise Http404
     return django.views.generic.list_detail.object_detail(request, photo_qs, object_id=id, template_name='photo/photo.html', extra_context={"next_photo": next_photo, "prev_photo": prev_photo })