From e2ac023dec62835b92f6cfac5790aa4c9922c19b Mon Sep 17 00:00:00 2001 From: eric-intuitem <71850047+eric-intuitem@users.noreply.github.com> Date: Thu, 30 May 2024 17:24:32 +0200 Subject: [PATCH 1/2] Create reset_mail.py --- .../core/management/commands/reset_mail.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 backend/core/management/commands/reset_mail.py diff --git a/backend/core/management/commands/reset_mail.py b/backend/core/management/commands/reset_mail.py new file mode 100644 index 000000000..2b3c24cdf --- /dev/null +++ b/backend/core/management/commands/reset_mail.py @@ -0,0 +1,20 @@ +from django.core.management.base import BaseCommand +from core.models import * +from iam.models import User, Folder +from ciso_assistant.settings import CISO_ASSISTANT_SUPERUSER_EMAIL + + +class Command(BaseCommand): + help = "Send reset email" + + def handle(self, *args, **kwargs): + admin = User.objects.get(email=CISO_ASSISTANT_SUPERUSER_EMAIL) + print(admin) + try: + admin.mailing( + email_template_name="registration/password_reset_email.html", + subject="CISO Assistant: Password Reset", + ) + self.stdout.write("reset mail sent") + except Exception as e: + self.stdout.write("cannot send reset mail") From 566b6cdd0ee405b42b4d18877d906038ff886090 Mon Sep 17 00:00:00 2001 From: eric-intuitem <71850047+eric-intuitem@users.noreply.github.com> Date: Thu, 30 May 2024 17:29:42 +0200 Subject: [PATCH 2/2] Create welcome_mail.py --- .../core/management/commands/welcome_mail.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 backend/core/management/commands/welcome_mail.py diff --git a/backend/core/management/commands/welcome_mail.py b/backend/core/management/commands/welcome_mail.py new file mode 100644 index 000000000..0644f6134 --- /dev/null +++ b/backend/core/management/commands/welcome_mail.py @@ -0,0 +1,20 @@ +from django.core.management.base import BaseCommand +from core.models import * +from iam.models import User, Folder +from ciso_assistant.settings import CISO_ASSISTANT_SUPERUSER_EMAIL + + +class Command(BaseCommand): + help = "Send welcome email" + + def handle(self, *args, **kwargs): + admin = User.objects.get(email=CISO_ASSISTANT_SUPERUSER_EMAIL) + print(admin) + try: + admin.mailing( + email_template_name="registration/first_connexion_email.html", + subject="Welcome to CISO Assistant!", + ) + self.stdout.write("welcome mail sent") + except Exception as e: + self.stdout.write("cannot send welcome mail")