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

Add new defaults to motion_state #2101

Merged
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
15 changes: 14 additions & 1 deletion global/data/example-data.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"_migration_index": 47,
"_migration_index": 48,
"organization": {
"1": {
"id": 1,
Expand Down Expand Up @@ -1531,6 +1531,7 @@
"allow_submitter_edit": false,
"allow_create_poll": false,
"allow_support": false,
"set_workflow_timestamp": false,
"allow_motion_forwarding": true,
"meeting_id": 1
},
Expand All @@ -1553,6 +1554,7 @@
"allow_create_poll": false,
"allow_support": false,
"allow_motion_forwarding": true,
"set_workflow_timestamp": false,
"meeting_id": 1
},
"4": {
Expand All @@ -1574,6 +1576,7 @@
"allow_create_poll": false,
"allow_support": false,
"allow_motion_forwarding": true,
"set_workflow_timestamp": false,
"meeting_id": 1
},
"5": {
Expand Down Expand Up @@ -1622,6 +1625,7 @@
"allow_create_poll": false,
"allow_support": true,
"allow_motion_forwarding": true,
"set_workflow_timestamp": false,
"meeting_id": 1
},
"7": {
Expand Down Expand Up @@ -1655,6 +1659,7 @@
"allow_create_poll": true,
"allow_support": false,
"allow_motion_forwarding": true,
"set_workflow_timestamp": false,
"meeting_id": 1
},
"8": {
Expand All @@ -1676,6 +1681,7 @@
"allow_create_poll": false,
"allow_support": false,
"allow_motion_forwarding": true,
"set_workflow_timestamp": false,
"meeting_id": 1
},
"9": {
Expand All @@ -1697,6 +1703,7 @@
"allow_create_poll": false,
"allow_support": false,
"allow_motion_forwarding": true,
"set_workflow_timestamp": false,
"meeting_id": 1
},
"10": {
Expand All @@ -1719,6 +1726,7 @@
"allow_create_poll": false,
"allow_support": false,
"allow_motion_forwarding": true,
"set_workflow_timestamp": false,
"meeting_id": 1
},
"11": {
Expand All @@ -1740,6 +1748,7 @@
"allow_create_poll": false,
"allow_support": false,
"allow_motion_forwarding": true,
"set_workflow_timestamp": false,
"meeting_id": 1
},
"12": {
Expand All @@ -1761,6 +1770,7 @@
"allow_create_poll": false,
"allow_support": false,
"allow_motion_forwarding": true,
"set_workflow_timestamp": false,
"meeting_id": 1
},
"13": {
Expand All @@ -1782,6 +1792,7 @@
"allow_create_poll": false,
"allow_support": false,
"allow_motion_forwarding": true,
"set_workflow_timestamp": false,
"meeting_id": 1
},
"14": {
Expand All @@ -1802,6 +1813,7 @@
"allow_create_poll": false,
"allow_support": false,
"allow_motion_forwarding": true,
"set_workflow_timestamp": false,
"meeting_id": 1
},
"15": {
Expand All @@ -1823,6 +1835,7 @@
"allow_create_poll": false,
"allow_support": false,
"allow_motion_forwarding": true,
"set_workflow_timestamp": false,
"meeting_id": 1
}
},
Expand Down
2 changes: 1 addition & 1 deletion global/data/initial-data.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"_migration_index": 47,
"_migration_index": 48,
"organization": {
"1": {
"id": 1,
Expand Down
2 changes: 2 additions & 0 deletions global/meta/models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2737,9 +2737,11 @@ motion_state:
allow_motion_forwarding:
type: boolean
restriction_mode: A
default: false
set_workflow_timestamp:
type: boolean
restriction_mode: A
default: false
submitter_withdraw_state_id:
type: relation
to: motion_state/submitter_withdraw_back_ids
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from typing import Any, Dict, List, Optional

from datastore.migrations import BaseModelMigration
from datastore.shared.util import fqid_from_collection_and_id
from datastore.writer.core import BaseRequestEvent, RequestUpdateEvent


class Migration(BaseModelMigration):
"""
This migration adds false boolean default to the motion_state's fields set_workflow_timestamp and allow_motion_forwarding.
"""

target_migration_index = 48
fields = ["set_workflow_timestamp", "allow_motion_forwarding"]

def migrate_models(self) -> Optional[List[BaseRequestEvent]]:
events: List[BaseRequestEvent] = []
db_models = self.reader.get_all("motion_state")
for id, model in db_models.items():
update: Dict[str, Any] = {
field: False for field in self.fields if field not in model
}
if len(update):
events.append(
RequestUpdateEvent(
fqid_from_collection_and_id("motion_state", id), update
)
)
return events
6 changes: 3 additions & 3 deletions openslides_backend/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from .base import Model
from .mixins import AgendaItemModelMixin, MeetingModelMixin, PollModelMixin

MODELS_YML_CHECKSUM = "d72f341534e83d6f62b306f9c7de7dc8"
MODELS_YML_CHECKSUM = "199a53035f313e1a429476bf78c98fa8"


class Organization(Model):
Expand Down Expand Up @@ -1442,8 +1442,8 @@ class MotionState(Model):
default="undefined",
constraints={"enum": ["do_not_merge", "undefined", "do_merge"]},
)
allow_motion_forwarding = fields.BooleanField()
set_workflow_timestamp = fields.BooleanField()
allow_motion_forwarding = fields.BooleanField(default=False)
set_workflow_timestamp = fields.BooleanField(default=False)
submitter_withdraw_state_id = fields.RelationField(
to={"motion_state": "submitter_withdraw_back_ids"},
equal_fields=["meeting_id", "workflow_id"],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
def test_migration(write, finalize, assert_model):
write(
{
"type": "create",
"fqid": "motion_state/11",
"fields": {
"id": 11,
"name": "received",
"recommendation_label": "receival",
"css_class": "lightblue",
"restrictions": [],
"allow_support": False,
"allow_create_poll": False,
"allow_submitter_edit": False,
"set_number": True,
"show_state_extension_field": False,
"merge_amendment_into_final": "do_not_merge",
"show_recommendation_extension_field": False,
"weight": 1,
},
},
{
"type": "create",
"fqid": "motion_state/12",
"fields": {
"id": 12,
"name": "failed",
"recommendation_label": "failure",
"css_class": "red",
"restrictions": [],
"allow_support": False,
"allow_create_poll": False,
"allow_submitter_edit": False,
"set_workflow_timestamp": True,
"set_number": True,
"show_state_extension_field": False,
"merge_amendment_into_final": "do_not_merge",
"show_recommendation_extension_field": False,
"weight": 2,
},
},
{
"type": "create",
"fqid": "motion_state/13",
"fields": {
"id": 13,
"name": "successful",
"recommendation_label": "success",
"css_class": "green",
"restrictions": [],
"allow_support": False,
"allow_create_poll": False,
"allow_submitter_edit": False,
"allow_motion_forwarding": False,
"set_number": True,
"show_state_extension_field": False,
"merge_amendment_into_final": "do_not_merge",
"show_recommendation_extension_field": False,
"weight": 3,
},
},
{
"type": "create",
"fqid": "motion_state/14",
"fields": {
"id": 14,
"name": "illegal",
"recommendation_label": "illegalize",
"css_class": "lightblue",
"restrictions": [],
"allow_support": False,
"allow_create_poll": False,
"allow_submitter_edit": False,
"allow_motion_forwarding": False,
"set_workflow_timestamp": True,
"set_number": True,
"show_state_extension_field": False,
"merge_amendment_into_final": "do_not_merge",
"show_recommendation_extension_field": False,
"weight": 4,
},
},
)

finalize("0047_add_workflow_state_boolean_defaults")

assert_model(
"motion_state/11",
{
"id": 11,
"name": "received",
"recommendation_label": "receival",
"css_class": "lightblue",
"restrictions": [],
"allow_support": False,
"allow_create_poll": False,
"allow_submitter_edit": False,
"set_number": True,
"show_state_extension_field": False,
"merge_amendment_into_final": "do_not_merge",
"show_recommendation_extension_field": False,
"weight": 1,
"allow_motion_forwarding": False,
"set_workflow_timestamp": False,
},
)
assert_model(
"motion_state/12",
{
"id": 12,
"name": "failed",
"recommendation_label": "failure",
"css_class": "red",
"restrictions": [],
"allow_support": False,
"allow_create_poll": False,
"allow_submitter_edit": False,
"set_number": True,
"show_state_extension_field": False,
"merge_amendment_into_final": "do_not_merge",
"show_recommendation_extension_field": False,
"weight": 2,
"allow_motion_forwarding": False,
"set_workflow_timestamp": True,
},
)
assert_model(
"motion_state/13",
{
"id": 13,
"name": "successful",
"recommendation_label": "success",
"css_class": "green",
"restrictions": [],
"allow_support": False,
"allow_create_poll": False,
"allow_submitter_edit": False,
"set_number": True,
"show_state_extension_field": False,
"merge_amendment_into_final": "do_not_merge",
"show_recommendation_extension_field": False,
"weight": 3,
"allow_motion_forwarding": False,
"set_workflow_timestamp": False,
},
)
assert_model(
"motion_state/14",
{
"id": 14,
"name": "illegal",
"recommendation_label": "illegalize",
"css_class": "lightblue",
"restrictions": [],
"allow_support": False,
"allow_create_poll": False,
"allow_submitter_edit": False,
"set_number": True,
"show_state_extension_field": False,
"merge_amendment_into_final": "do_not_merge",
"show_recommendation_extension_field": False,
"weight": 4,
"allow_motion_forwarding": False,
"set_workflow_timestamp": True,
},
)
8 changes: 8 additions & 0 deletions tests/system/presenter/test_check_database_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ def test_correct(self) -> None:
"allow_support": False,
"allow_create_poll": False,
"allow_submitter_edit": False,
"allow_motion_forwarding": False,
"set_workflow_timestamp": False,
"set_number": True,
"show_state_extension_field": False,
"merge_amendment_into_final": "undefined",
Expand Down Expand Up @@ -470,6 +472,8 @@ def test_correct_relations(self) -> None:
"allow_support": False,
"allow_create_poll": False,
"allow_submitter_edit": False,
"allow_motion_forwarding": False,
"set_workflow_timestamp": False,
"set_number": True,
"show_state_extension_field": False,
"merge_amendment_into_final": "undefined",
Expand Down Expand Up @@ -676,6 +680,8 @@ def test_relation_2(self) -> None:
"allow_support": False,
"allow_create_poll": False,
"allow_submitter_edit": False,
"allow_motion_forwarding": False,
"set_workflow_timestamp": False,
"set_number": True,
"show_state_extension_field": False,
"merge_amendment_into_final": "undefined",
Expand Down Expand Up @@ -762,6 +768,8 @@ def test_relation_2(self) -> None:
"allow_support": False,
"allow_create_poll": False,
"allow_submitter_edit": False,
"allow_motion_forwarding": False,
"set_workflow_timestamp": False,
"set_number": True,
"show_state_extension_field": False,
"merge_amendment_into_final": "undefined",
Expand Down