From 08bc3d14aa101fa7b8ca8a36eb6a33b2682207bd Mon Sep 17 00:00:00 2001 From: ibuler Date: Thu, 20 Jul 2023 14:46:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20json=20m2m=20field?= =?UTF-8?q?=20=E4=B8=AD=E6=AD=A3=E5=88=99=E6=9C=89=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E5=8C=B9=E9=85=8D=E4=B8=8D=E6=AD=A3=E7=A1=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/common/db/fields.py | 2 +- apps/perms/tasks.py | 21 +++++++++++---------- apps/terminal/utils/db_port_mapper.py | 1 + requirements/issues.txt | 6 +++++- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/apps/common/db/fields.py b/apps/common/db/fields.py index aff54c75a..dee051da5 100644 --- a/apps/common/db/fields.py +++ b/apps/common/db/fields.py @@ -387,7 +387,7 @@ class RelatedManager: lookup = "{}__{}".format(name, match) q = Q(**{lookup: val}) except re.error: - q = ~Q() + q = Q(pk__isnull=True) elif match == "not": q = ~Q(**{name: val}) elif match in ['m2m', 'in']: diff --git a/apps/perms/tasks.py b/apps/perms/tasks.py index 4420322d1..82f97bf8c 100644 --- a/apps/perms/tasks.py +++ b/apps/perms/tasks.py @@ -1,25 +1,25 @@ # ~*~ coding: utf-8 ~*~ from __future__ import absolute_import, unicode_literals -from datetime import timedelta + from collections import defaultdict +from datetime import timedelta -from django.db.transaction import atomic -from django.conf import settings from celery import shared_task +from django.conf import settings +from django.db.transaction import atomic +from django.utils.translation import gettext_lazy as _ -from ops.celery.decorator import register_as_period_task -from orgs.utils import tmp_to_root_org +from common.const.crontab import CRONTAB_AT_AM_TEN from common.utils import get_logger from common.utils.timezone import local_now, dt_parser -from common.const.crontab import CRONTAB_AT_AM_TEN - +from ops.celery.decorator import register_as_period_task +from orgs.utils import tmp_to_root_org from perms.models import AssetPermission -from perms.utils import UserPermTreeExpireUtil from perms.notifications import ( PermedAssetsWillExpireUserMsg, AssetPermsWillExpireForOrgAdminMsg, ) -from django.utils.translation import gettext_lazy as _ +from perms.utils import UserPermTreeExpireUtil logger = get_logger(__file__) @@ -32,7 +32,8 @@ def check_asset_permission_expired(): """ 这里的任务要足够短,不要影响周期任务 """ perms = AssetPermission.objects.get_expired_permissions() perm_ids = list(perms.distinct().values_list('id', flat=True)) - logger.info(f'Checking expired permissions: {perm_ids}') + show_perm_ids = perm_ids[:5] + logger.info(f'Checking expired permissions: {show_perm_ids} ...') UserPermTreeExpireUtil().expire_perm_tree_for_perms(perm_ids) diff --git a/apps/terminal/utils/db_port_mapper.py b/apps/terminal/utils/db_port_mapper.py index f5405f97e..9d335859a 100644 --- a/apps/terminal/utils/db_port_mapper.py +++ b/apps/terminal/utils/db_port_mapper.py @@ -79,6 +79,7 @@ class DBPortManager(object): for port, db_id in mapper.items(): if db_id == str(db.id): return port + if raise_exception: error = _( 'No available port is matched. ' diff --git a/requirements/issues.txt b/requirements/issues.txt index 5db4004a7..768d95e1e 100644 --- a/requirements/issues.txt +++ b/requirements/issues.txt @@ -1,6 +1,6 @@ # Install cryptography error: build/temp.macosx-10.13-intel-2.7/_openssl.c:483:10: fatal error: 'openssl/opensslv.h' file not found -$ pip install cryptography --global-option=build_ext --global-option="-L/usr/local/opt/openssl/lib" --global-option="-I/usr/local/opt/openssl/include" +$ pip install cryptography --global-option=build_ext --global-option="-L/opt/homebrew/Cellar/openssl@3/3.1.1_1/lib" --global-option="-I/opt/homebrew/Cellar/openssl@3/3.1.1_1/include" # Pillow zlib failed @@ -9,3 +9,7 @@ Reinstall xcode reslove $ xcode-select --install + +# libxmlsec 报错 +wget 'https://raw.githubusercontent.com/Homebrew/homebrew-core/7f35e6ede954326a10949891af2dba47bbe1fc17/Formula/libxmlsec1.rb' +brew install ./libxmlsec1.rb