Merge pull request #5918 from FinnStutzenstein/removeVotedIds

Remove voted_ids
This commit is contained in:
Finn Stutzenstein 2021-03-04 08:20:19 +01:00 committed by GitHub
commit d62d1a687b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 18 deletions

@ -1 +1 @@
Subproject commit fcbcfb8d68c083a7c9204548b0f0c1bb61ef49c0
Subproject commit b778a165491d503aa7e286c3859a4d601c827ddc

View File

@ -6,7 +6,7 @@ export abstract class BaseOption<T> extends BaseDecimalModel<T> {
public no: number;
public abstain: number;
public poll_id: number;
public voted_id: number[];
public votes_id: number[];
protected getDecimalFields(): string[] {
return ['yes', 'no', 'abstain'];

View File

@ -77,7 +77,7 @@ class BasePollAccessPermissions(BaseAccessPermissions):
Non-published polls will be restricted:
- Remove votes* values from the poll
- Remove yes/no/abstain fields from options
- Remove fields given in self.assitional_fields from the poll
- Remove fields given in self.additional_fields from the poll
"""
# add has_voted for all users to check whether op has voted
@ -100,22 +100,23 @@ class BasePollAccessPermissions(BaseAccessPermissions):
)
poll["user_has_voted_for_delegations"] = voted_for_delegations
data_copy = json.loads(json.dumps(full_data))
for poll in data_copy:
if poll["state"] not in (BasePoll.STATE_FINISHED, BasePoll.STATE_PUBLISHED):
del poll["voted_id"]
if await async_has_perm(user_id, self.manage_permission):
data = full_data
pass
elif await async_has_perm(user_id, self.base_permission):
data = []
for poll in full_data:
for poll in data_copy:
if poll["state"] != BasePoll.STATE_PUBLISHED:
poll = json.loads(
json.dumps(poll)
) # copy, so we can remove some fields.
del poll["votesvalid"]
del poll["votesinvalid"]
del poll["votescast"]
del poll["voted_id"]
if "voted_id" in poll: # could be removed earlier
del poll["voted_id"]
for field in self.additional_fields:
del poll[field]
data.append(poll)
else:
data = []
return data
data_copy = []
return data_copy

View File

@ -2733,7 +2733,6 @@ class VoteAssignmentPollNamedAutoupdates(VoteAssignmentPollAutoupdatesBaseClass)
"votesvalid": "1.000000",
"user_has_voted": False,
"user_has_voted_for_delegations": [],
"voted_id": [self.user.id],
},
"assignments/assignment-option:1": {
"abstain": "1.000000",
@ -2926,7 +2925,6 @@ class VoteAssignmentPollPseudoanonymousAutoupdates(
"type": AssignmentPoll.TYPE_PSEUDOANONYMOUS,
"user_has_voted": False,
"user_has_voted_for_delegations": [],
"voted_id": [self.user.id],
"onehundred_percent_base": AssignmentPoll.PERCENT_BASE_CAST,
"majority_method": AssignmentPoll.MAJORITY_TWO_THIRDS,
"min_votes_amount": 1,

View File

@ -165,7 +165,6 @@ class CreateMotionPoll(TestCase):
"votescast": "0.000000",
"options_id": [1],
"id": 1,
"voted_id": [],
"user_has_voted": False,
"user_has_voted_for_delegations": [],
},
@ -1081,7 +1080,6 @@ class VoteMotionPollNamedAutoupdates(TestCase):
"id": 1,
"user_has_voted": False,
"user_has_voted_for_delegations": [],
"voted_id": [self.user.id],
},
"motions/motion-vote:1": {
"pollstate": 2,
@ -1224,7 +1222,6 @@ class VoteMotionPollPseudoanonymousAutoupdates(TestCase):
"id": 1,
"user_has_voted": False,
"user_has_voted_for_delegations": [],
"voted_id": [self.user.id],
},
"motions/motion-vote:1": {
"pollstate": 2,