From e108aae3c01da04c4ac238ed770ae3037f8b0bf4 Mon Sep 17 00:00:00 2001 From: BaiJiangJie Date: Tue, 14 May 2019 21:39:34 +0800 Subject: [PATCH 1/2] =?UTF-8?q?[Bugfix]=20=E4=BF=AE=E5=A4=8DAssetUserManag?= =?UTF-8?q?er.get=E8=8E=B7=E5=8F=96username=E4=B8=BA""=E7=9A=84AuthBook?= =?UTF-8?q?=E5=AF=B9=E8=B1=A1=E6=97=B6=EF=BC=8C=E8=BF=94=E5=9B=9E=E5=A4=9A?= =?UTF-8?q?=E4=B8=AA=E7=BB=93=E6=9E=9C=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/backends/external/db.py | 2 +- apps/assets/backends/internal/admin_user.py | 2 +- apps/assets/backends/internal/system_user.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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 From 54a9070c58f307d6bca03e4031e4e517d17f81aa Mon Sep 17 00:00:00 2001 From: BaiJiangJie Date: Thu, 16 May 2019 10:36:47 +0800 Subject: [PATCH 2/2] =?UTF-8?q?[Update]=20=E8=B5=84=E4=BA=A7=E8=8A=82?= =?UTF-8?q?=E7=82=B9API=E6=B7=BB=E5=8A=A0search=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/api/node.py | 2 ++ 1 file changed, 2 insertions(+) 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