From e9330b9552858d46783971e8624ccc5ac80cfe46 Mon Sep 17 00:00:00 2001 From: Elrond Date: Sun, 10 Mar 2013 20:56:48 +0100 Subject: [PATCH] 655: Fix collection fetching for media_collect() The problem is: Collection.query.filter_by(id=X, ...) 1. X = form.collection.data This works nicely for the completely empty form (X = None). It does not work for a selected collection, because X will be the collection, not its id. 2. X = request.form.get('collection') (old code). This one works mostly, except for the completely empty form on postgres, because in this case X = u"__None" and postgres does not like comparing an integer column with a string. Fix: collection = form.collection.data if collection and collection.creator != request.user.id: collection = None --- mediagoblin/user_pages/views.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mediagoblin/user_pages/views.py b/mediagoblin/user_pages/views.py index dc562084..c611daa1 100644 --- a/mediagoblin/user_pages/views.py +++ b/mediagoblin/user_pages/views.py @@ -226,9 +226,9 @@ def media_collect(request, media): # Otherwise, use the collection selected from the drop-down else: - collection = Collection.query.filter_by( - id=form.collection.data, - creator=request.user.id).first() + collection = form.collection.data + if collection and collection.creator != request.user.id: + collection = None # Make sure the user actually selected a collection if not collection: -- 2.25.1