2019-11-12 18:30:26 +01:00
|
|
|
from textwrap import dedent
|
|
|
|
|
2020-09-10 12:09:05 +02:00
|
|
|
from django.contrib.auth import get_user_model
|
2019-10-18 14:18:49 +02:00
|
|
|
from django.contrib.auth.models import AnonymousUser
|
2019-11-12 18:30:26 +01:00
|
|
|
from django.db import transaction
|
2020-04-06 16:38:07 +02:00
|
|
|
from django.db.utils import IntegrityError
|
2019-11-12 18:30:26 +01:00
|
|
|
from rest_framework import status
|
2019-10-18 14:18:49 +02:00
|
|
|
|
|
|
|
from openslides.utils.auth import in_some_groups
|
2021-01-20 09:10:23 +01:00
|
|
|
from openslides.utils.autoupdate import disable_history, inform_changed_data
|
2019-10-18 14:18:49 +02:00
|
|
|
from openslides.utils.rest_api import (
|
|
|
|
DecimalField,
|
|
|
|
GenericViewSet,
|
|
|
|
ModelViewSet,
|
|
|
|
Response,
|
|
|
|
ValidationError,
|
2021-04-12 08:20:06 +02:00
|
|
|
action,
|
2019-10-18 14:18:49 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
from .models import BasePoll
|
|
|
|
|
|
|
|
|
|
|
|
class BasePollViewSet(ModelViewSet):
|
2019-11-12 18:30:26 +01:00
|
|
|
valid_update_keys = [
|
|
|
|
"majority_method",
|
|
|
|
"onehundred_percent_base",
|
|
|
|
"title",
|
|
|
|
"description",
|
|
|
|
]
|
2019-11-27 15:44:17 +01:00
|
|
|
|
2019-10-18 14:18:49 +02:00
|
|
|
def check_view_permissions(self):
|
|
|
|
"""
|
|
|
|
the vote view is checked seperately. For all other views manage permissions
|
|
|
|
are required.
|
|
|
|
"""
|
|
|
|
if self.action == "vote":
|
|
|
|
return True
|
|
|
|
else:
|
|
|
|
return self.has_manage_permissions()
|
|
|
|
|
2021-04-12 13:57:24 +02:00
|
|
|
def get_locked_object(self):
|
|
|
|
"""
|
|
|
|
Enhance get_object to make sure to lock the underlying object to prevent
|
|
|
|
race conditions.
|
|
|
|
"""
|
|
|
|
poll = self.get_object()
|
|
|
|
return self.queryset.select_for_update().get(pk=poll.pk)
|
|
|
|
|
2019-11-12 18:30:26 +01:00
|
|
|
@transaction.atomic
|
|
|
|
def create(self, request, *args, **kwargs):
|
|
|
|
serializer = self.get_serializer(data=request.data)
|
|
|
|
serializer.is_valid(raise_exception=True)
|
|
|
|
|
|
|
|
# for analog polls, votes can be given directly when the poll is created
|
|
|
|
# for assignment polls, the options do not exist yet, so the AssignmentRelatedUser ids are needed
|
|
|
|
if "votes" in request.data:
|
|
|
|
poll = serializer.save()
|
|
|
|
poll.create_options()
|
|
|
|
self.handle_request_with_votes(request, poll)
|
|
|
|
else:
|
|
|
|
self.perform_create(serializer)
|
|
|
|
|
|
|
|
headers = self.get_success_headers(serializer.data)
|
|
|
|
return Response(
|
|
|
|
serializer.data, status=status.HTTP_201_CREATED, headers=headers
|
|
|
|
)
|
|
|
|
|
2019-10-18 14:18:49 +02:00
|
|
|
def perform_create(self, serializer):
|
|
|
|
poll = serializer.save()
|
|
|
|
poll.create_options()
|
|
|
|
|
2019-11-12 18:30:26 +01:00
|
|
|
@transaction.atomic
|
2019-11-27 15:44:17 +01:00
|
|
|
def update(self, request, *args, **kwargs):
|
2019-10-18 14:18:49 +02:00
|
|
|
"""
|
2019-11-12 18:30:26 +01:00
|
|
|
Customized view endpoint to update a poll.
|
2019-10-18 14:18:49 +02:00
|
|
|
"""
|
2021-04-12 13:57:24 +02:00
|
|
|
poll = self.get_locked_object()
|
2019-10-18 14:18:49 +02:00
|
|
|
|
2019-11-27 15:44:17 +01:00
|
|
|
partial = kwargs.get("partial", False)
|
|
|
|
serializer = self.get_serializer(poll, data=request.data, partial=partial)
|
|
|
|
serializer.is_valid(raise_exception=False)
|
|
|
|
|
2019-10-18 14:18:49 +02:00
|
|
|
if poll.state != BasePoll.STATE_CREATED:
|
2019-11-27 15:44:17 +01:00
|
|
|
invalid_keys = set(serializer.validated_data.keys()) - set(
|
|
|
|
self.valid_update_keys
|
2019-10-18 14:18:49 +02:00
|
|
|
)
|
2019-11-27 15:44:17 +01:00
|
|
|
if len(invalid_keys):
|
|
|
|
raise ValidationError(
|
|
|
|
{
|
2019-11-12 18:30:26 +01:00
|
|
|
"detail": dedent(
|
|
|
|
f"""
|
|
|
|
The poll is not in the created state.
|
|
|
|
You can only edit: {', '.join(self.valid_update_keys)}.
|
|
|
|
You provided the invalid keys: {', '.join(invalid_keys)}.
|
|
|
|
"""
|
|
|
|
)
|
2019-11-27 15:44:17 +01:00
|
|
|
}
|
|
|
|
)
|
2019-10-18 14:18:49 +02:00
|
|
|
|
2019-11-12 18:30:26 +01:00
|
|
|
if "votes" in request.data:
|
|
|
|
self.handle_request_with_votes(request, poll)
|
2019-11-27 15:44:17 +01:00
|
|
|
return super().update(request, *args, **kwargs)
|
2019-10-18 14:18:49 +02:00
|
|
|
|
2019-11-12 18:30:26 +01:00
|
|
|
def handle_request_with_votes(self, request, poll):
|
|
|
|
if poll.type != BasePoll.TYPE_ANALOG:
|
|
|
|
raise ValidationError(
|
|
|
|
{"detail": "You cannot enter votes for a non-analog poll."}
|
|
|
|
)
|
|
|
|
|
|
|
|
vote_data = request.data["votes"]
|
|
|
|
# convert user ids to option ids
|
|
|
|
self.convert_option_data(poll, vote_data)
|
|
|
|
|
2020-09-10 12:09:05 +02:00
|
|
|
self.validate_vote_data(vote_data, poll)
|
|
|
|
self.handle_analog_vote(vote_data, poll)
|
2019-11-12 18:30:26 +01:00
|
|
|
|
|
|
|
if request.data.get("publish_immediately"):
|
|
|
|
poll.state = BasePoll.STATE_PUBLISHED
|
|
|
|
elif (
|
|
|
|
poll.state != BasePoll.STATE_PUBLISHED
|
|
|
|
): # only set to finished if not already published
|
|
|
|
poll.state = BasePoll.STATE_FINISHED
|
|
|
|
poll.save()
|
|
|
|
|
2021-02-05 12:22:52 +01:00
|
|
|
def extend_history_information(self, information):
|
|
|
|
# Use this method to add history information when a poll is started and stopped.
|
|
|
|
# The implementation can be found in concret view set e. g. MotionPollViewSet.
|
|
|
|
pass
|
|
|
|
|
2021-04-12 08:20:06 +02:00
|
|
|
@action(detail=True, methods=["POST"])
|
2020-04-06 14:14:00 +02:00
|
|
|
@transaction.atomic
|
2019-10-18 14:18:49 +02:00
|
|
|
def start(self, request, pk):
|
2021-04-12 13:57:24 +02:00
|
|
|
poll = self.get_locked_object()
|
2019-10-18 14:18:49 +02:00
|
|
|
if poll.state != BasePoll.STATE_CREATED:
|
|
|
|
raise ValidationError({"detail": "Wrong poll state"})
|
|
|
|
poll.state = BasePoll.STATE_STARTED
|
|
|
|
|
|
|
|
poll.save()
|
|
|
|
inform_changed_data(poll.get_votes())
|
2021-02-05 12:22:52 +01:00
|
|
|
self.extend_history_information(["Voting started"])
|
2019-10-18 14:18:49 +02:00
|
|
|
return Response()
|
|
|
|
|
2021-04-12 08:20:06 +02:00
|
|
|
@action(detail=True, methods=["POST"])
|
2020-04-06 14:14:00 +02:00
|
|
|
@transaction.atomic
|
2019-10-18 14:18:49 +02:00
|
|
|
def stop(self, request, pk):
|
2021-04-12 13:57:24 +02:00
|
|
|
poll = self.get_locked_object()
|
|
|
|
# Analog polls cannot be stopped; they are stopped when
|
2019-11-13 07:46:13 +01:00
|
|
|
# the results are entered.
|
|
|
|
if poll.type == BasePoll.TYPE_ANALOG:
|
|
|
|
raise ValidationError(
|
|
|
|
{"detail": "Analog polls can not be stopped. Please enter votes."}
|
|
|
|
)
|
|
|
|
|
2019-10-18 14:18:49 +02:00
|
|
|
if poll.state != BasePoll.STATE_STARTED:
|
|
|
|
raise ValidationError({"detail": "Wrong poll state"})
|
|
|
|
|
2021-03-25 13:13:49 +01:00
|
|
|
poll.stop()
|
2019-10-18 14:18:49 +02:00
|
|
|
inform_changed_data(poll.get_votes())
|
2020-01-16 17:22:12 +01:00
|
|
|
inform_changed_data(poll.get_options())
|
2021-02-05 12:22:52 +01:00
|
|
|
self.extend_history_information(["Voting stopped"])
|
2019-10-18 14:18:49 +02:00
|
|
|
return Response()
|
|
|
|
|
2021-04-12 08:20:06 +02:00
|
|
|
@action(detail=True, methods=["POST"])
|
2020-04-06 14:14:00 +02:00
|
|
|
@transaction.atomic
|
2019-10-18 14:18:49 +02:00
|
|
|
def publish(self, request, pk):
|
2021-04-12 13:57:24 +02:00
|
|
|
poll = self.get_locked_object()
|
2021-05-26 17:53:46 +02:00
|
|
|
if poll.state not in (BasePoll.STATE_STARTED, BasePoll.STATE_FINISHED):
|
2019-10-18 14:18:49 +02:00
|
|
|
raise ValidationError({"detail": "Wrong poll state"})
|
|
|
|
|
2021-05-26 17:53:46 +02:00
|
|
|
# stop poll if needed
|
|
|
|
if poll.state == BasePoll.STATE_STARTED:
|
|
|
|
poll.stop()
|
|
|
|
|
2019-10-18 14:18:49 +02:00
|
|
|
poll.state = BasePoll.STATE_PUBLISHED
|
|
|
|
poll.save()
|
2020-05-28 13:53:01 +02:00
|
|
|
inform_changed_data(
|
2021-01-20 09:10:23 +01:00
|
|
|
(
|
|
|
|
vote.user
|
|
|
|
for vote in poll.get_votes().prefetch_related("user").all()
|
|
|
|
if vote.user
|
|
|
|
)
|
2020-05-28 13:53:01 +02:00
|
|
|
)
|
2021-01-20 09:10:23 +01:00
|
|
|
inform_changed_data(poll.get_votes())
|
|
|
|
inform_changed_data(poll.get_options())
|
2019-10-18 14:18:49 +02:00
|
|
|
return Response()
|
|
|
|
|
2021-04-12 08:20:06 +02:00
|
|
|
@action(detail=True, methods=["POST"])
|
2020-04-06 14:14:00 +02:00
|
|
|
@transaction.atomic
|
2019-10-18 14:18:49 +02:00
|
|
|
def pseudoanonymize(self, request, pk):
|
2021-04-12 13:57:24 +02:00
|
|
|
poll = self.get_locked_object()
|
2019-10-18 14:18:49 +02:00
|
|
|
|
|
|
|
if poll.state not in (BasePoll.STATE_FINISHED, BasePoll.STATE_PUBLISHED):
|
|
|
|
raise ValidationError(
|
2020-12-17 00:30:56 +01:00
|
|
|
{"detail": "Anonymizing can only be done after finishing a poll."}
|
2019-10-18 14:18:49 +02:00
|
|
|
)
|
|
|
|
if poll.type != BasePoll.TYPE_NAMED:
|
2020-12-17 00:30:56 +01:00
|
|
|
raise ValidationError({"detail": "You can just anonymize named polls."})
|
2019-10-18 14:18:49 +02:00
|
|
|
|
|
|
|
poll.pseudoanonymize()
|
2021-02-05 12:22:52 +01:00
|
|
|
self.extend_history_information(["Voting anonymized"])
|
2019-10-18 14:18:49 +02:00
|
|
|
return Response()
|
|
|
|
|
2021-04-12 08:20:06 +02:00
|
|
|
@action(detail=True, methods=["POST"])
|
2020-04-06 14:14:00 +02:00
|
|
|
@transaction.atomic
|
2019-10-18 14:18:49 +02:00
|
|
|
def reset(self, request, pk):
|
2021-04-12 13:57:24 +02:00
|
|
|
poll = self.get_locked_object()
|
2019-10-18 14:18:49 +02:00
|
|
|
poll.reset()
|
2021-02-05 12:22:52 +01:00
|
|
|
self.extend_history_information(["Voting reset"])
|
2019-10-18 14:18:49 +02:00
|
|
|
return Response()
|
|
|
|
|
2021-04-12 08:20:06 +02:00
|
|
|
@action(detail=True, methods=["POST"])
|
2020-04-06 16:38:07 +02:00
|
|
|
@transaction.atomic
|
2019-10-18 14:18:49 +02:00
|
|
|
def vote(self, request, pk):
|
|
|
|
"""
|
|
|
|
For motion polls: Just "Y", "N" or "A" (if pollmethod is "YNA")
|
|
|
|
"""
|
2021-04-12 13:57:24 +02:00
|
|
|
poll = self.get_locked_object()
|
2019-10-18 14:18:49 +02:00
|
|
|
|
2021-01-20 09:10:23 +01:00
|
|
|
# Disable history for these requests
|
|
|
|
disable_history()
|
|
|
|
|
2019-10-18 14:18:49 +02:00
|
|
|
if isinstance(request.user, AnonymousUser):
|
|
|
|
self.permission_denied(request)
|
|
|
|
|
2020-09-10 12:09:05 +02:00
|
|
|
# data format is:
|
|
|
|
# { data: <vote_data>, [user_id: int] }
|
|
|
|
# if user_id is given, the operator votes for this user instead of himself
|
|
|
|
# user_id is ignored for analog polls
|
2019-11-12 18:30:26 +01:00
|
|
|
data = request.data
|
2020-09-10 12:09:05 +02:00
|
|
|
if "data" not in data:
|
|
|
|
raise ValidationError({"detail": "No data provided."})
|
|
|
|
vote_data = data["data"]
|
2021-01-20 09:10:23 +01:00
|
|
|
if (
|
|
|
|
"user_id" in data
|
|
|
|
and data["user_id"] != request.user.id
|
|
|
|
and poll.type != BasePoll.TYPE_ANALOG
|
|
|
|
):
|
2020-09-10 12:09:05 +02:00
|
|
|
try:
|
|
|
|
vote_user = get_user_model().objects.get(pk=data["user_id"])
|
|
|
|
except get_user_model().DoesNotExist:
|
|
|
|
raise ValidationError({"detail": "The given user does not exist."})
|
|
|
|
else:
|
|
|
|
vote_user = request.user
|
|
|
|
|
|
|
|
# check permissions based on poll type and user
|
|
|
|
self.assert_can_vote(poll, request, vote_user)
|
|
|
|
|
|
|
|
# validate the vote data
|
|
|
|
self.validate_vote_data(vote_data, poll)
|
2019-11-27 15:44:17 +01:00
|
|
|
|
2019-11-12 18:30:26 +01:00
|
|
|
if poll.type == BasePoll.TYPE_ANALOG:
|
2020-09-10 12:09:05 +02:00
|
|
|
self.handle_analog_vote(vote_data, poll)
|
|
|
|
if vote_data.get("publish_immediately") == "1":
|
2019-11-12 18:30:26 +01:00
|
|
|
poll.state = BasePoll.STATE_PUBLISHED
|
|
|
|
else:
|
|
|
|
poll.state = BasePoll.STATE_FINISHED
|
2019-10-18 14:18:49 +02:00
|
|
|
poll.save()
|
|
|
|
|
2019-11-12 18:30:26 +01:00
|
|
|
elif poll.type == BasePoll.TYPE_NAMED:
|
2020-09-10 12:09:05 +02:00
|
|
|
self.handle_named_vote(vote_data, poll, vote_user, request.user)
|
2019-11-27 15:44:17 +01:00
|
|
|
|
2019-11-12 18:30:26 +01:00
|
|
|
elif poll.type == BasePoll.TYPE_PSEUDOANONYMOUS:
|
2020-09-10 12:09:05 +02:00
|
|
|
self.handle_pseudoanonymous_vote(vote_data, poll, vote_user)
|
2020-02-12 17:18:01 +01:00
|
|
|
|
|
|
|
inform_changed_data(poll)
|
2019-11-27 15:44:17 +01:00
|
|
|
|
2019-11-12 18:30:26 +01:00
|
|
|
return Response()
|
2019-11-27 15:44:17 +01:00
|
|
|
|
2021-04-12 08:20:06 +02:00
|
|
|
@action(detail=True, methods=["POST"])
|
2020-06-03 14:11:25 +02:00
|
|
|
@transaction.atomic
|
|
|
|
def refresh(self, request, pk):
|
2021-04-12 13:57:24 +02:00
|
|
|
poll = self.get_locked_object()
|
2021-01-20 09:10:23 +01:00
|
|
|
inform_changed_data(poll)
|
|
|
|
inform_changed_data(poll.get_options())
|
|
|
|
inform_changed_data(poll.get_votes())
|
2020-06-03 14:11:25 +02:00
|
|
|
return Response()
|
|
|
|
|
2020-09-10 12:09:05 +02:00
|
|
|
def assert_can_vote(self, poll, request, vote_user):
|
2019-11-12 18:30:26 +01:00
|
|
|
"""
|
2020-04-06 16:38:07 +02:00
|
|
|
Raises a permission denied, if the user is not allowed to vote (or has already voted).
|
2020-09-10 12:09:05 +02:00
|
|
|
Adds the user to the voted array, so this needs to be reverted if a later error happens!
|
2019-11-12 18:30:26 +01:00
|
|
|
Analog: has to have manage permissions
|
|
|
|
Named & Pseudoanonymous: has to be in a poll group and present
|
|
|
|
"""
|
2020-12-03 13:23:31 +01:00
|
|
|
# if the request user is not the vote user, the delegation must be right
|
2020-09-10 12:09:05 +02:00
|
|
|
if request.user != vote_user and request.user != vote_user.vote_delegated_to:
|
2020-12-03 13:23:31 +01:00
|
|
|
raise ValidationError(
|
|
|
|
{
|
|
|
|
"detail": f"You cannot vote for {vote_user.id} since the vote right was not delegated to you."
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
# If the request user is the vote user, this user must not have any delegation.
|
|
|
|
# It is not allowed to vote for oneself, if the vote is delegated
|
|
|
|
if request.user == vote_user and request.user.vote_delegated_to is not None:
|
|
|
|
raise ValidationError(
|
|
|
|
{"detail": "You cannot vote since your vote right is delegated."}
|
|
|
|
)
|
2020-09-10 12:09:05 +02:00
|
|
|
|
2019-11-12 18:30:26 +01:00
|
|
|
if poll.type == BasePoll.TYPE_ANALOG:
|
|
|
|
if not self.has_manage_permissions():
|
|
|
|
self.permission_denied(request)
|
|
|
|
else:
|
|
|
|
if poll.state != BasePoll.STATE_STARTED:
|
2020-12-03 13:23:31 +01:00
|
|
|
raise ValidationError(
|
|
|
|
{"detail": "You can only vote on a started poll."}
|
|
|
|
)
|
2020-04-07 09:53:16 +02:00
|
|
|
|
2019-11-12 18:30:26 +01:00
|
|
|
if not request.user.is_present or not in_some_groups(
|
2020-09-10 12:09:05 +02:00
|
|
|
vote_user.id,
|
2020-04-06 16:38:07 +02:00
|
|
|
list(poll.groups.values_list("pk", flat=True)),
|
|
|
|
exact=True,
|
2019-11-12 18:30:26 +01:00
|
|
|
):
|
2020-04-06 16:38:07 +02:00
|
|
|
self.permission_denied(request)
|
|
|
|
|
|
|
|
try:
|
2020-09-10 12:09:05 +02:00
|
|
|
self.add_user_to_voted_array(vote_user, poll)
|
2020-04-06 16:38:07 +02:00
|
|
|
inform_changed_data(poll)
|
|
|
|
except IntegrityError:
|
2020-12-17 00:30:56 +01:00
|
|
|
raise ValidationError({"detail": "You have already voted."})
|
2019-11-12 18:30:26 +01:00
|
|
|
|
|
|
|
def parse_vote_value(self, obj, key):
|
2021-04-26 08:31:22 +02:00
|
|
|
"""Raises a ValidationError on incorrect values, including None"""
|
2019-11-12 18:30:26 +01:00
|
|
|
if key not in obj:
|
|
|
|
raise ValidationError({"detail": f"The field {key} is required"})
|
|
|
|
field = DecimalField(min_value=-2, max_digits=15, decimal_places=6)
|
|
|
|
value = field.to_internal_value(obj[key])
|
|
|
|
if value < 0 and value != -1 and value != -2:
|
|
|
|
raise ValidationError(
|
|
|
|
{
|
|
|
|
"detail": "No fractional negative values allowed, only the special values -1 and -2"
|
|
|
|
}
|
|
|
|
)
|
|
|
|
return value
|
2019-10-18 14:18:49 +02:00
|
|
|
|
2020-06-03 14:11:25 +02:00
|
|
|
def has_manage_permissions(self):
|
|
|
|
"""
|
|
|
|
Returns true, if the request user has manage perms.
|
|
|
|
"""
|
|
|
|
raise NotImplementedError()
|
|
|
|
|
2019-11-12 18:30:26 +01:00
|
|
|
def convert_option_data(self, poll, data):
|
2019-10-18 14:18:49 +02:00
|
|
|
"""
|
2019-11-12 18:30:26 +01:00
|
|
|
May be overwritten by subclass. Adjusts the option data based on the now existing poll
|
2019-10-18 14:18:49 +02:00
|
|
|
"""
|
2019-11-12 18:30:26 +01:00
|
|
|
pass
|
2019-10-18 14:18:49 +02:00
|
|
|
|
2020-04-06 16:38:07 +02:00
|
|
|
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.
|
2020-04-07 09:53:16 +02:00
|
|
|
This operation should be atomic: If the user is already in the array, an IntegrityError must
|
|
|
|
be thrown, otherwise the user must be added.
|
2020-04-06 16:38:07 +02:00
|
|
|
"""
|
|
|
|
raise NotImplementedError()
|
|
|
|
|
2020-09-10 12:09:05 +02:00
|
|
|
def validate_vote_data(self, data, poll):
|
2019-11-12 18:30:26 +01:00
|
|
|
"""
|
|
|
|
To be implemented by subclass. Validates the data according to poll type and method and fields by validated versions.
|
|
|
|
Raises ValidationError on failure
|
|
|
|
"""
|
|
|
|
raise NotImplementedError()
|
|
|
|
|
2020-09-10 12:09:05 +02:00
|
|
|
def handle_analog_vote(self, data, poll):
|
2019-11-12 18:30:26 +01:00
|
|
|
"""
|
|
|
|
To be implemented by subclass. Handles the analog vote. Assumes data is validated
|
|
|
|
"""
|
|
|
|
raise NotImplementedError()
|
|
|
|
|
2020-09-10 12:09:05 +02:00
|
|
|
def handle_named_vote(self, data, poll, vote_user, request_user):
|
2019-11-12 18:30:26 +01:00
|
|
|
"""
|
2020-02-12 17:18:01 +01:00
|
|
|
To be implemented by subclass. Handles the named vote. Assumes data is validated.
|
|
|
|
Needs to manage the voted-array per option.
|
2019-11-12 18:30:26 +01:00
|
|
|
"""
|
|
|
|
raise NotImplementedError()
|
|
|
|
|
2020-02-12 17:18:01 +01:00
|
|
|
def handle_pseudoanonymous_vote(self, data, poll, user):
|
2019-11-12 18:30:26 +01:00
|
|
|
"""
|
2020-02-12 17:18:01 +01:00
|
|
|
To be implemented by subclass. Handles the pseudoanonymous vote. Assumes data
|
|
|
|
is validated. Needs to check, if the vote is allowed by the voted-array per poll.
|
|
|
|
Needs to add the user to the voted-array.
|
2019-11-12 18:30:26 +01:00
|
|
|
"""
|
|
|
|
raise NotImplementedError()
|
2019-10-18 14:18:49 +02:00
|
|
|
|
|
|
|
|
2021-03-04 16:15:57 +01:00
|
|
|
class BaseVoteViewSet(GenericViewSet):
|
2019-10-18 14:18:49 +02:00
|
|
|
pass
|
2019-11-12 18:30:26 +01:00
|
|
|
|
|
|
|
|
2021-03-04 16:15:57 +01:00
|
|
|
class BaseOptionViewSet(GenericViewSet):
|
2019-11-12 18:30:26 +01:00
|
|
|
pass
|