Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
4 changes: 3 additions & 1 deletion openslides_backend/models/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,12 @@ def check_normal_fields(self, model: dict[str, Any], collection: str) -> bool:
all_collection_fields = {
field.get_own_field_name() for field in self.get_fields(collection)
}
# TODO: remove duplication: required is also checked in check_types
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.

About this TODO

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.

TODO for the next PR. Checker tests (and probably some parts of the checker itself too) will be handled separately.

required_or_default_collection_fields = {
field.get_own_field_name()
for field in self.get_fields(collection)
if field.required or field.default is not None
if (field.required or field.default is not None)
and field.get_own_field_name() != "sequential_number"
}

errors = False
Expand Down
17 changes: 15 additions & 2 deletions openslides_backend/presenter/get_forwarding_meetings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from datetime import datetime
from typing import Any

import fastjsonschema
Expand Down Expand Up @@ -76,8 +77,12 @@ def get_result(self) -> Any:
{
"id": meeting_id2,
"name": meeting2.get("name", ""),
"start_time": meeting2.get("start_time"),
"end_time": meeting2.get("end_time"),
"start_time": self._get_formatted_datetime_value(
meeting2.get("start_time")
),
"end_time": self._get_formatted_datetime_value(
meeting2.get("end_time")
),
}
)
if meeting_result:
Expand All @@ -92,3 +97,11 @@ def get_result(self) -> Any:
}
)
return result

@staticmethod
def _get_formatted_datetime_value(value: Any) -> str | None:
if not value:
return None
if isinstance(value, datetime):
return value.isoformat()
return str(value)
41 changes: 16 additions & 25 deletions openslides_backend/presenter/get_user_related_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import fastjsonschema

from openslides_backend.permissions.management_levels import CommitteeManagementLevel
from openslides_backend.shared.mixins.user_scope_mixin import UserScopeMixin
from openslides_backend.shared.schema import id_list_schema

from ..services.database.commands import GetManyRequest
from ..shared.exceptions import PresenterException
from ..shared.patterns import fqid_from_collection_and_id
from ..shared.schema import schema_version
from .base import BasePresenter
Expand Down Expand Up @@ -64,30 +64,21 @@ def get_committees_data(self, user: dict[str, Any]) -> list[dict[str, Any]]:
if not user.get("committee_ids"):
return []

committees_data = []
gmr = GetManyRequest("committee", user["committee_ids"], ["id", "name"])
committees = {
committee["id"]: {"name": committee.get("name", ""), "cml": []}
for committee in self.datastore.get_many([gmr])
.get("committee", {})
.values()
}
for committee_nr in user.get("committee_management_ids", []):
if committee_nr in committees:
committees[committee_nr]["cml"].append("can_manage")
else:
raise PresenterException(
f"Data error: user has rights for committee {committee_nr}, but faultily is no member of committee."
)
for committee_id, committee in committees.items():
committees_data.append(
{
"id": committee_id,
"name": committee.get("name", ""),
"cml": ", ".join(committee.get("cml", [])),
}
)
return committees_data
gm_result = self.datastore.get_many(
[GetManyRequest("committee", user["committee_ids"], ["id", "name"])]
)
return [
{
"id": id_,
"name": committee.get("name", ""),
"cml": (
CommitteeManagementLevel.CAN_MANAGE
if id_ in user.get("committee_management_ids", [])
else ""
),
}
for id_, committee in gm_result.get("committee", {}).items()
]

def get_meetings_data(self, user: dict[str, Any]) -> list[dict[str, Any]]:
if not (meeting_user_ids := user.get("meeting_user_ids")):
Expand Down
Loading
Loading