From 15a5dda9e0cdbe2ac618a6b2a09df8928f485c88 Mon Sep 17 00:00:00 2001 From: ibuler Date: Wed, 27 Sep 2023 15:12:24 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BF=AE=E6=94=B9=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E7=9A=84=E9=82=AE=E7=AE=B1=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/common/tasks.py | 3 --- .../migrations/0046_auto_20230927_1456.py | 21 +++++++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 apps/users/migrations/0046_auto_20230927_1456.py diff --git a/apps/common/tasks.py b/apps/common/tasks.py index 2daa5acb5..468fa2a51 100644 --- a/apps/common/tasks.py +++ b/apps/common/tasks.py @@ -37,9 +37,7 @@ def send_mail_async(*args, **kwargs): from_email = settings.EMAIL_FROM or settings.EMAIL_HOST_USER args.insert(2, from_email) - args[3] = [mail for mail in args[3] if mail != 'admin@mycomany.com'] args = tuple(args) - try: return send_mail(*args, **kwargs) except Exception as e: @@ -52,7 +50,6 @@ def send_mail_attachment_async(subject, message, recipient_list, attachment_list attachment_list = [] from_email = settings.EMAIL_FROM or settings.EMAIL_HOST_USER subject = (settings.EMAIL_SUBJECT_PREFIX or '') + subject - recipient_list = [mail for mail in recipient_list if mail != 'admin@mycomany.com'] email = EmailMultiAlternatives( subject=subject, body=message, diff --git a/apps/users/migrations/0046_auto_20230927_1456.py b/apps/users/migrations/0046_auto_20230927_1456.py new file mode 100644 index 000000000..d32569026 --- /dev/null +++ b/apps/users/migrations/0046_auto_20230927_1456.py @@ -0,0 +1,21 @@ +# Generated by Django 4.1.10 on 2023-09-27 06:56 + +from django.db import migrations + + +def migrate_user_default_email(apps, *args): + user_cls = apps.get_model('users', 'User') + user_cls.objects\ + .filter(email='admin@mycomany.com')\ + .update(email='admin@example.com') + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0045_delete_usersession'), + ] + + operations = [ + migrations.RunPython(migrate_user_default_email), + ]