remove email related code
Build and Push Docker Images / Build and Push Docker Images (push) Failing after 9s
Build and Push Docker Images / Build and Push Docker Images (push) Failing after 9s
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
# api/management/commands/seed.py
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from api.models import Atoll, Island
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Seeds baseline reference data (atolls and islands) required for sign up."
|
||||
|
||||
def handle(self, *args, **options):
|
||||
atoll, atoll_created = Atoll.objects.get_or_create(name="Faafu")
|
||||
self.stdout.write(
|
||||
self.style.SUCCESS(f"Created atoll: {atoll.name}")
|
||||
if atoll_created
|
||||
else self.style.NOTICE(f"Atoll already exists: {atoll.name}")
|
||||
)
|
||||
|
||||
island, island_created = Island.objects.get_or_create(
|
||||
name="Dharanboodhoo", defaults={"atoll": atoll}
|
||||
)
|
||||
self.stdout.write(
|
||||
self.style.SUCCESS(f"Created island: {island.name} ({atoll.name})")
|
||||
if island_created
|
||||
else self.style.NOTICE(f"Island already exists: {island.name}")
|
||||
)
|
||||
|
||||
self.stdout.write(self.style.SUCCESS("Seeding complete."))
|
||||
@@ -1,8 +1,4 @@
|
||||
from django.core.mail import EmailMultiAlternatives
|
||||
from django.dispatch import receiver
|
||||
from django.template.loader import render_to_string
|
||||
from decouple import config
|
||||
from django_rest_passwordreset.signals import reset_password_token_created
|
||||
from django.db.models.signals import post_save
|
||||
from api.models import User, TemporaryUser
|
||||
from django.contrib.auth.models import Permission
|
||||
@@ -44,44 +40,3 @@ def verify_user_with_person_api(sender, instance, created, **kwargs):
|
||||
if created:
|
||||
print(f"Temporary User Instance: {instance}")
|
||||
verify_user_with_person_api_task(instance.t_id)
|
||||
|
||||
|
||||
@receiver(reset_password_token_created)
|
||||
def password_reset_token_created(
|
||||
sender, instance, reset_password_token, *args, **kwargs
|
||||
):
|
||||
"""
|
||||
Handles password reset tokens
|
||||
When a token is created, an e-mail needs to be sent to the user
|
||||
:param sender: View Class that sent the signal
|
||||
:param instance: View Instance that sent the signal
|
||||
:param reset_password_token: Token Model Object
|
||||
:param args:
|
||||
:param kwargs:
|
||||
:return:
|
||||
"""
|
||||
context = {
|
||||
"current_user": reset_password_token.user,
|
||||
"username": reset_password_token.user.username,
|
||||
"email": reset_password_token.user.email,
|
||||
"reset_password_url": f"{config('FRONTEND_URL')}/auth/reset-password-confirm/?token={reset_password_token.key}",
|
||||
}
|
||||
|
||||
# render email text
|
||||
email_html_message = render_to_string("email/password_reset_email.html", context)
|
||||
email_plaintext_message = (
|
||||
f"Here is your password reset link: {context['reset_password_url']}"
|
||||
)
|
||||
|
||||
msg = EmailMultiAlternatives(
|
||||
# title:
|
||||
"Password Reset for {title}".format(title="Sarlink Portal"),
|
||||
# message:
|
||||
email_plaintext_message, # This is the plaintext version
|
||||
# from:
|
||||
"noreply@sarlink.net",
|
||||
# to:
|
||||
[reset_password_token.user.email],
|
||||
)
|
||||
msg.attach_alternative(email_html_message, "text/html")
|
||||
msg.send()
|
||||
|
||||
@@ -1,102 +0,0 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="description" content="Instructions to reset your password." />
|
||||
<meta name="keywords" content="password, reset, email, instructions" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
|
||||
<title>Password Reset Email</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
background-color: #f5f5f5;
|
||||
margin: 0;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 600px;
|
||||
margin: 0 auto;
|
||||
background-color: #ffffff;
|
||||
border-radius: 8px;
|
||||
padding: 30px;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.header {
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.logo {
|
||||
color: #2c3e50;
|
||||
font-size: 24px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.message {
|
||||
color: #6c757d;
|
||||
font-size: 16px;
|
||||
line-height: 1.5;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.footer {
|
||||
margin-top: 30px;
|
||||
color: #6c757d;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.button {
|
||||
display: inline-block;
|
||||
padding: 10px 20px;
|
||||
background-color: #007bff;
|
||||
color: #ffffff !important;
|
||||
text-decoration: none;
|
||||
border-radius: 5px;
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
.button:hover {
|
||||
background-color: #0056b3;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #007bff;
|
||||
text-decoration: underline;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<div class="logo">Password Reset Instructions</div>
|
||||
</div>
|
||||
|
||||
<p class="message">
|
||||
Hello {{ username }},
|
||||
</p>
|
||||
<p class="message">
|
||||
We received a request to reset your password. Click the button below to create a new password:
|
||||
</p>
|
||||
|
||||
<a href="{{ reset_password_url }}" class="button">Reset Password</a>
|
||||
|
||||
<p class="message">
|
||||
If the button doesn't work, you can copy and paste this link into your browser:
|
||||
<br>
|
||||
<a href="{{ reset_password_url }}">{{ reset_password_url }}</a>
|
||||
</p>
|
||||
|
||||
<p class="message">
|
||||
If you did not request this password reset, you can safely ignore
|
||||
this email.
|
||||
</p>
|
||||
|
||||
<p class="footer">Best regards,<br>SARLink</p>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -10,7 +10,6 @@ from .views import (
|
||||
ListUserView,
|
||||
UserDetailAPIView,
|
||||
healthcheck,
|
||||
test_email,
|
||||
ListAtollView,
|
||||
CreateAtollView,
|
||||
RetrieveUpdateDestroyAtollView,
|
||||
@@ -49,7 +48,6 @@ urlpatterns = [
|
||||
),
|
||||
path("users/<int:pk>/reject/", UserRejectAPIView.as_view(), name="user-reject"),
|
||||
path("healthcheck/", healthcheck, name="healthcheck"),
|
||||
path("test/", test_email, name="testemail"),
|
||||
path("atolls/", ListAtollView.as_view(), name="atolls"),
|
||||
path("atolls/new/", CreateAtollView.as_view(), name="atoll-new"),
|
||||
path(
|
||||
|
||||
@@ -29,7 +29,6 @@ from knox.views import LoginView as KnoxLoginView
|
||||
from knox.models import AuthToken
|
||||
from django_filters.rest_framework import DjangoFilterBackend
|
||||
from typing import cast, Dict, Any
|
||||
from django.core.mail import send_mail
|
||||
from django.db.models import Q
|
||||
from api.notifications import send_otp
|
||||
from .utils import check_person_api_verification
|
||||
@@ -550,19 +549,6 @@ class UserDetailAPIView(StaffEditorPermissionMixin, generics.RetrieveAPIView):
|
||||
return Response(data)
|
||||
|
||||
|
||||
@api_view(["POST"])
|
||||
@permission_classes((permissions.AllowAny,))
|
||||
def test_email(request):
|
||||
send_mail(
|
||||
"Subject here",
|
||||
"Here is the message.",
|
||||
"noreply@sarlink.net",
|
||||
["shihaam@shihaam.me"],
|
||||
fail_silently=False,
|
||||
)
|
||||
return Response({"status": "ok"}, status=status.HTTP_200_OK)
|
||||
|
||||
|
||||
class CreateAtollView(StaffEditorPermissionMixin, generics.CreateAPIView):
|
||||
serializer_class = AtollSerializer
|
||||
queryset = Atoll.objects.all()
|
||||
|
||||
Reference in New Issue
Block a user