fix: 修复license校验问题
parent
f5fcc01113
commit
5973957037
|
|
@ -77,11 +77,13 @@ def valid_license(model=None, count=None, message=None):
|
||||||
def inner(func):
|
def inner(func):
|
||||||
def run(*args, **kwargs):
|
def run(*args, **kwargs):
|
||||||
xpack_cache = DBModelManage.get_model('xpack_cache')
|
xpack_cache = DBModelManage.get_model('xpack_cache')
|
||||||
if ((not False if xpack_cache is None else xpack_cache.get('XPACK_LICENSE_IS_VALID', False))
|
is_license_valid = xpack_cache.get('XPACK_LICENSE_IS_VALID', False) if xpack_cache is not None else False
|
||||||
and QuerySet(
|
record_count = QuerySet(model).count()
|
||||||
model).count() >= count):
|
|
||||||
error = message or f'超出限制{count},请联系我们(https://fit2cloud.com/)。'
|
if not is_license_valid and record_count >= count:
|
||||||
raise AppApiException(400, error)
|
error_message = message or f'超出限制{count}, 请联系我们(https://fit2cloud.com/)。'
|
||||||
|
raise AppApiException(400, error_message)
|
||||||
|
|
||||||
return func(*args, **kwargs)
|
return func(*args, **kwargs)
|
||||||
|
|
||||||
return run
|
return run
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,8 @@ class ValidSerializer(serializers.Serializer):
|
||||||
self.is_valid(raise_exception=True)
|
self.is_valid(raise_exception=True)
|
||||||
model_value = model_message_dict.get(self.data.get('valid_type'))
|
model_value = model_message_dict.get(self.data.get('valid_type'))
|
||||||
xpack_cache = DBModelManage.get_model('xpack_cache')
|
xpack_cache = DBModelManage.get_model('xpack_cache')
|
||||||
if not False if xpack_cache is None else xpack_cache.get('XPACK_LICENSE_IS_VALID', False):
|
is_license_valid = xpack_cache.get('XPACK_LICENSE_IS_VALID', False) if xpack_cache is not None else False
|
||||||
|
if not is_license_valid:
|
||||||
if self.data.get('valid_count') != model_value.get('count'):
|
if self.data.get('valid_count') != model_value.get('count'):
|
||||||
raise AppApiException(400, model_value.get('message'))
|
raise AppApiException(400, model_value.get('message'))
|
||||||
if QuerySet(
|
if QuerySet(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue