Add field restriction_mode to every collectionfield

This commit is contained in:
Oskar Hahn 2021-07-31 10:32:24 +02:00 committed by Finn Stutzenstein
parent 7c6fe46946
commit 552ac0f9d3
No known key found for this signature in database
GPG Key ID: 9042F605C6324654
2 changed files with 832 additions and 133 deletions

View File

@ -203,6 +203,9 @@ class Checker:
def is_normal_field(self, field: str) -> bool: def is_normal_field(self, field: str) -> bool:
return "$" not in field return "$" not in field
def is_calculated_field(self, field: str) -> bool:
return field == "content"
def make_structured(self, field: str, replacement: Any) -> str: def make_structured(self, field: str, replacement: Any) -> str:
if type(replacement) not in (str, int): if type(replacement) not in (str, int):
raise CheckException( raise CheckException(
@ -274,9 +277,14 @@ class Checker:
for x in self.models[collection].keys() for x in self.models[collection].keys()
if self.is_normal_field(x) or self.is_template_field(x) if self.is_normal_field(x) or self.is_template_field(x)
) )
calculated_fields = set(
x
for x in self.models[collection].keys()
if self.is_calculated_field(x)
)
errors = False errors = False
if collection_fields - model_fields: if collection_fields - model_fields - calculated_fields:
error = f"{collection}/{model['id']}: Missing fields {', '.join(collection_fields - model_fields)}" error = f"{collection}/{model['id']}: Missing fields {', '.join(collection_fields - model_fields)}"
self.errors.append(error) self.errors.append(error)
errors = True errors = True

File diff suppressed because it is too large Load Diff