Fix various export errors

This commit is contained in:
Joshua Sangmeister 2021-11-18 17:17:18 +01:00
parent 740f164ac3
commit cc6cf9ea42

View File

@ -15,8 +15,8 @@ from openslides.mediafiles.views import (
)
from openslides.motions.models import Motion
from openslides.users.views import demo_mode_users, is_demo_mode
from openslides.utils.cache import element_cache
from openslides.utils import logging
from openslides.utils.cache import element_cache
def copy(obj, *attrs):
@ -199,7 +199,7 @@ class OS4Exporter:
# Note: When returning self.all_data one has access to the original data to compare it to the export.
# return {"all": self.all_data, "export": self.to_list_format()}
return self.to_list_format()
return self.data
def set_model(self, collection, model):
if model["id"] in self.data[collection]:
@ -420,7 +420,6 @@ class OS4Exporter:
"is_pseudoanonymized",
"pollmethod",
"onehundred_percent_base",
"majority_method",
"votesvalid",
"votesinvalid",
"votescast",
@ -870,7 +869,8 @@ class OS4Exporter:
new["css_class"] = old["css_class"]
else:
new["css_class"] = "lightblue"
new["weight"] = old["id"]
new["restrictions"] = []
restrictions_map = {
"motions.can_see_internal": "motion.can_see_internal",
@ -883,7 +883,9 @@ class OS4Exporter:
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.")
logging.getLogger(__name__).warn(
f"Invalid restriction '{restriction}' for motion {old['id']} is ignored."
)
new["set_number"] = not old["dont_set_identifier"]
new["merge_amendment_into_final"] = {
@ -1030,6 +1032,9 @@ class OS4Exporter:
"gender",
"email",
)
# remove invalid genders
if new["gender"] not in ("male", "female", "diverse"):
new["gender"] = None
new["is_physical_person"] = not old["is_committee"]
new["password"] = ""
@ -1412,9 +1417,30 @@ class OS4Exporter:
self.meeting["conference_auto_connect_next_speakers"] = configs[
"general_system_conference_auto_connect_next_speakers"
]
self.meeting["conference_enable_helpdesk"] = configs[
"general_system_conference_enable_helpdesk"
]
# TODO: missing setting in OS4
# self.meeting["conference_enable_helpdesk"] = configs["general_system_conference_enable_helpdesk"]
self.meeting["applause_enable"] = configs["general_system_applause_enable"]
self.meeting["applause_type"] = configs["general_system_applause_type"]
self.meeting["applause_show_level"] = configs[
"general_system_applause_show_level"
]
self.meeting["applause_min_amount"] = configs[
"general_system_applause_min_amount"
]
self.meeting["applause_max_amount"] = configs[
"general_system_applause_max_amount"
]
self.meeting["applause_particle_image_url"] = configs[
"general_system_applause_particle_image"
]
self.meeting["applause_timeout"] = configs[
"general_system_stream_applause_timeout"
]
self.meeting["applause_timeout"] = configs[
"general_system_stream_applause_timeout"
]
self.meeting["projector_countdown_default_time"] = configs[
"projector_default_countdown"
@ -1532,7 +1558,10 @@ class OS4Exporter:
self.meeting["motions_recommendation_text_mode"] = configs[
"motions_recommendation_text_mode"
]
self.meeting["motions_default_sorting"] = configs["motions_motions_sorting"]
self.meeting["motions_default_sorting"] = {
"identifier": "number",
"weight": "weight",
}[configs["motions_motions_sorting"]]
self.meeting["motions_number_type"] = configs["motions_identifier"]
self.meeting["motions_number_min_digits"] = configs[
"motions_identifier_min_digits"
@ -1579,9 +1608,6 @@ class OS4Exporter:
self.meeting["motion_poll_default_100_percent_base"] = configs[
"motion_poll_default_100_percent_base"
]
self.meeting["motion_poll_default_majority_method"] = configs[
"motion_poll_default_majority_method"
]
group_ids = configs["motion_poll_default_groups"]
for group_id in group_ids:
@ -1634,9 +1660,6 @@ class OS4Exporter:
self.meeting["assignment_poll_default_100_percent_base"] = configs[
"assignment_poll_default_100_percent_base"
]
self.meeting["assignment_poll_default_majority_method"] = configs[
"assignment_poll_default_majority_method"
]
group_ids = configs["assignment_poll_default_groups"]
for group_id in group_ids:
@ -1650,7 +1673,6 @@ class OS4Exporter:
self.meeting["poll_default_type"] = "analog"
self.meeting["poll_default_method"] = "Y"
self.meeting["poll_default_100_percent_base"] = "YNA"
self.meeting["poll_default_majority_method"] = "simple"
self.meeting["poll_default_group_ids"] = []
self.meeting["poll_couple_countdown"] = True
@ -1697,6 +1719,7 @@ class OS4Exporter:
self.meeting["committee_id"] = None
self.meeting["default_meeting_for_committee_id"] = None
self.meeting["is_active_in_organization_id"] = None
self.meeting["organization_tag_ids"] = []
self.meeting["present_user_ids"] = [
x["id"]