From 2fc7030b349fd3c028409ae2882ed1d6fd6fbe96 Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Fri, 9 Apr 2021 03:31:43 +0200 Subject: [PATCH] On rajoute transaction.atomic --- elections/models.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/elections/models.py b/elections/models.py index f7a6671..a1704fc 100644 --- a/elections/models.py +++ b/elections/models.py @@ -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)