Merge pull request #5501 from FinnStutzenstein/fixes

Fixed poll required users and motion state extension selector
This commit is contained in:
Emanuel Schütze 2020-08-12 14:43:25 +02:00 committed by GitHub
commit 72a53c5cd0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 39 additions and 38 deletions

View File

@ -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);
}

View File

@ -38,7 +38,7 @@
(keydown)="keyDownFunction($event)"
/>
</mat-form-field>
<mat-form-field *ngIf="searchList">
<mat-form-field *ngIf="searchList" [formGroup]="extensionFieldForm">
<os-search-value-selector
formControlName="list"
[inputListValues]="searchList"

View File

@ -153,22 +153,20 @@ export class ExtensionFieldComponent implements OnInit, OnDestroy {
list: [[]]
});
this.searchValueSubscription = this.extensionFieldForm
.get('list')
.valueChanges.subscribe((value: number) => {
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();
}
});
}
}

View File

@ -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"]])

View File

@ -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()