diff --git a/apps/assets/utils.py b/apps/assets/utils.py index 0f80adec6..e0b316ad7 100644 --- a/apps/assets/utils.py +++ b/apps/assets/utils.py @@ -136,7 +136,10 @@ class TreeService(Tree): if assets: return assets assets = set(self.assets(nid)) - children = self.children(nid) + try: + children = self.children(nid) + except NodeIDAbsentError: + children = [] for child in children: assets.update(self.all_assets(child.identifier)) self.all_nodes_assets_map[nid] = assets diff --git a/apps/audits/models.py b/apps/audits/models.py index 31471edbe..5b53d1c85 100644 --- a/apps/audits/models.py +++ b/apps/audits/models.py @@ -6,6 +6,7 @@ from django.utils.translation import ugettext_lazy as _ from django.utils import timezone from orgs.mixins.models import OrgModelMixin +from orgs.utils import current_org __all__ = [ 'FTPLog', 'OperateLog', 'PasswordChangeLog', 'UserLoginLog', @@ -104,6 +105,9 @@ class UserLoginLog(models.Model): Q(city__contains=keyword) | Q(username__contains=keyword) ) + if not current_org.is_root(): + username_list = current_org.get_org_members().values_list('username', flat=True) + login_logs = login_logs.filter(username__in=username_list) return login_logs class Meta: diff --git a/apps/authentication/signals_handlers.py b/apps/authentication/signals_handlers.py index 7033cf777..c0b48c61d 100644 --- a/apps/authentication/signals_handlers.py +++ b/apps/authentication/signals_handlers.py @@ -47,7 +47,7 @@ def on_openid_login_success(sender, user=None, request=None, **kwargs): @receiver(populate_user) def on_ldap_create_user(sender, user, ldap_user, **kwargs): - if user and user.name != 'admin': + if user and user.username != 'admin': user.source = user.SOURCE_LDAP user.save() diff --git a/apps/authentication/templates/authentication/_access_key_modal.html b/apps/authentication/templates/authentication/_access_key_modal.html index 5686c212d..ac5b26d54 100644 --- a/apps/authentication/templates/authentication/_access_key_modal.html +++ b/apps/authentication/templates/authentication/_access_key_modal.html @@ -21,7 +21,7 @@
diff --git a/apps/perms/api/user_remote_app_permission.py b/apps/perms/api/user_remote_app_permission.py index 868c92015..51a9217ce 100644 --- a/apps/perms/api/user_remote_app_permission.py +++ b/apps/perms/api/user_remote_app_permission.py @@ -53,6 +53,8 @@ class UserGrantedRemoteAppsAsTreeApi(UserGrantedRemoteAppsApi): permission_classes = (IsOrgAdminOrAppUser,) def get_serializer(self, remote_apps=None, *args, **kwargs): + if remote_apps is None: + remote_apps = [] only_remote_app = self.request.query_params.get('only', '0') == '1' tree_root = None data = [] diff --git a/apps/terminal/api/command.py b/apps/terminal/api/command.py index c18de010f..1dfd0ad3b 100644 --- a/apps/terminal/api/command.py +++ b/apps/terminal/api/command.py @@ -29,6 +29,9 @@ class CommandQueryMixin: default_days_ago = 5 def get_queryset(self): + # 解决访问 /docs/ 问题 + if hasattr(self, 'swagger_fake_view'): + return self.command_store.model.objects.none() date_from, date_to = self.get_date_range() q = self.request.query_params multi_command_storage = get_multi_command_storage() |
---|