Skip to content

Commit

Permalink
Merge pull request #910 from AI4Bharat/archive
Browse files Browse the repository at this point in the history
Archive
  • Loading branch information
aparna-aa authored Dec 27, 2024
2 parents 405cea2 + ed71a79 commit 0b64c2d
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 2 deletions.
4 changes: 2 additions & 2 deletions backend/user_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import logging
from organization.models import Organization
from config import app_name
from utils.email_template import send_email_template_with_attachment
from utils.email_template import send_email_template_with_attachment,complete_email_template_with_attachment


def get_completed_tasks():
Expand Down Expand Up @@ -105,7 +105,7 @@ def get_completed_tasks():
)
logging.info("Sending Mail to %s", manager.email)

compiled_msg = send_email_template_with_attachment(
compiled_msg = complete_email_template_with_attachment(
subject=f"{app_name} - Completed Tasks Report",
username=manager["email"].split("@")[0],
message=email_to_send,
Expand Down
92 changes: 92 additions & 0 deletions backend/utils/email_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,98 @@ def send_email_template_with_attachment(subject, username, message):
</html>
"""
return html_code
def complete_email_template_with_attachment(subject, username, message):
style_string = """
*{ margin: 0;
padding: 0;
}
body {
font-family: "Arial", sans-serif;
background-color: #f2f8f8;
margin: 0;
padding: 0;
padding-top: 2rem;
}
.container {
background-color: #fff;
# border: solid 1px #e1e1e1;
border-radius: 2px;
padding: 1.4rem;
max-width: 380px;
margin: auto;
}
.header {
width: fit-content;
margin: auto;
}
h1 {
font-size: 1.2rem;
font-weight: 300;
margin: 1rem 0;
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}
p {
font-size: 0.8rem;
color: #222;
margin: 0.8rem 0;
}
.primary {
color: #18621f;
}
.footer {
margin-top: 1rem;
font-size: 0.9rem;
}
.footer > * {
font-size: inherit;
}
"""

html_code = f"""
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>{subject}</title>
<style>
{style_string}
</style>
</head>
<body style="background-color:#E4F9FE;padding:1rem">
<div class="container">
<header class="header">
<h3>{subject}</h3>
</header>
<main>
<div style="margin: 1rem auto; width: fit-content">
</div>
<div>
<p style="font-size:14px">
Dear {username},
</p>
<p >
{message}
</p>
<p style="font-style: italic;padding-top:1rem">
Thanks for contributing on Chitralekha! Kindly check the attachment below
</p>
<p style="font-size: 10px; color:grey">
This email was intended for <span style="color:blue">{username}</span> If you have already completed the task, please ignore this email.
</p>
</div>
</main>
<footer class="footer">
<p style="font-size: 0.8rem;">
Best Regards,<br />
Chitralekha Admin
</p>
</footer>
</div>
</body>
</html>
"""
return html_code


def send_email_template(subject, message):
Expand Down

0 comments on commit 0b64c2d

Please sign in to comment.