On utilise get_user_model partout

This commit is contained in:
Tom Hubrecht 2021-05-29 12:05:47 +02:00
parent 0dfc8f6aea
commit eb075fd771
2 changed files with 6 additions and 2 deletions

View file

@ -5,6 +5,7 @@ import networkx as nx
import numpy as np import numpy as np
from networkx.algorithms.dag import ancestors, descendants 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.contrib.auth.hashers import make_password
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.core.mail import EmailMessage, get_connection 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 """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é. 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()) voters = list(election.registered_voters.all())
e_url = reverse("election.view", args=[election.id]) e_url = reverse("election.view", args=[election.id])

View file

@ -1,6 +1,7 @@
import csv import csv
from django.contrib import messages from django.contrib import messages
from django.contrib.auth import get_user_model
from django.contrib.messages.views import SuccessMessageMixin from django.contrib.messages.views import SuccessMessageMixin
from django.core.mail import EmailMessage from django.core.mail import EmailMessage
from django.db import transaction from django.db import transaction
@ -38,10 +39,12 @@ from .mixins import (
NotArchivedMixin, NotArchivedMixin,
OpenElectionOnlyMixin, 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 .staticdefs import MAIL_VOTE_DELETED, MAIL_VOTERS, QUESTION_TYPES, VOTE_RULES
from .utils import create_users, send_mail from .utils import create_users, send_mail
User = get_user_model()
# TODO: access control *everywhere* # TODO: access control *everywhere*
# ############################################################################# # #############################################################################