On rajoute transaction.atomic

This commit is contained in:
Tom Hubrecht 2021-04-09 03:31:43 +02:00
parent c8dd99aa55
commit 2fc7030b34

View file

@ -1,6 +1,6 @@
from django.conf import settings
from django.contrib.auth.models import AbstractUser
from django.db import models
from django.db import models, transaction
from django.utils.translation import gettext_lazy as _
from .staticdefs import (
@ -89,10 +89,12 @@ class Question(models.Model):
validate_function = getattr(ValidateFunctions, VALIDATE_FUNCTIONS[self.type])
return vote_form.is_valid() and validate_function(vote_form)
@transaction.atomic
def cast_ballot(self, user, vote_form):
cast_function = getattr(CastFunctions, CAST_FUNCTIONS[self.type])
cast_function(user, vote_form)
@transaction.atomic
def tally(self):
tally_function = getattr(TallyFunctions, TALLY_FUNCTIONS[self.type])
tally_function(self)