send email when application is created/edited by admin

This commit is contained in:
karthikmurakonda 2022-07-23 14:51:34 +05:30
parent ca68276738
commit f14d4bae8d
2 changed files with 16 additions and 0 deletions

1
.gitignore vendored
View File

@ -139,3 +139,4 @@ dmypy.json
/CDC_Backend/Storage/ /CDC_Backend/Storage/
.idea .idea
*.pyc *.pyc
dev.env

View File

@ -199,6 +199,7 @@ def submitApplication(request, id, email, user_type):
data = request.data data = request.data
student = get_object_or_404(Student, pk=data[STUDENT_ID]) student = get_object_or_404(Student, pk=data[STUDENT_ID])
opening = get_object_or_404(Placement, pk=data[OPENING_ID]) opening = get_object_or_404(Placement, pk=data[OPENING_ID])
user = get_object_or_404(User, pk=data[STUDENT_ID])
if data[APPLICATION_ID] == "": if data[APPLICATION_ID] == "":
application = PlacementApplication() application = PlacementApplication()
@ -216,7 +217,14 @@ def submitApplication(request, id, email, user_type):
else: else:
additional_info[i] = data[ADDITIONAL_INFO][i] additional_info[i] = data[ADDITIONAL_INFO][i]
application.additional_info = json.dumps(additional_info) application.additional_info = json.dumps(additional_info)
data = {
"name": student.name,
"company_name": opening.company_name,
"application_type": "Placement",
"additional_info": dict(json.loads(application.additional_info)),
}
application.save() application.save()
sendEmail(user.email, STUDENT_APPLICATION_SUBMITTED_TEMPLATE_SUBJECT, data, STUDENT_APPLICATION_SUBMITTED_TEMPLATE)
return Response({'action': "Add Student Application", 'message': "Application added"}, return Response({'action': "Add Student Application", 'message': "Application added"},
status=status.HTTP_200_OK) status=status.HTTP_200_OK)
else: else:
@ -235,7 +243,14 @@ def submitApplication(request, id, email, user_type):
additional_info[i] = data[ADDITIONAL_INFO][i] additional_info[i] = data[ADDITIONAL_INFO][i]
application.additional_info = json.dumps(additional_info) application.additional_info = json.dumps(additional_info)
data = {
"name": student.name,
"company_name": opening.company_name,
"application_type": "Placement",
"additional_info": dict(json.loads(application.additional_info)),
}
application.save() application.save()
sendEmail(user.email, STUDENT_APPLICATION_UPDATED_TEMPLATE_SUBJECT, data, STUDENT_APPLICATION_UPDATED_TEMPLATE)
return Response({'action': "Add Student Application", 'message': "Application updated"}, return Response({'action': "Add Student Application", 'message': "Application updated"},
status=status.HTTP_200_OK) status=status.HTTP_200_OK)
else: else: