[vote] Update meeting defaults for polls#3644
Conversation
6a4dca2 to
3ee862c
Compare
luisa-beerboom
left a comment
There was a problem hiding this comment.
Idk what I think about this new collection, however the code looks mostly good to me.
|
|
||
| # Set poll defaults | ||
| poll_default_field_name_pattern = re.compile( | ||
| r"([a-z]+)_poll_default_([a-z_]+[a-z]+)" |
There was a problem hiding this comment.
I think
| r"([a-z]+)_poll_default_([a-z_]+[a-z]+)" | |
| r"([a-z]+)_poll_default_(([a-z]+_)*[a-z]+)" |
might be more accurate to the pattern you're trying to match, though I wonder if a regex isn't a bit overkill for now.
There was a problem hiding this comment.
You are right. I've just realized that .split() would do the same job in this case.
| poll_type_field_name, poll_type_field_value = next( | ||
| iter(poll_types_fields.items()) | ||
| ) | ||
| self.check_equal_fields(instance, poll_type_field_name, poll_type_field_value) |
There was a problem hiding this comment.
This setup of grabbing the next value in a dict iteration and checking only that seems somewhat incomplete unless one knows that there can be only one of the POLL_TYPE_FIELDS in the instance.
I'd suggest either using a for loop or writing an explanatory comment.
There was a problem hiding this comment.
The check above raises error if number of items in poll_types_fields is not 1. Descriptions of the helper methods were not really descriptive indeed. Added proper docstrings.
Adjusts backend to the changes in OpenSlides/openslides-meta#532
How the poll_default settings fields of the meeting will be migrated is described here: https://github.com/OpenSlides/openslides-vote-service/tree/feature/vote/Migration.md#meeting