Merge pull request #5761 from jwinzer/poll-progress-users
Fix user filter of poll progress
This commit is contained in:
commit
0a80a73f2e
@ -1,4 +1,4 @@
|
|||||||
<div class="poll-progress-wrapper">
|
<div class="poll-progress-wrapper" *ngIf="canSeeProgressBar">
|
||||||
<div class="vote-number">
|
<div class="vote-number">
|
||||||
<span>{{ votescast }} / {{ max }}</span>
|
<span>{{ votescast }} / {{ max }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
@ -5,9 +5,10 @@ import { Title } from '@angular/platform-browser';
|
|||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { map } from 'rxjs/operators';
|
import { map } from 'rxjs/operators';
|
||||||
|
|
||||||
|
import { OperatorService } from 'app/core/core-services/operator.service';
|
||||||
import { UserRepositoryService } from 'app/core/repositories/users/user-repository.service';
|
import { UserRepositoryService } from 'app/core/repositories/users/user-repository.service';
|
||||||
import { BaseViewComponentDirective } from 'app/site/base/base-view';
|
import { BaseViewComponentDirective } from 'app/site/base/base-view';
|
||||||
import { ViewBasePoll } from 'app/site/polls/models/view-base-poll';
|
import { PollClassType, ViewBasePoll } from 'app/site/polls/models/view-base-poll';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'os-poll-progress',
|
selector: 'os-poll-progress',
|
||||||
@ -23,11 +24,22 @@ export class PollProgressComponent extends BaseViewComponentDirective implements
|
|||||||
return this.poll?.votescast || 0;
|
return this.poll?.votescast || 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public get canSeeProgressBar(): boolean {
|
||||||
|
let canManage = false;
|
||||||
|
if (this.poll?.pollClassType === PollClassType.Motion) {
|
||||||
|
canManage = this.operator.hasPerms(this.permission.motionsCanManagePolls);
|
||||||
|
} else if (this.poll?.pollClassType === PollClassType.Assignment) {
|
||||||
|
canManage = this.operator.hasPerms(this.permission.assignmentsCanManage);
|
||||||
|
}
|
||||||
|
return canManage && this.operator.hasPerms(this.permission.usersCanSeeName);
|
||||||
|
}
|
||||||
|
|
||||||
public constructor(
|
public constructor(
|
||||||
title: Title,
|
title: Title,
|
||||||
protected translate: TranslateService,
|
protected translate: TranslateService,
|
||||||
snackbar: MatSnackBar,
|
snackbar: MatSnackBar,
|
||||||
private userRepo: UserRepositoryService
|
private userRepo: UserRepositoryService,
|
||||||
|
private operator: OperatorService
|
||||||
) {
|
) {
|
||||||
super(title, translate, snackbar);
|
super(title, translate, snackbar);
|
||||||
}
|
}
|
||||||
@ -41,12 +53,14 @@ export class PollProgressComponent extends BaseViewComponentDirective implements
|
|||||||
map(users =>
|
map(users =>
|
||||||
/**
|
/**
|
||||||
* Filter the users who would be able to vote:
|
* Filter the users who would be able to vote:
|
||||||
* They are present or have their right to vote delegated
|
* They are present and don't have their vote right delegated
|
||||||
|
* or the have their vote delegated to a user who is present.
|
||||||
* They are in one of the voting groups
|
* They are in one of the voting groups
|
||||||
*/
|
*/
|
||||||
users.filter(
|
users.filter(
|
||||||
user =>
|
user =>
|
||||||
(user.is_present || user.isVoteRightDelegated) &&
|
((user.is_present && !user.isVoteRightDelegated) ||
|
||||||
|
user.voteDelegatedTo?.is_present) &&
|
||||||
this.poll.groups_id.intersect(user.groups_id).length
|
this.poll.groups_id.intersect(user.groups_id).length
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -63,15 +63,26 @@ class UserAccessPermissions(BaseAccessPermissions):
|
|||||||
|
|
||||||
# Check user permissions.
|
# Check user permissions.
|
||||||
if await async_has_perm(user_id, "users.can_see_name"):
|
if await async_has_perm(user_id, "users.can_see_name"):
|
||||||
|
whitelist_operator = None
|
||||||
if await async_has_perm(user_id, "users.can_see_extra_data"):
|
if await async_has_perm(user_id, "users.can_see_extra_data"):
|
||||||
if await async_has_perm(user_id, "users.can_manage"):
|
if await async_has_perm(user_id, "users.can_manage"):
|
||||||
data = [filtered_data(full, all_data_fields) for full in full_data]
|
whitelist = all_data_fields
|
||||||
else:
|
else:
|
||||||
data = [filtered_data(full, many_data_fields) for full in full_data]
|
whitelist = many_data_fields
|
||||||
else:
|
else:
|
||||||
|
whitelist = little_data_fields
|
||||||
|
whitelist_operator = own_data_fields
|
||||||
|
|
||||||
|
# for managing {motion, assignment} polls the users needs to know
|
||||||
|
# the vote delegation structure.
|
||||||
|
if await async_has_perm(
|
||||||
|
user_id, "motion.can_manage_polls"
|
||||||
|
) or await async_has_perm(user_id, "assignments.can_manage"):
|
||||||
|
whitelist.add("vote_delegated_to_id")
|
||||||
|
whitelist.add("vote_delegated_from_users_id")
|
||||||
|
|
||||||
data = [
|
data = [
|
||||||
filtered_data(full, little_data_fields, own_data_fields)
|
filtered_data(full, whitelist, whitelist_operator) for full in full_data
|
||||||
for full in full_data
|
|
||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
# Build a list of users, that can be seen without any permissions (with little fields).
|
# Build a list of users, that can be seen without any permissions (with little fields).
|
||||||
|
Loading…
Reference in New Issue
Block a user