feat(elections): Pseudonimize votes after tallying
This commit is contained in:
parent
fb0e5a8a37
commit
4fd9e3a211
2 changed files with 13 additions and 1 deletions
|
@ -10,3 +10,11 @@ def send_election_mail(election_pk: int, subject: str, body: str, reply_to: str)
|
|||
send_mail(election, subject, body, reply_to)
|
||||
election.sent_mail = True
|
||||
election.save(update_fields=["sent_mail"])
|
||||
|
||||
|
||||
@background
|
||||
def pseudonimize_election(election_pk: int):
|
||||
election = Election.objects.get(pk=election_pk)
|
||||
|
||||
for q in election.questions.all():
|
||||
q.pseudonymize()
|
||||
|
|
|
@ -41,13 +41,14 @@ from .mixins import (
|
|||
)
|
||||
from .models import Election, Option, Question, Vote
|
||||
from .staticdefs import MAIL_VOTE_DELETED, MAIL_VOTERS, QUESTION_TYPES, VOTE_RULES
|
||||
from .tasks import send_election_mail
|
||||
from .tasks import pseudonimize_election, send_election_mail
|
||||
from .utils import create_users
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from elections.typing import User
|
||||
else:
|
||||
from django.contrib.auth import get_user_model
|
||||
|
||||
User = get_user_model()
|
||||
|
||||
# TODO: access control *everywhere*
|
||||
|
@ -299,6 +300,9 @@ class ElectionTallyView(ClosedElectionMixin, BackgroundUpdateView):
|
|||
election.tallied = True
|
||||
election.time_tallied = timezone.now()
|
||||
election.save()
|
||||
|
||||
pseudonimize_election(election.pk)
|
||||
|
||||
return super().get(request, *args, **kwargs)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue