From eb075fd7712369ae093d8119ea4043f43267b966 Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Sat, 29 May 2021 12:05:47 +0200 Subject: [PATCH] On utilise get_user_model partout --- elections/utils.py | 3 ++- elections/views.py | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) 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* # #############################################################################