diff --git a/openslides/assignments/apps.py b/openslides/assignments/apps.py index 0a0256cd1..b3241d452 100644 --- a/openslides/assignments/apps.py +++ b/openslides/assignments/apps.py @@ -50,7 +50,12 @@ class AssignmentsAppConfig(AppConfig): # Register required_users required_user.add_collection_string( - self.get_model("Assignment").get_collection_string(), required_users + self.get_model("Assignment").get_collection_string(), + required_users_assignments, + ) + required_user.add_collection_string( + self.get_model("AssignmentOption").get_collection_string(), + required_users_options, ) def get_config_variables(self): @@ -72,7 +77,7 @@ class AssignmentsAppConfig(AppConfig): yield self.get_model(model_name) -async def required_users(element: Dict[str, Any]) -> Set[int]: +async def required_users_assignments(element: Dict[str, Any]) -> Set[int]: """ Returns all user ids that are displayed as candidates (including poll options) in the assignment element. @@ -95,3 +100,10 @@ async def required_users(element: Dict[str, Any]) -> Set[int]: if option: candidates.add(option["user_id"]) return candidates + + +async def required_users_options(element: Dict[str, Any]) -> Set[int]: + """ + Returns all user ids that have voted on an option and are therefore required for the single votes table. + """ + return element["voted_id"] diff --git a/openslides/assignments/models.py b/openslides/assignments/models.py index c76d96d83..0e185dee9 100644 --- a/openslides/assignments/models.py +++ b/openslides/assignments/models.py @@ -267,6 +267,7 @@ class AssignmentOptionManager(BaseManager): class AssignmentOption(RESTModelMixin, BaseOption): access_permissions = AssignmentOptionAccessPermissions() + can_see_permission = "assignments.can_see" objects = AssignmentOptionManager() vote_class = AssignmentVote @@ -307,6 +308,7 @@ class AssignmentPollManager(BaseManager): class AssignmentPoll(RESTModelMixin, BasePoll): access_permissions = AssignmentPollAccessPermissions() + can_see_permission = "assignments.can_see" objects = AssignmentPollManager() option_class = AssignmentOption diff --git a/openslides/motions/apps.py b/openslides/motions/apps.py index 78593fa24..e6b5d29f9 100644 --- a/openslides/motions/apps.py +++ b/openslides/motions/apps.py @@ -78,7 +78,12 @@ class MotionsAppConfig(AppConfig): # Register required_users required_user.add_collection_string( - self.get_model("Motion").get_collection_string(), required_users + self.get_model("Motion").get_collection_string(), required_users_motions + ) + + required_user.add_collection_string( + self.get_model("MotionOption").get_collection_string(), + required_users_options, ) def get_config_variables(self): @@ -107,7 +112,7 @@ class MotionsAppConfig(AppConfig): yield self.get_model(model_name) -async def required_users(element: Dict[str, Any]) -> Set[int]: +async def required_users_motions(element: Dict[str, Any]) -> Set[int]: """ Returns all user ids that are displayed as as submitter or supporter in any motion if request_user can see motions. This function may return an @@ -118,3 +123,10 @@ async def required_users(element: Dict[str, Any]) -> Set[int]: ) submitters_supporters.update(element["supporters_id"]) return submitters_supporters + + +async def required_users_options(element: Dict[str, Any]) -> Set[int]: + """ + Returns all user ids that have voted on an option and are therefore required for the single votes table. + """ + return element["voted_id"] diff --git a/openslides/motions/models.py b/openslides/motions/models.py index 9ba5efc99..138050bae 100644 --- a/openslides/motions/models.py +++ b/openslides/motions/models.py @@ -902,6 +902,7 @@ class MotionOptionManager(BaseManager): class MotionOption(RESTModelMixin, BaseOption): access_permissions = MotionOptionAccessPermissions() + can_see_permission = "motions.can_see" objects = MotionOptionManager() vote_class = MotionVote