Skip to content

Commit 2c67d97

Browse files
committed
change function name, fix type hints
1 parent c8eba73 commit 2c67d97

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

mailing/utils.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22
from typing import Union, List, Dict
33

44
import django.db.models
5+
from django.contrib.auth import get_user_model
56
from django.core import mail
67
from django.core.mail import EmailMultiAlternatives
78
from django.template.loader import render_to_string
89

9-
from users.models import CustomUser
10+
User = get_user_model()
1011

1112

1213
def send_mail(
13-
user: CustomUser,
14+
user: User,
1415
subject: str,
1516
template_path: str,
1617
template_context: Union[
@@ -19,11 +20,11 @@ def send_mail(
1920
] = None,
2021
connection=None,
2122
):
22-
return send_mails_mass([user], subject, template_path, template_context, connection)
23+
return send_mass_mail([user], subject, template_path, template_context, connection)
2324

2425

25-
def send_mails_mass(
26-
users: django.db.models.QuerySet,
26+
def send_mass_mail(
27+
users: django.db.models.QuerySet | List[User],
2728
subject: str,
2829
template_path: str,
2930
template_context: Union[

mailing/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from rest_framework.views import APIView
55

66
from users.models import CustomUser
7-
from .utils import send_mails_mass
7+
from .utils import send_mass_mail
88
from .models import MailingSchema
99

1010

@@ -20,7 +20,7 @@ def post(self, request):
2020
if key_in_post in request.POST:
2121
context[variable_name] = request.POST[key_in_post]
2222
users_to_send = CustomUser.objects.filter(pk__in=users)
23-
send_mails_mass(users_to_send, subject, mail_schema.template.path)
23+
send_mass_mail(users_to_send, subject, mail_schema.template.path)
2424
return JsonResponse({"detail": "ok"})
2525

2626

0 commit comments

Comments
 (0)