diff --git a/elections/utils.py b/elections/utils.py index 08277dd..c597f2d 100644 --- a/elections/utils.py +++ b/elections/utils.py @@ -5,6 +5,7 @@ import networkx as nx import numpy as np from networkx.algorithms.dag import ancestors, descendants +from django.contrib.auth import get_user_model from django.contrib.auth.hashers import make_password from django.core.exceptions import ValidationError from django.core.mail import EmailMessage, get_connection @@ -394,7 +395,7 @@ def send_mail(election, mail_form): """Envoie le mail d'annonce de l'élection avec identifiants et mot de passe aux votant·e·s, le mdp est généré en même temps que le mail est envoyé. """ - from .models import User + User = get_user_model() voters = list(election.registered_voters.all()) e_url = reverse("election.view", args=[election.id]) diff --git a/elections/views.py b/elections/views.py index 76e781c..56c237a 100644 --- a/elections/views.py +++ b/elections/views.py @@ -1,6 +1,7 @@ import csv from django.contrib import messages +from django.contrib.auth import get_user_model from django.contrib.messages.views import SuccessMessageMixin from django.core.mail import EmailMessage from django.db import transaction @@ -38,10 +39,12 @@ from .mixins import ( NotArchivedMixin, OpenElectionOnlyMixin, ) -from .models import Election, Option, Question, User, Vote +from .models import Election, Option, Question, Vote from .staticdefs import MAIL_VOTE_DELETED, MAIL_VOTERS, QUESTION_TYPES, VOTE_RULES from .utils import create_users, send_mail +User = get_user_model() + # TODO: access control *everywhere* # #############################################################################