added email option while jnf submission error

This commit is contained in:
karthikmurakonda 2022-08-31 00:45:16 +05:30
parent 9260d121e5
commit 6a3b5042b1
2 changed files with 18 additions and 0 deletions

View File

@ -230,10 +230,12 @@ def addPlacement(request):
status=status.HTTP_200_OK)
except ValueError as e:
exception_email(opening)
logger.info("ValueError in addPlacement: " + str(e))
return Response({'action': "Add Placement", 'message': str(e)},
status=status.HTTP_400_BAD_REQUEST)
except:
exception_email(opening)
logger.warning("Add New Placement: " + str(sys.exc_info()))
return Response({'action': "Add Placement", 'message': "Something went wrong"},
status=status.HTTP_400_BAD_REQUEST)

View File

@ -331,3 +331,19 @@ def send_opening_notifications(placement_id):
except:
logger.warning('Utils - send_opening_notifications: ' + str(sys.exc_info()))
return False
def exception_email(opening):
data = {
"designation": opening.designation,
"opening_type": PLACEMENT,
"company_name": opening.company_name,
}
pdfhtml = opening_description_table_html(opening)
name = opening.company_name + '_jnf_response.pdf'
attachment_jnf_respone = {
"name": name,
"html": pdfhtml,
}
sendEmail(CDC_MAIl_ADDRESS, COMPANY_OPENING_SUBMITTED_TEMPLATE_SUBJECT.format(id=opening.id), data,
COMPANY_OPENING_SUBMITTED_TEMPLATE, attachment_jnf_respone)