Skip to content

Use real enums#424

Open
vkrasnovyd wants to merge 21 commits intoOpenSlides:mainfrom
vkrasnovyd:409-real-enums
Open

Use real enums#424
vkrasnovyd wants to merge 21 commits intoOpenSlides:mainfrom
vkrasnovyd:409-real-enums

Conversation

@vkrasnovyd
Copy link
Copy Markdown
Contributor

@vkrasnovyd vkrasnovyd commented Mar 19, 2026

Resolves #409

Additionally to implementing enums:

  • Replaced anchors for enums in the collection-meta.yml with strings. This allowed me to revert the changes in build_models_yaml_content from Define collections defaults in collections-meta.yml #411 and parse the collections files separately again;
  • Defined new attribute for number fields: maximum. Adjusted generator, validator and HelperGetNames to use it. Replaced enum with minimum and maximu for meeting.export_pdf_fontsize;
  • Added a bunch of checks for enums and defaults in validate-models-yml;
  • Updated views generation for collections with enum[] types to keep receiving text arrays and not enum arrays when reading the data.

@vkrasnovyd vkrasnovyd marked this pull request as draft March 19, 2026 18:15
Copy link
Copy Markdown
Member

@hjanott hjanott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not convert enum[] to text[]. This will make code less generic for go services.
If we need this conversion for the backend-service maybe we can register our enums in psycopg. https://www.psycopg.org/psycopg3/docs/basic/adapt.html#enum-adaptation

- entitled
- entitled_present
- disabled
id_field: &id_field
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do it in a separate PR, as it will not change the generated schema.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created an issue #431.

return trigger_text

@staticmethod
def get_initials(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the purpose of this function by its name. :/
Let's change it and/or write a doc string.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a docstring.

for line in Path(yaml_file).read_text().splitlines(keepends=True)
)
data = yaml.safe_load("".join(yaml_content))
with open(yaml_file, "rb") as f:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So much simpler. I like.

@hjanott hjanott assigned vkrasnovyd and unassigned hjanott Mar 23, 2026
@vkrasnovyd vkrasnovyd removed their assignment Mar 25, 2026
@vkrasnovyd vkrasnovyd assigned vkrasnovyd and unassigned hjanott Mar 26, 2026
vkrasnovyd and others added 4 commits March 26, 2026 18:33
Co-authored-by: Hannes Janott <hannes.janott@openslides.com>
Co-authored-by: Hannes Janott <hannes.janott@openslides.com>
@vkrasnovyd vkrasnovyd requested a review from hjanott March 27, 2026 08:33
@vkrasnovyd vkrasnovyd assigned hjanott and unassigned vkrasnovyd Mar 27, 2026
Copy link
Copy Markdown
Member

@hjanott hjanott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks finished to me now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use real enums

2 participants