This commit is contained in:
karthikmurakonda 2023-10-19 06:52:29 +05:30
commit 34ec430468
2 changed files with 23 additions and 0 deletions

View File

@ -124,6 +124,8 @@ def updateDeadline(request, id, email, user_type):
opening.deadline_datetime = datetime.datetime.strptime(data[DEADLINE_DATETIME], '%Y-%m-%d %H:%M:%S %z')
opening.changed_by = get_object_or_404(User, id=id)
opening.save()
deadline=opening.deadline_datetime.strftime('%Y-%m-%d %H:%M:%S')
send_opening_to_notifications_service(id=opening.id,name=opening.company_name,deadline=deadline,role=opening.designation)
return Response({'action': "Update Deadline", 'message': "Deadline Updated"},
status=status.HTTP_200_OK)
except Http404:
@ -160,6 +162,8 @@ def updateOfferAccepted(request, id, email, user_type):
opening.changed_by = get_object_or_404(User, id=id)
opening.save()
if opening.offer_accepted:
deadline=deadline_datetime.strftime('%Y-%m-%d %H:%M:%S')
send_opening_to_notifications_service(id=opening.id,name=opening.company_name,deadline=deadline,role=opening.designation)
send_opening_notifications(opening.id,opening_type)
else:
raise ValueError("Offer Status already updated")

View File

@ -562,3 +562,22 @@ def send_email_for_opening(opening):
print("An error occurred while sending the email:", e)
@background_task.background(schedule=2)
def send_opening_to_notifications_service(id,name,deadline,role):
data={
"id":id,
"company":name,
"deadline":deadline,
"role":role
}
encoded=jwt.encode(data,os.environ.get("JWT_SECRET_KEY"),algorithm="HS256")
data_={
"token":encoded,
}
resp=rq.post(url=os.environ.get("PUSH_API_URL")+"addopening/",data=data_)
if resp.status_code==200:
print("Notification Sent")
else:
print("Notification Failed")
logger.warning("Utils - send_opening_to_notifications_service: " + str(resp) + "data sent:"+str(data))