MCPcopy Index your code
hub / github.com/1Panel-dev/MaxKB / ValidSerializer

Class ValidSerializer

apps/system_manage/serializers/valid_serializers.py:36–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34
35
36class ValidSerializer(serializers.Serializer):
37 valid_type = serializers.CharField(required=True, label=_('type'), validators=[
38 validators.RegexValidator(regex=re.compile("^application|knowledge|user$"),
39 message="类型只支持:application|knowledge|user", code=500)
40 ])
41 valid_count = serializers.IntegerField(required=True, label=_('check quantity'))
42
43 def valid(self, is_valid=True):
44 if is_valid:
45 self.is_valid(raise_exception=True)
46 model_value = model_message_dict.get(self.data.get('valid_type'))
47 license_is_valid = cache.get(Cache_Version.SYSTEM.get_key(key='license_is_valid'),
48 version=Cache_Version.SYSTEM.get_version())
49 is_license_valid = license_is_valid if license_is_valid is not None else False
50 if not is_license_valid:
51 if self.data.get('valid_count') != model_value.get('count'):
52 raise AppApiException(400, model_value.get('message'))
53 if QuerySet(
54 model_value.get('model')).count() >= model_value.get('count'):
55 raise AppApiException(400, model_value.get('message'))
56 return True

Callers 1

getMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected