[UPDT] ONBOARDING: Send portal template mail design

This commit is contained in:
Horilla
2023-12-18 17:20:28 +05:30
parent 22c44dfacc
commit 5cd9c53c7f
3 changed files with 174 additions and 6 deletions

View File

@@ -85,6 +85,12 @@
href="{% url 'rec-candidate-update' candidate.id %}?onboarding=True"
><ion-icon name="create-outline"></ion-icon
></a>
<a
class="oh-btn oh-btn--light-bkg w-100"
title="{% trans 'Send Portal' %}"
href="{% url 'rec-candidate-update' candidate.id %}?onboarding=True"
><ion-icon name="mail-outline"></ion-icon
></a>
<a
class="oh-btn oh-btn--danger-outline oh-btn--light-bkg w-100"
id="delete-link"

View File

@@ -0,0 +1,144 @@
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Horilla News Letter Design</title>
<style>
body {
margin: 0;
background-color: #e5e5e5;
}
table {
border-spacing: 0;
}
td {
padding: 0;
}
img {
border: 0;
}
.hr-wrapper {
width: 100%;
table-layout: fixed;
background-color: #e5e5e5;
padding-bottom: 60px;
}
.hr-table-main {
background-color: #fff;
margin: 0 auto;
width: 100%;
max-width: 650px;
border-spacing: 0;
font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif;
color: #1c1c1c;
margin-top: 15px;
}
.hr-table-main__header {
table-layout: fixed;
padding: 15px;
width: 100%;
}
.hr-link {
color: #6f6f6f;
font-size: 12px;
}
.hr-callout-table {
table-layout: fixed;
width: 100%;
border: 1px solid #f0f0f0;
font-size: 14px;
}
.hr-callout-table td {
padding: 10px;
background-color: #fafafa;
}
</style>
</head>
<body>
<center class="hr-wrapper">
<table class="hr-table-main" width="100%" style="margin-top:60px ;">
<tr>
<td>
<table class="hr-table-main__header">
<tr>
<td style="width: 50%">
<img src="{{protocol}}://{{host}}{% static '/images/ui/horilla-logo.png' %}" height="30" width="110.4" />
</td>
<td style="width: 50%; text-align: right">
<a href="#" class="hr-link">View in browser</a>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center" style="padding-top:20px;padding-bottom: 20px ;">
<img src="{{protocol}}://{{host}}{% static '/images/ui/commitment.png' %}" style="display:block;height:auto;border:0;width:20%" width="272" />
</td>
</tr>
<tr>
<td style="padding:15px 25px 0 25px; font-size: 24px;" align="center">
<strong>Hello {{ instance.name }}, Congratulations on your selection!</strong>
</td>
</tr>
<tr>
<td align="center" style="padding-top: 0px;">
<p style="width: 90%;">Your dedication is valued, and we wish you continued success. If you have questions or need assistance, feel free to ask. Best wishes for your journey! Kindly complete your profile when convenient.</p>
</td>
</tr>
<tr>
<td style="padding: 15px" align="center">
<a href="{{ portal }}" style="
background-color: #e54f37;
color: #fff;
border-radius: 10px;
display: inline-block;
padding: 15px 25px;
text-decoration: none;
font-weight: bold;
">Complete Profile</a>
</td>
</tr>
<tr>
<td align="center" style="
padding-left: 15px;
padding-right: 15px;
padding-top: 30px;
padding-bottom: 15px;
color: #5c5c5c;
font-size: 12px;
">
This mail was sent you because your email has been enrolled as an candidate at {{ instance.recruitment_id.company_id.company }}.<br />
Don't want to receive mails like these anymore?
<a href="#" style="color: #5c5c5c">Unsubscribe here</a>.
</td>
</tr>
<tr>
<td align="center" style="
padding-left: 15px;
padding-right: 15px;
padding-bottom: 10px;
padding-top: 10px;
color: #5c5c5c;
font-size: 12px;
">&copy; 2023 Horilla, Inc.</td>
</tr>
</table>
</center>
</body>
</html>

View File

@@ -10,8 +10,11 @@ actions to handle the request, process data, and generate a response.
This module is part of the recruitment project and is intended to
provide the main entry points for interacting with the application's functionality.
"""
from urllib.parse import parse_qs
import json, contextlib, random, secrets
from django.core.mail import EmailMessage
from django.template.loader import render_to_string
from django.core.mail import send_mail
from django.contrib.auth.models import User
from django.utils.translation import gettext as __
@@ -543,6 +546,8 @@ def email_send(request):
"""
if request.method != "POST":
return JsonResponse("", safe=False)
host = request.get_host()
protocol = "https" if request.is_secure() else "http"
candidates = request.POST.get("candidates")
json_list = json.loads(candidates)
if len(json_list) <= 0:
@@ -561,13 +566,26 @@ def email_send(request):
new_portal.save()
else:
OnboardingPortal(candidate_id=candidate, token=token).save()
send_mail(
"Onboarding Portal",
f"{request.get_host()}/onboarding/user-creation/{token}",
"from@example.com",
[candidate.email],
fail_silently=False,
html_message = render_to_string(
"onboarding/mail_templates/default.html",
{
"portal": f"{protocol}://{host}/onboarding/user-creation/{token}",
"instance": candidate,
"host": host,
"protocol": protocol,
},
)
email = EmailMessage(
f"Hello {candidate.name}, Congratulations on your selection!",
html_message,
settings.EMAIL_HOST_USER,
[candidate.email],
)
email.content_subtype = "html"
try:
email.send()
except:
messages.error(request,f"Mail not send to {candidate.name}")
candidate.start_onboard = True
candidate.save()
return JsonResponse({"message": _("Email send successfully"), "tags": "success"})