Skip to content

Commit

Permalink
Merge pull request kobotoolbox#2068 from kobotoolbox/2061-duplicate-a…
Browse files Browse the repository at this point in the history
…ssets

2061 duplicate assets
  • Loading branch information
jnm authored Nov 10, 2018
2 parents 3d04616 + 475037d commit bed6475
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions kpi/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def filter_queryset(self, request, queryset, view):
get_anonymous_user(), permission, queryset)
if view.action != 'list':
# Not a list, so discoverability doesn't matter
return owned_and_explicitly_shared | public
return (owned_and_explicitly_shared | public).distinct()

# For a list, do not include public objects unless they are also
# discoverable
Expand All @@ -85,7 +85,7 @@ def filter_queryset(self, request, queryset, view):
if all_public:
# We were asked not to consider subscriptions; return all
# discoverable objects
return owned_and_explicitly_shared | discoverable
return (owned_and_explicitly_shared | discoverable).distinct()

# Of the discoverable objects, determine to which the user has
# subscribed
Expand All @@ -101,7 +101,7 @@ def filter_queryset(self, request, queryset, view):
# Neither the model or its parent has a subscription relation
subscribed = public.none()

return owned_and_explicitly_shared | subscribed
return (owned_and_explicitly_shared | subscribed).distinct()


class RelatedAssetPermissionsFilter(KpiObjectPermissionsFilter):
Expand Down
1 change: 1 addition & 0 deletions kpi/models/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,7 @@ def has_active_hooks(self):
:return: {boolean}
"""
return self.hooks.filter(active=True).exists()

@staticmethod
def optimize_queryset_for_list(queryset):
''' Used by serializers to improve performance when listing assets '''
Expand Down

0 comments on commit bed6475

Please sign in to comment.