Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use YAML aliases #4

Merged
merged 1 commit into from
Feb 5, 2024
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
85 changes: 38 additions & 47 deletions models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 4 additions & 2 deletions models_validator/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down