Fixing timezone issue in opening mails (#146)

This commit is contained in:
Gowtham Sai 2022-10-13 16:22:10 +05:30 committed by GitHub
parent d9939885fc
commit 0058feb06e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -12,6 +12,7 @@ from os import path, remove
import background_task import background_task
import jwt import jwt
import pdfkit import pdfkit
import pytz
import requests as rq import requests as rq
from django.conf import settings from django.conf import settings
from django.core.mail import EmailMultiAlternatives from django.core.mail import EmailMultiAlternatives
@ -329,11 +330,12 @@ def send_opening_notifications(placement_id):
student_user = get_object_or_404(User, id=student.id) student_user = get_object_or_404(User, id=student.id)
subject = NOTIFY_STUDENTS_OPENING_TEMPLATE_SUBJECT.format( subject = NOTIFY_STUDENTS_OPENING_TEMPLATE_SUBJECT.format(
company_name=placement.company_name) company_name=placement.company_name)
deadline_datetime = placement.deadline_datetime.astimezone(pytz.timezone('Asia/Kolkata'))
data = { data = {
"company_name": placement.company_name, "company_name": placement.company_name,
"opening_type": 'Placement', "opening_type": 'Placement',
"designation": placement.designation, "designation": placement.designation,
"deadline": placement.deadline_datetime.strftime("%A, %-d %B %Y, %-I:%M %p"), "deadline": deadline_datetime.strftime("%A, %-d %B %Y, %-I:%M %p"),
"link": PLACEMENT_OPENING_URL.format(id=placement.id) "link": PLACEMENT_OPENING_URL.format(id=placement.id)
} }
sendEmail(student_user.email, subject, data, NOTIFY_STUDENTS_OPENING_TEMPLATE) sendEmail(student_user.email, subject, data, NOTIFY_STUDENTS_OPENING_TEMPLATE)