fixed: email not sending when application is edit

- indexed id for student.
This commit is contained in:
karthik murakonda 2022-07-28 11:37:09 +05:30
parent 0488e3e334
commit afd61d8ef4
3 changed files with 22 additions and 15 deletions

View File

@ -229,8 +229,7 @@ def submitApplication(request, id, email, user_type):
data = request.data
student = get_object_or_404(Student, pk=data[STUDENT_ID])
opening = get_object_or_404(Placement, pk=data[OPENING_ID])
user = get_object_or_404(User, pk=data[STUDENT_ID])
student_user = get_object_or_404(User, id = student.id)
if data[APPLICATION_ID] == "":
application = PlacementApplication()
application.id = generateRandomString()
@ -253,9 +252,9 @@ def submitApplication(request, id, email, user_type):
"application_type": "Placement",
"additional_info": dict(json.loads(application.additional_info)),
}
subject = STUDENT_APPLICATION_SUBMITTED_TEMPLATE_SUBJECT.format(company_name=opening.company_name)
application.changed_by = get_object_or_404(User, id=id)
application.save()
sendEmail(user.email, STUDENT_APPLICATION_SUBMITTED_TEMPLATE_SUBJECT, data, STUDENT_APPLICATION_SUBMITTED_TEMPLATE)
sendEmail(student_user.email, subject, data, STUDENT_APPLICATION_SUBMITTED_TEMPLATE)
return Response({'action': "Add Student Application", 'message': "Application added"},
status=status.HTTP_200_OK)
else:
@ -278,11 +277,13 @@ def submitApplication(request, id, email, user_type):
"name": student.name,
"company_name": opening.company_name,
"application_type": "Placement",
"additional_info": dict(json.loads(application.additional_info)),
"resume": application.resume[16:],
"additional_info_items": dict(json.loads(application.additional_info)),
}
subject = STUDENT_APPLICATION_SUBMITTED_TEMPLATE_SUBJECT.format(company_name=opening.company_name)
application.changed_by = get_object_or_404(User, id=id)
application.save()
sendEmail(user.email, STUDENT_APPLICATION_UPDATED_TEMPLATE_SUBJECT, data, STUDENT_APPLICATION_UPDATED_TEMPLATE)
sendEmail(student_user.email, subject, data, STUDENT_APPLICATION_UPDATED_TEMPLATE)
return Response({'action': "Add Student Application", 'message': "Application updated"},
status=status.HTTP_200_OK)
else:

View File

@ -10,8 +10,8 @@ from .constants import *
class User(models.Model):
email = models.EmailField(blank=False, max_length=JNF_TEXT_MAX_CHARACTER_COUNT, unique=True)
id = models.CharField(blank=False, max_length=25, index=True, unique=True)
email = models.EmailField(blank=False, max_length=JNF_TEXT_MAX_CHARACTER_COUNT, unique=True, primary_key=True)
id = models.CharField(blank=False, max_length=25, db_index=True)
user_type = ArrayField(models.CharField(blank=False, max_length=10), size=4, default=list, blank=False)
last_login_time = models.DateTimeField(default=timezone.now)
history = HistoricalRecords()

View File

@ -48,16 +48,22 @@
We have received some update in your application for a <b>{{ application_type }}</b> offer at
<b>
{{ company_name }}</b>.
<table style="border:solid 1px; margin: auto; text-align: center;width: 80%;
border-radius:15px; background-color: #e0e3ee">
<tr>
<td style="padding:8px 10px;color:#153643; "> resume:</td>
<td style="padding:8px 10px;color:#153643;">{{ resume }}</td>
</tr>
</table>
{% if additional_info_items %}
We received these additional details
<br>
<p style="margin:0 0 12px 0;font-size:16px;line-height:24px;font-family:
'Roboto', sans-serif;text-align: center">
<table style="border:solid 1px; margin: auto; text-align: center;width: 80%;
border-radius:15px; background-color: #e0e3ee">
{% for i,j in additional_info.items %}
<p style="margin:0 0 12px 0;font-size:16px;line-height:24px;font-family:
'Roboto', sans-serif;text-align: center">
{% for i,j in additional_info_items.items %}
<tr>
<td style="padding:8px 10px;color:#153643; ">{{ i }}:</td>