adds all user that voted to required users for single votes table

This commit is contained in:
Joshua Sangmeister 2020-02-25 11:22:27 +01:00 committed by FinnStutzenstein
parent 2d13519c35
commit 82c8ade0ba
4 changed files with 31 additions and 4 deletions

View File

@ -50,7 +50,12 @@ class AssignmentsAppConfig(AppConfig):
# Register required_users # Register required_users
required_user.add_collection_string( 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): def get_config_variables(self):
@ -72,7 +77,7 @@ class AssignmentsAppConfig(AppConfig):
yield self.get_model(model_name) 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 Returns all user ids that are displayed as candidates (including poll
options) in the assignment element. options) in the assignment element.
@ -95,3 +100,10 @@ async def required_users(element: Dict[str, Any]) -> Set[int]:
if option: if option:
candidates.add(option["user_id"]) candidates.add(option["user_id"])
return candidates 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"]

View File

@ -267,6 +267,7 @@ class AssignmentOptionManager(BaseManager):
class AssignmentOption(RESTModelMixin, BaseOption): class AssignmentOption(RESTModelMixin, BaseOption):
access_permissions = AssignmentOptionAccessPermissions() access_permissions = AssignmentOptionAccessPermissions()
can_see_permission = "assignments.can_see"
objects = AssignmentOptionManager() objects = AssignmentOptionManager()
vote_class = AssignmentVote vote_class = AssignmentVote
@ -307,6 +308,7 @@ class AssignmentPollManager(BaseManager):
class AssignmentPoll(RESTModelMixin, BasePoll): class AssignmentPoll(RESTModelMixin, BasePoll):
access_permissions = AssignmentPollAccessPermissions() access_permissions = AssignmentPollAccessPermissions()
can_see_permission = "assignments.can_see"
objects = AssignmentPollManager() objects = AssignmentPollManager()
option_class = AssignmentOption option_class = AssignmentOption

View File

@ -78,7 +78,12 @@ class MotionsAppConfig(AppConfig):
# Register required_users # Register required_users
required_user.add_collection_string( 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): def get_config_variables(self):
@ -107,7 +112,7 @@ class MotionsAppConfig(AppConfig):
yield self.get_model(model_name) 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 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 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"]) submitters_supporters.update(element["supporters_id"])
return submitters_supporters 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"]

View File

@ -902,6 +902,7 @@ class MotionOptionManager(BaseManager):
class MotionOption(RESTModelMixin, BaseOption): class MotionOption(RESTModelMixin, BaseOption):
access_permissions = MotionOptionAccessPermissions() access_permissions = MotionOptionAccessPermissions()
can_see_permission = "motions.can_see"
objects = MotionOptionManager() objects = MotionOptionManager()
vote_class = MotionVote vote_class = MotionVote