-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update: Intgrated the sendgrid service.
- Loading branch information
1 parent
7de665f
commit 801c5b8
Showing
8 changed files
with
127 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
window.env = { | ||
SERVER_DOMAIN_NAME_API: 'https://cshrserver.gent01.qa.grid.tf/api', // Added for testing, this is a staging API | ||
SERVER_DOMAIN_NAME_API: 'http://127.0.0.1:8000/api', // Added for testing, this is a staging API | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
from django.conf import settings | ||
from celery import Celery | ||
from celery.schedules import crontab | ||
from django.core.mail import EmailMultiAlternatives | ||
|
||
import datetime | ||
from django.core.mail import send_mail | ||
from celery import shared_task | ||
|
@@ -172,25 +174,50 @@ def send_quarter_evaluation_email(): | |
|
||
|
||
@shared_task() | ||
def send_email_for_request(user_id, msg, mail_title) -> Response: | ||
from django.core.mail import send_mail | ||
def send_email_for_request(user_id) -> Response: | ||
from cshr.models.users import User | ||
from cshr.utils.send_email import get_email_recievers | ||
from cshr.services.users import get_user_by_id | ||
from cshr.utils.send_email import check_email_configuration | ||
|
||
check_email_configuration() | ||
user: User = get_user_by_id(user_id) | ||
|
||
if user is None: | ||
return False | ||
|
||
recievers: array[str] = get_email_recievers(user) | ||
mail = EmailMultiAlternatives( | ||
subject="Vacation Request Notification", | ||
from_email="Codescalers HR <[email protected]>", | ||
to=recievers, | ||
headers={"Reply-To": "[email protected]"} | ||
) | ||
mail.categories = [ | ||
'work', | ||
'urgent', | ||
] | ||
mail.attach_alternative( | ||
f""" | ||
<p>I trust this message finds you and your family in good health.</p> | ||
<p>I wanted to bring to your attention that { user.full_name } has recently submitted a vacation request. To review and manage this notification, please log in to your CSHR account and check your <a href='https://hr.threefold.tech/notifications/' target='_blank'>notifications</a>.</p> | ||
<p>Thank you for your attention to this matter.</p> | ||
<p>Best regards,</p> | ||
<hr/> | ||
<strong> | ||
<small>Codescalers HR Mail System</small> | ||
<br/> | ||
<small>Note: This email was sent via the Codescalers HR email system. Please refrain from replying to this email.</small> | ||
</strong> | ||
""", | ||
"text/html" | ||
) | ||
|
||
try: | ||
send_mail( | ||
mail_title, msg, settings.EMAIL_HOST_USER, recievers, fail_silently=False | ||
) | ||
mail.send() | ||
return True | ||
except Exception: | ||
return False | ||
return True | ||
|
||
|
||
@shared_task() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters