diff options
author | ayleph <ayleph@thisshitistemp.com> | 2017-06-28 21:49:29 -0700 |
---|---|---|
committer | Andrew Browning <ayleph@thisshitistemp.com> | 2017-08-15 02:39:00 -0400 |
commit | 763eae89d9c13459a9e8ef1de384a7025d5820dd (patch) | |
tree | 71de72cfeebd57b1c76834314b30e046042fd3b8 /mediagoblin/user_pages/views.py | |
parent | 5487c3b0d95313aff67dd3a2b6fbb2007119ac53 (diff) | |
download | mediagoblin-763eae89d9c13459a9e8ef1de384a7025d5820dd.tar.lz mediagoblin-763eae89d9c13459a9e8ef1de384a7025d5820dd.tar.xz mediagoblin-763eae89d9c13459a9e8ef1de384a7025d5820dd.zip |
Fix #5514 - Add to Collection causes server error
Re-arrange code to check whether a collection has been selected prior
to checking whether an item already exists in the selected collection.
This fixes a regression introduced in 0f3bf8d.
Diffstat (limited to 'mediagoblin/user_pages/views.py')
-rw-r--r-- | mediagoblin/user_pages/views.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/mediagoblin/user_pages/views.py b/mediagoblin/user_pages/views.py index ab235695..b4737ea8 100644 --- a/mediagoblin/user_pages/views.py +++ b/mediagoblin/user_pages/views.py @@ -297,12 +297,6 @@ def media_collect(request, media): collection = None # Make sure the user actually selected a collection - item = CollectionItem.query.filter_by(collection=collection.id) - item = item.join(CollectionItem.object_helper).filter_by( - model_type=media.__tablename__, - obj_pk=media.id - ).first() - if not collection: messages.add_message( request, @@ -312,8 +306,14 @@ def media_collect(request, media): user=media.get_actor.username, media_id=media.id) + item = CollectionItem.query.filter_by(collection=collection.id) + item = item.join(CollectionItem.object_helper).filter_by( + model_type=media.__tablename__, + obj_pk=media.id + ).first() + # Check whether media already exists in collection - elif item is not None: + if item is not None: messages.add_message( request, messages.ERROR, |