Fix for motion restrictions in case migrations weren't applied properly

This commit is contained in:
Joshua Sangmeister 2021-11-18 09:18:30 +01:00
parent f04d64d48d
commit 740f164ac3

View File

@ -16,6 +16,7 @@ from openslides.mediafiles.views import (
from openslides.motions.models import Motion from openslides.motions.models import Motion
from openslides.users.views import demo_mode_users, is_demo_mode from openslides.users.views import demo_mode_users, is_demo_mode
from openslides.utils.cache import element_cache from openslides.utils.cache import element_cache
from openslides.utils import logging
def copy(obj, *attrs): def copy(obj, *attrs):
@ -869,15 +870,21 @@ class OS4Exporter:
new["css_class"] = old["css_class"] new["css_class"] = old["css_class"]
else: else:
new["css_class"] = "lightblue" new["css_class"] = "lightblue"
new["restrictions"] = [
{ new["restrictions"] = []
"motions.can_see_internal": "motion.can_see_internal", restrictions_map = {
"motions.can_manage_metadata": "motion.can_manage_metadata", "motions.can_see_internal": "motion.can_see_internal",
"motions.can_manage": "motion.can_manage", "motions.can_manage_metadata": "motion.can_manage_metadata",
"is_submitter": "is_submitter", "motions.can_manage": "motion.can_manage",
}[restriction] "managers_only": "motion.can_manage", # Should not exist any more since migration 0026, but does anyway...
for restriction in old["restriction"] "is_submitter": "is_submitter",
] }
for restriction in old["restriction"]:
if restriction in restrictions_map:
new["restrictions"].append(restrictions_map[restriction])
else:
logging.getLogger(__name__).warn(f"Invalid restriction '{restriction}' for motion {old['id']} is ignored.")
new["set_number"] = not old["dont_set_identifier"] new["set_number"] = not old["dont_set_identifier"]
new["merge_amendment_into_final"] = { new["merge_amendment_into_final"] = {
-1: "do_not_merge", -1: "do_not_merge",