diff --git a/apps/assets/api/node.py b/apps/assets/api/node.py index 51e830efc..f772a2ace 100644 --- a/apps/assets/api/node.py +++ b/apps/assets/api/node.py @@ -39,6 +39,8 @@ __all__ = [ class NodeViewSet(viewsets.ModelViewSet): + filter_fields = ('value', 'key', ) + search_fields = filter_fields queryset = Node.objects.all() permission_classes = (IsOrgAdmin,) serializer_class = serializers.NodeSerializer diff --git a/apps/assets/backends/external/db.py b/apps/assets/backends/external/db.py index f3f6c16d6..eedafd336 100644 --- a/apps/assets/backends/external/db.py +++ b/apps/assets/backends/external/db.py @@ -11,7 +11,7 @@ class AuthBookBackend(BaseBackend): @classmethod def filter(cls, username=None, asset=None, latest=True): queryset = AuthBook.objects.all() - if username: + if username is not None: queryset = queryset.filter(username=username) if asset: queryset = queryset.filter(asset=asset) diff --git a/apps/assets/backends/internal/admin_user.py b/apps/assets/backends/internal/admin_user.py index e67b41fc9..abd32b5ae 100644 --- a/apps/assets/backends/internal/admin_user.py +++ b/apps/assets/backends/internal/admin_user.py @@ -27,7 +27,7 @@ class AdminUserBackend(BaseBackend): instances = [] assets = cls._get_assets(asset) for asset in assets: - if username and asset.admin_user.username != username: + if username is not None and asset.admin_user.username != username: continue instance = construct_authbook_object(asset.admin_user, asset) instances.append(instance) diff --git a/apps/assets/backends/internal/system_user.py b/apps/assets/backends/internal/system_user.py index 52b22215c..b1413fedb 100644 --- a/apps/assets/backends/internal/system_user.py +++ b/apps/assets/backends/internal/system_user.py @@ -30,7 +30,7 @@ class SystemUserBackend(BaseBackend): @classmethod def _filter_system_users_by_username(cls, system_users, username): _system_users = cls._distinct_system_users_by_username(system_users) - if username: + if username is not None: _system_users = [su for su in _system_users if username == su.username] return _system_users