Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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