Fix errors in collection views
authorJoar Wandborg <joar@wandborg.se>
Mon, 18 Feb 2013 13:41:34 +0000 (14:41 +0100)
committerJoar Wandborg <joar@wandborg.se>
Mon, 18 Feb 2013 13:41:34 +0000 (14:41 +0100)
When a collection does not exist, render the 404 page.

mediagoblin/user_pages/views.py

index 811d35784d065030ce64fb248ade5ecba062b67e..0225b6d74753253a5c2506dae4c26005ae6f9d00 100644 (file)
@@ -309,6 +309,9 @@ def user_collection(request, page, url_user=None):
         get_creator=url_user,
         slug=request.matchdict['collection']).first()
 
+    if not collection:
+        return render_404(request)
+
     cursor = collection.get_collection_items()
 
     pagination = Pagination(page, cursor)
@@ -515,6 +518,8 @@ def collection_atom_feed(request):
     collection = Collection.query.filter_by(
                creator=user.id,
                slug=request.matchdict['collection']).first()
+    if not collection:
+        return render_404(request)
 
     cursor = CollectionItem.query.filter_by(
                  collection=collection.id) \