Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions apps/common/util/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,13 @@ def valid_license(model=None, count=None, message=None):
def inner(func):
def run(*args, **kwargs):
xpack_cache = DBModelManage.get_model('xpack_cache')
if ((not False if xpack_cache is None else xpack_cache.get('XPACK_LICENSE_IS_VALID', False))
and QuerySet(
model).count() >= count):
error = message or f'超出限制{count},请联系我们(https://fit2cloud.com/)。'
raise AppApiException(400, error)
is_license_valid = xpack_cache.get('XPACK_LICENSE_IS_VALID', False) if xpack_cache is not None else False
record_count = QuerySet(model).count()

if not is_license_valid and record_count >= count:
error_message = message or f'超出限制{count}, 请联系我们(https://fit2cloud.com/)。'
raise AppApiException(400, error_message)

return func(*args, **kwargs)

return run
Expand Down
3 changes: 2 additions & 1 deletion apps/setting/serializers/valid_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ def valid(self, is_valid=True):
self.is_valid(raise_exception=True)
model_value = model_message_dict.get(self.data.get('valid_type'))
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'):
raise AppApiException(400, model_value.get('message'))
if QuerySet(
Expand Down
Loading