feat(contact us): landing page contact support through email
This commit is contained in:
@@ -167,7 +167,7 @@ class OtpRequestView(APIView):
|
||||
# Send the email
|
||||
try:
|
||||
email_service.load_template(
|
||||
"module_auth/email_template.html", context={"code": otp_code, "name": principal.first_name}
|
||||
"module_auth/otp_email_template.html", context={"code": otp_code, "name": principal.first_name}
|
||||
)
|
||||
email_service.send()
|
||||
except Exception as e:
|
||||
|
||||
@@ -261,7 +261,7 @@ LOGGING = {
|
||||
# jwt configuration
|
||||
# https://django-rest-framework-simplejwt.readthedocs.io/en/latest/settings.html#settings
|
||||
SIMPLE_JWT = {
|
||||
"ACCESS_TOKEN_LIFETIME": datetime.timedelta(minutes=5),
|
||||
"ACCESS_TOKEN_LIFETIME": datetime.timedelta(days=15),
|
||||
"REFRESH_TOKEN_LIFETIME": datetime.timedelta(days=15),
|
||||
"ROTATE_REFRESH_TOKENS": False,
|
||||
"BLACKLIST_AFTER_ROTATION": True,
|
||||
|
||||
@@ -12,12 +12,14 @@ urlpatterns = [
|
||||
path('contact_us/action/', views.ContactUsActionView.as_view(), name='contact_us_action'),
|
||||
path('contact_us/archive/list/', views.ContactUsArchiveView.as_view(), name='contact_us_archive'),
|
||||
|
||||
path('contact_us/landing/', views.ContactUsLandingView, name="contact_us_landing"),
|
||||
|
||||
path('feedback/', views.FeedbackView.as_view(), name="feedback"),
|
||||
path('feedback/list/', views.FeedbackListJson.as_view(), name="feedback_list"),
|
||||
path('feedback/action/', views.FeedbackActionView.as_view(), name='feedback_action'),
|
||||
|
||||
|
||||
|
||||
# path('feedback/', views.FeedbackListView.as_view(), name='feedback_list'),
|
||||
# path('feedback/delete/<int:pk>', views.FeedbackDeleteView.as_view(), name='feedback_delete'),
|
||||
|
||||
]
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import datetime
|
||||
from django.conf import settings
|
||||
from django.contrib import messages
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
@@ -127,6 +128,66 @@ class ContactUsReplyView(LoginRequiredMixin, generic.View):
|
||||
else:
|
||||
return JsonResponseUtil.error(message=constants.FAILURE, errors="Missing 'id' or 'message' in the request")
|
||||
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
|
||||
@csrf_exempt
|
||||
def ContactUsLandingView(request):
|
||||
name = request.POST.get('full_name')
|
||||
email = request.POST.get('email')
|
||||
subject = request.POST.get('subject')
|
||||
message = request.POST.get('message')
|
||||
|
||||
if not all([name, email, subject, message]):
|
||||
return JsonResponseUtil.error(message=constants.FAILURE, errors='Please fill in all the fields.')
|
||||
|
||||
try:
|
||||
contact_us = ContactUs(
|
||||
name=name,
|
||||
email_address=email,
|
||||
subject=subject,
|
||||
message=message
|
||||
)
|
||||
contact_us.save()
|
||||
|
||||
context = {
|
||||
"name": name,
|
||||
"email": email,
|
||||
"subject": subject,
|
||||
"message": message,
|
||||
"year": datetime.datetime.year
|
||||
}
|
||||
print(context)
|
||||
|
||||
# Send the email to support team
|
||||
support_team_service = EmailService(
|
||||
subject=f"New contact us - {subject}",
|
||||
to=email,
|
||||
from_email=settings.EMAIL_HOST_USER,
|
||||
)
|
||||
|
||||
support_team_service.load_template(
|
||||
"module_support/contact_us_support.html", context=context
|
||||
)
|
||||
support_team_service.send()
|
||||
|
||||
# Send the email to support team
|
||||
thankyou_service = EmailService(
|
||||
subject=f"New contact us - {subject}",
|
||||
to=email,
|
||||
from_email=settings.EMAIL_HOST_USER,
|
||||
)
|
||||
|
||||
thankyou_service.load_template(
|
||||
"module_support/thank_you_support.html", context=context
|
||||
)
|
||||
thankyou_service.send()
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error occur in ContactUsLandingView {str(e)}")
|
||||
return JsonResponseUtil.error(message=constants.FAILURE, errors=constants.SOMETHING_WRONG)
|
||||
|
||||
return JsonResponseUtil.success(message='Thank you for contacting us!')
|
||||
|
||||
|
||||
class FeedbackView(permission.ResourcePermissionRequiredMixin, LoginRequiredMixin, generic.TemplateView):
|
||||
page_name = iam_constant.RESOURCE_MANAGE_FEEDBACK
|
||||
|
||||
54
templates/module_support/contact_us_support.html
Normal file
54
templates/module_support/contact_us_support.html
Normal file
@@ -0,0 +1,54 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Contact Support</title>
|
||||
<style>
|
||||
/* Add your custom styles here */
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
margin: 0;
|
||||
padding: 20px;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
.email-container {
|
||||
max-width: 600px;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
background-color: #ffffff;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
.email-container h1 {
|
||||
font-size: 24px;
|
||||
margin-bottom: 20px;
|
||||
color: #333333;
|
||||
}
|
||||
.email-container p {
|
||||
line-height: 1.6;
|
||||
color: #666666;
|
||||
}
|
||||
.email-container strong {
|
||||
color: #333333;
|
||||
}
|
||||
.email-container a {
|
||||
color: #0066cc;
|
||||
text-decoration: none;
|
||||
}
|
||||
.email-container a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="email-container">
|
||||
<h1>Contact Support</h1>
|
||||
<p><strong>Name:</strong> {{name}}</p>
|
||||
<p><strong>Email:</strong> {{email}}</p>
|
||||
<p><strong>Subject:</strong> {{subject}}</p>
|
||||
<p><strong>Message:</strong></p>
|
||||
<p>{{message}}</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
73
templates/module_support/thank_you_support.html
Normal file
73
templates/module_support/thank_you_support.html
Normal file
@@ -0,0 +1,73 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Contact Us Email</title>
|
||||
<!-- Bootstrap CSS -->
|
||||
{% comment %} <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet"> {% endcomment %}
|
||||
<style>
|
||||
/* Add your custom styles here */
|
||||
body {
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
.email-container {
|
||||
max-width: 600px;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
background-color: #ffffff;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||||
margin-top: 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.email-container h1 {
|
||||
font-size: 24px;
|
||||
margin-bottom: 20px;
|
||||
color: #333333;
|
||||
}
|
||||
.email-container p {
|
||||
line-height: 1.6;
|
||||
color: #666666;
|
||||
}
|
||||
.email-container strong {
|
||||
color: #333333;
|
||||
}
|
||||
.email-container a {
|
||||
color: #0066cc;
|
||||
text-decoration: none;
|
||||
}
|
||||
.email-container a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
.footer {
|
||||
text-align: center;
|
||||
margin-top: 20px;
|
||||
color: #999999;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="email-container">
|
||||
<h1>Subject: {{ subject }}</h1>
|
||||
<p>Dear {{ name }},</p>
|
||||
<p>Thank you for contacting Digest. We appreciate you reaching out.</p>
|
||||
<p><strong>Your Message:</strong></p>
|
||||
<p>{{ message }}</p>
|
||||
<p>We will respond to your inquiry as soon as possible.</p>
|
||||
<p>In the meantime, you may find answers to frequently asked questions on our Help Center: <a href="#">[link to Help Center]</a></p>
|
||||
<p>Sincerely,</p>
|
||||
<p>The Digest Team</p>
|
||||
</div>
|
||||
<div class="footer">
|
||||
© {{year}} Digest. All rights reserved.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Bootstrap JS and dependencies -->
|
||||
{% comment %} <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.4/dist/umd/popper.min.js"></script>
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script> {% endcomment %}
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user