Cleanup for #5300
This commit is contained in:
parent
12bc926b44
commit
7a97aa1b79
@ -1176,10 +1176,6 @@ class MotionPollViewSet(BasePollViewSet):
|
||||
|
||||
return result
|
||||
|
||||
def add_user_to_voted_array(self, user, poll):
|
||||
VotedModel = MotionPoll.voted.through
|
||||
VotedModel.objects.create(motionpoll=poll, user=user)
|
||||
|
||||
def handle_analog_vote(self, data, poll, user):
|
||||
option = poll.options.get()
|
||||
vote, _ = MotionVote.objects.get_or_create(option=option, value="Y")
|
||||
@ -1226,19 +1222,21 @@ class MotionPollViewSet(BasePollViewSet):
|
||||
elif poll.pollmethod == MotionPoll.POLLMETHOD_YN and data not in ("Y", "N"):
|
||||
raise ValidationError("Data must be Y or N")
|
||||
|
||||
def add_user_to_voted_array(self, user, poll):
|
||||
VotedModel = MotionPoll.voted.through
|
||||
VotedModel.objects.create(motionpoll=poll, user=user)
|
||||
|
||||
def handle_named_vote(self, data, poll, user):
|
||||
option = poll.options.get()
|
||||
vote = MotionVote.objects.create(user=user, option=option)
|
||||
self.handle_named_and_pseudoanonymous_vote(data, user, poll, option, vote)
|
||||
self.handle_named_and_pseudoanonymous_vote(data, user.vote_weight, user, poll)
|
||||
|
||||
def handle_pseudoanonymous_vote(self, data, poll, user):
|
||||
option = poll.options.get()
|
||||
vote = MotionVote.objects.create(user=None, option=option)
|
||||
self.handle_named_and_pseudoanonymous_vote(data, user, poll, option, vote)
|
||||
self.handle_named_and_pseudoanonymous_vote(data, user.vote_weight, None, poll)
|
||||
|
||||
def handle_named_and_pseudoanonymous_vote(self, data, user, poll, option, vote):
|
||||
def handle_named_and_pseudoanonymous_vote(self, data, weight, user, poll):
|
||||
option = poll.options.get()
|
||||
vote = MotionVote.objects.create(user=user, option=option)
|
||||
vote.value = data
|
||||
vote.weight = user.vote_weight
|
||||
vote.weight = weight
|
||||
vote.save(no_delete_on_restriction=True)
|
||||
inform_changed_data(option)
|
||||
|
||||
|
@ -232,6 +232,7 @@ class BasePollViewSet(ModelViewSet):
|
||||
else:
|
||||
if poll.state != BasePoll.STATE_STARTED:
|
||||
raise ValidationError("You can only vote on a started poll.")
|
||||
|
||||
if not request.user.is_present or not in_some_groups(
|
||||
request.user.id,
|
||||
list(poll.groups.values_list("pk", flat=True)),
|
||||
@ -268,7 +269,8 @@ class BasePollViewSet(ModelViewSet):
|
||||
def add_user_to_voted_array(self, user, poll):
|
||||
"""
|
||||
To be implemented by subclass. Adds the given user to the voted array of the given poll.
|
||||
Throws an IntegrityError if the user already exists in the array
|
||||
This operation should be atomic: If the user is already in the array, an IntegrityError must
|
||||
be thrown, otherwise the user must be added.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user