diff --git a/models.yml b/models.yml index 4a3df669..2911ebb2 100644 --- a/models.yml +++ b/models.yml @@ -57,6 +57,31 @@ # The field `restriction_mode` is required for every field. It puts the field into a # restriction group. See https://github.com/OpenSlides/OpenSlides/wiki/Restrictions-Overview +_meta: # meta field to hold repeatedly used values + languages: &languages + - en + - de + - it + - es + - ru + - cs + ballot_paper_selection: &ballot_paper_selection + - NUMBER_OF_DELEGATES + - NUMBER_OF_ALL_PARTICIPANTS + - CUSTOM_NUMBER + poll_backends: &poll_backends + - long + - fast + onehundred_percent_bases: &onehundred_percent_bases + - "Y" + - "YN" + - "YNA" + - "N" + - "valid" + - "cast" + - "entitled" + - "disabled" + organization: id: type: number @@ -112,13 +137,7 @@ organization: default_language: type: string restriction_mode: A - enum: - - en - - de - - it - - es - - ru - - cs + enum: *languages required: true # Saml settings @@ -755,13 +774,7 @@ meeting: language: type: string restriction_mode: A - enum: - - en - - de - - it - - es - - ru - - cs + enum: *languages required: true # Configuration (only for the server owner) @@ -1194,10 +1207,7 @@ meeting: # Motion poll motion_poll_ballot_paper_selection: type: string - enum: - - NUMBER_OF_DELEGATES - - NUMBER_OF_ALL_PARTICIPANTS - - CUSTOM_NUMBER + enum: *ballot_paper_selection default: CUSTOM_NUMBER restriction_mode: B motion_poll_ballot_paper_number: @@ -1210,6 +1220,7 @@ meeting: restriction_mode: B motion_poll_default_onehundred_percent_base: type: string + enum: *onehundred_percent_bases default: YNA restriction_mode: B motion_poll_default_group_ids: @@ -1218,10 +1229,8 @@ meeting: restriction_mode: B motion_poll_default_backend: type: string + enum: *poll_backends default: fast - enum: - - long - - fast restriction_mode: B # poll list election @@ -1321,10 +1330,7 @@ meeting: # Assignment polls assignment_poll_ballot_paper_selection: type: string - enum: - - NUMBER_OF_DELEGATES - - NUMBER_OF_ALL_PARTICIPANTS - - CUSTOM_NUMBER + enum: *ballot_paper_selection default: CUSTOM_NUMBER restriction_mode: B assignment_poll_ballot_paper_number: @@ -1353,6 +1359,7 @@ meeting: restriction_mode: B assignment_poll_default_onehundred_percent_base: type: string + enum: *onehundred_percent_bases default: valid restriction_mode: B assignment_poll_default_group_ids: @@ -1361,19 +1368,14 @@ meeting: restriction_mode: B assignment_poll_default_backend: type: string + enum: *poll_backends default: fast - enum: - - long - - fast restriction_mode: B # Polls poll_ballot_paper_selection: type: string - enum: - - NUMBER_OF_DELEGATES - - NUMBER_OF_ALL_PARTICIPANTS - - CUSTOM_NUMBER + enum: *ballot_paper_selection restriction_mode: B poll_ballot_paper_number: type: number @@ -1390,6 +1392,7 @@ meeting: restriction_mode: B poll_default_onehundred_percent_base: type: string + enum: *onehundred_percent_bases default: YNA restriction_mode: B poll_default_group_ids: @@ -1398,10 +1401,8 @@ meeting: restriction_mode: B poll_default_backend: type: string + enum: *poll_backends default: fast - enum: - - long - - fast restriction_mode: B poll_couple_countdown: type: boolean @@ -2931,10 +2932,8 @@ poll: backend: type: string required: True + enum: *poll_backends default: fast - enum: - - long - - fast restriction_mode: A is_pseudoanonymized: type: boolean @@ -2987,15 +2986,7 @@ poll: onehundred_percent_base: type: string required: true - enum: - - "Y" - - "YN" - - "YNA" - - "N" - - "valid" - - "cast" - - "entitled" - - "disabled" + enum: *onehundred_percent_bases default: disabled restriction_mode: A votesvalid: diff --git a/models_validator/validate.py b/models_validator/validate.py index f7bc6685..690d73c5 100644 --- a/models_validator/validate.py +++ b/models_validator/validate.py @@ -72,8 +72,10 @@ def run_check(self) -> None: raise CheckException("\n".join(errors)) def _run_checks(self) -> None: - for collection in self.models.keys(): - if not COLLECTION_REGEX.match(collection): + for collection in list(self.models.keys()): + if collection.startswith("_"): + self.models.pop(collection) + elif not COLLECTION_REGEX.match(collection): self.errors.append(f"Collection '{collection}' is not valid.") if self.errors: return