From d682d0d134032079502f7c7db929d3eaa77c2cd8 Mon Sep 17 00:00:00 2001 From: Finn Stutzenstein Date: Tue, 11 Aug 2020 13:20:08 +0200 Subject: [PATCH] Fixed poll required users and motion state extension selector --- .../core/core-services/data-store.service.ts | 1 - .../extension-field.component.html | 2 +- .../extension-field.component.ts | 28 +++++++-------- openslides/assignments/apps.py | 35 +++++++++---------- openslides/motions/apps.py | 11 ++++-- 5 files changed, 39 insertions(+), 38 deletions(-) diff --git a/client/src/app/core/core-services/data-store.service.ts b/client/src/app/core/core-services/data-store.service.ts index 2fa19e4c7..206bf3b08 100644 --- a/client/src/app/core/core-services/data-store.service.ts +++ b/client/src/app/core/core-services/data-store.service.ts @@ -669,7 +669,6 @@ export class DataStoreService { public print(): void { console.log('Max change id', this.maxChangeId); - console.log('json storage'); console.log(JSON.stringify(this.jsonStore)); console.log(this.modelStore); } diff --git a/client/src/app/shared/components/extension-field/extension-field.component.html b/client/src/app/shared/components/extension-field/extension-field.component.html index 7a60c096d..df03eaa21 100644 --- a/client/src/app/shared/components/extension-field/extension-field.component.html +++ b/client/src/app/shared/components/extension-field/extension-field.component.html @@ -38,7 +38,7 @@ (keydown)="keyDownFunction($event)" /> - + { - if (value) { - if (this.listSubmitOnChange) { - this.listChange.emit(value); - } - if (this.appendValueToInput) { - if (!this.inputControl) { - this.inputControl = ''; - } - this.inputControl += `[${this.listValuePrefix}${value}${this.listValueSuffix}]`; - } - this.extensionFieldForm.reset(); + this.searchValueSubscription = this.extensionFieldForm.get('list').valueChanges.subscribe((value: any) => { + if (value && typeof value === 'number') { + if (this.listSubmitOnChange) { + this.listChange.emit(value); } - }); + if (this.appendValueToInput) { + if (!this.inputControl) { + this.inputControl = ''; + } + this.inputControl += `[${this.listValuePrefix}${value}${this.listValueSuffix}]`; + } + this.extensionFieldForm.reset(); + } + }); } } diff --git a/openslides/assignments/apps.py b/openslides/assignments/apps.py index 2397ca945..3560d08e3 100644 --- a/openslides/assignments/apps.py +++ b/openslides/assignments/apps.py @@ -55,7 +55,11 @@ class AssignmentsAppConfig(AppConfig): ) required_user.add_collection_string( self.get_model("AssignmentPoll").get_collection_string(), - required_users_options, + required_users_assignment_polls, + ) + required_user.add_collection_string( + self.get_model("AssignmentOption").get_collection_string(), + required_users_assignment_options, ) def get_config_variables(self): @@ -82,28 +86,23 @@ 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. """ - from openslides.assignments.models import AssignmentOption, AssignmentPoll - from openslides.utils.cache import element_cache - candidates = set( + return set( related_user["user_id"] for related_user in element["assignment_related_users"] ) - for poll_id in element["polls_id"]: - poll = await element_cache.get_element_data( - AssignmentPoll.get_collection_string(), poll_id - ) - if poll: - for option_id in poll["options_id"]: - option = await element_cache.get_element_data( - AssignmentOption.get_collection_string(), option_id - ) - if option: - candidates.add(option["user_id"]) - return candidates -async def required_users_options(element: Dict[str, Any]) -> Set[int]: +async def required_users_assignment_polls(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"] + from openslides.poll.models import BasePoll + + if element["state"] == BasePoll.STATE_PUBLISHED: + return element["voted_id"] + else: + return set() + + +async def required_users_assignment_options(element: Dict[str, Any]) -> Set[int]: + return set([element["user_id"]]) diff --git a/openslides/motions/apps.py b/openslides/motions/apps.py index 7a0d0c90b..e5a22a149 100644 --- a/openslides/motions/apps.py +++ b/openslides/motions/apps.py @@ -84,7 +84,7 @@ class MotionsAppConfig(AppConfig): required_user.add_collection_string( self.get_model("MotionPoll").get_collection_string(), - required_users_options, + required_users_motion_polls, ) def get_config_variables(self): @@ -126,8 +126,13 @@ async def required_users_motions(element: Dict[str, Any]) -> Set[int]: return submitters_supporters -async def required_users_options(element: Dict[str, Any]) -> Set[int]: +async def required_users_motion_polls(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"] + from openslides.poll.models import BasePoll + + if element["state"] == BasePoll.STATE_PUBLISHED: + return element["voted_id"] + else: + return set()