Skip to content

Commit 5973957

Browse files
committed
fix: 修复license校验问题
1 parent f5fcc01 commit 5973957

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

apps/common/util/common.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,13 @@ def valid_license(model=None, count=None, message=None):
7777
def inner(func):
7878
def run(*args, **kwargs):
7979
xpack_cache = DBModelManage.get_model('xpack_cache')
80-
if ((not False if xpack_cache is None else xpack_cache.get('XPACK_LICENSE_IS_VALID', False))
81-
and QuerySet(
82-
model).count() >= count):
83-
error = message or f'超出限制{count},请联系我们(https://fit2cloud.com/)。'
84-
raise AppApiException(400, error)
80+
is_license_valid = xpack_cache.get('XPACK_LICENSE_IS_VALID', False) if xpack_cache is not None else False
81+
record_count = QuerySet(model).count()
82+
83+
if not is_license_valid and record_count >= count:
84+
error_message = message or f'超出限制{count}, 请联系我们(https://fit2cloud.com/)。'
85+
raise AppApiException(400, error_message)
86+
8587
return func(*args, **kwargs)
8688

8789
return run

apps/setting/serializers/valid_serializers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ def valid(self, is_valid=True):
4141
self.is_valid(raise_exception=True)
4242
model_value = model_message_dict.get(self.data.get('valid_type'))
4343
xpack_cache = DBModelManage.get_model('xpack_cache')
44-
if not False if xpack_cache is None else xpack_cache.get('XPACK_LICENSE_IS_VALID', False):
44+
is_license_valid = xpack_cache.get('XPACK_LICENSE_IS_VALID', False) if xpack_cache is not None else False
45+
if not is_license_valid:
4546
if self.data.get('valid_count') != model_value.get('count'):
4647
raise AppApiException(400, model_value.get('message'))
4748
if QuerySet(

0 commit comments

Comments
 (0)