fixed notifications
This commit is contained in:
parent
5d0f9fba58
commit
ed6f313b68
|
@ -158,7 +158,7 @@ def updateOfferAccepted(request, id, email, user_type):
|
||||||
opening.changed_by = get_object_or_404(User, id=id)
|
opening.changed_by = get_object_or_404(User, id=id)
|
||||||
opening.save()
|
opening.save()
|
||||||
if opening.offer_accepted:
|
if opening.offer_accepted:
|
||||||
send_opening_notifications(opening.id)
|
send_opening_notifications(opening.id,opening_type)
|
||||||
else:
|
else:
|
||||||
raise ValueError("Offer Status already updated")
|
raise ValueError("Offer Status already updated")
|
||||||
|
|
||||||
|
|
|
@ -405,26 +405,29 @@ def internship_eligibility_filters(student, internships):
|
||||||
|
|
||||||
|
|
||||||
@background_task.background(schedule=2)
|
@background_task.background(schedule=2)
|
||||||
def send_opening_notifications(placement_id):
|
def send_opening_notifications(opening_id, opening_type):
|
||||||
try:
|
try:
|
||||||
placement = get_object_or_404(Placement, id=placement_id)
|
if opening_type == PLACEMENT:
|
||||||
|
opening = get_object_or_404(Placement, id=opening_id)
|
||||||
|
else:
|
||||||
|
opening = get_object_or_404(Internship, id=opening_id)
|
||||||
emails=[]
|
emails=[]
|
||||||
students = Student.objects.all()
|
students = Student.objects.all()
|
||||||
for student in students.iterator():
|
for student in students.iterator():
|
||||||
if student.branch in placement.allowed_branch:
|
if student.branch in opening.allowed_branch:
|
||||||
if student.degree == 'bTech' or placement.rs_eligible is True:
|
if student.degree == 'bTech' or opening.rs_eligible is True:
|
||||||
if PlacementApplicationConditions(student, placement)[0]:
|
if (isinstance(opening,Placement) and PlacementApplicationConditions(student, opening)[0]) or (isinstance(opening,Internship) and InternshipApplicationConditions(student, opening)[0]):
|
||||||
try:
|
try:
|
||||||
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=opening.company_name)
|
||||||
deadline_datetime = placement.deadline_datetime.astimezone(pytz.timezone('Asia/Kolkata'))
|
deadline_datetime = opening.deadline_datetime.astimezone(pytz.timezone('Asia/Kolkata'))
|
||||||
data = {
|
data = {
|
||||||
"company_name": placement.company_name,
|
"company_name": opening.company_name,
|
||||||
"opening_type": 'Placement',
|
"opening_type": "INTERNSHIP" if isinstance(opening, Internship) else "PLACEMENT",
|
||||||
"designation": placement.designation,
|
"designation": opening.designation,
|
||||||
"deadline": 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.designation)
|
"link": PLACEMENT_OPENING_URL.format(id=opening.designation)
|
||||||
}
|
}
|
||||||
emails.append(student_user.email)
|
emails.append(student_user.email)
|
||||||
#sendEmail(student_user.email, subject, data, NOTIFY_STUDENTS_OPENING_TEMPLATE)
|
#sendEmail(student_user.email, subject, data, NOTIFY_STUDENTS_OPENING_TEMPLATE)
|
||||||
|
@ -432,6 +435,7 @@ def send_opening_notifications(placement_id):
|
||||||
logger.warning('Utils - send_opening_notifications: user not found : ' + student.id)
|
logger.warning('Utils - send_opening_notifications: user not found : ' + student.id)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning('Utils - send_opening_notifications: For Loop' + str(e))
|
logger.warning('Utils - send_opening_notifications: For Loop' + str(e))
|
||||||
|
|
||||||
sendEmail(emails, subject, data, NOTIFY_STUDENTS_OPENING_TEMPLATE) #handled multiple mailings
|
sendEmail(emails, subject, data, NOTIFY_STUDENTS_OPENING_TEMPLATE) #handled multiple mailings
|
||||||
except:
|
except:
|
||||||
logger.warning('Utils - send_opening_notifications: ' + str(sys.exc_info()))
|
logger.warning('Utils - send_opening_notifications: ' + str(sys.exc_info()))
|
||||||
|
@ -442,7 +446,7 @@ def exception_email(opening):
|
||||||
opening = opening.dict()
|
opening = opening.dict()
|
||||||
data = {
|
data = {
|
||||||
"designation": opening["designation"],
|
"designation": opening["designation"],
|
||||||
"opening_type": PLACEMENT,
|
"opening_type": "INTERNSHIP" if opening["opening_type"] == "INF" else "PLACEMENT",
|
||||||
"company_name": opening["company_name"],
|
"company_name": opening["company_name"],
|
||||||
}
|
}
|
||||||
pdfhtml = opening_description_table_html(opening)
|
pdfhtml = opening_description_table_html(opening)
|
||||||
|
|
Loading…
Reference in New Issue