updates issuhandlers and mailer

This commit is contained in:
uttamthummala 2023-10-03 19:14:10 +05:30
parent 59c1a0a59e
commit 17299b1861
5 changed files with 27 additions and 25 deletions

View File

@ -485,7 +485,9 @@ class Issues(models.Model):
id = models.AutoField(primary_key=True)
title = models.CharField(max_length=JNF_SMALLTEXT_MAX_CHARACTER_COUNT, blank=False, default="")
description = models.CharField(max_length=200, blank=False, default="")
opening=(models.ForeignKey(Placement, on_delete=models.CASCADE, blank=False) or models.ForeignKey(Internship, on_delete=models.CASCADE, blank=False))
#opening=(models.ForeignKey(Placement, on_delete=models.CASCADE, blank=False) or models.ForeignKey(Internship, on_delete=models.CASCADE, blank=False))
opening_id=models.CharField(blank=False, max_length=15, default=None, null=True)
opening_type=models.CharField(choices=[('Placement','Placement'),('Internship','Internship')], blank=False, max_length=15, default=PLACEMENT)
#status = models.CharField(max_length=JNF_SMALLTEXT_MAX_CHARACTER_COUNT, blank=False, default="")
student=models.ForeignKey(Student, on_delete=models.CASCADE, blank=False)
created_at = models.DateTimeField(blank=False, default=None, null=True)

View File

@ -353,7 +353,7 @@ def studentAcceptOffer(request, id, email, user_type):
@api_view(['POST'])
@isAuthorized(allowed_users=[STUDENT])
@precheck(required_data=["Title","Description","opening_id"])
@precheck(required_data=["Title","Description","opening_id","opening_type"])
def addIssue(request, id, email, user_type):
try:
data = request.data
@ -362,12 +362,13 @@ def addIssue(request, id, email, user_type):
issue.student = student
issue.title = data["Title"]
issue.description = data["Description"]
# issue.opening=get_object_or_404(Placement, id=data["opening_id"]) or get_object_or_404(Internship, id=data["opening_id"])
issue.opening_id = data["opening_id"]
issue.opening_type = data["opening_type"]
try:
issue.opening=get_object_or_404(Placement, id=data["opening_id"])
except:
try:
issue.opening=get_object_or_404(Internship, id=data["opening_id"])
if data["opening_type"]==PLACEMENT:
opening=get_object_or_404(Placement, id=data["opening_id"])
else:
opening=get_object_or_404(Internship, id=data["opening_id"])
except:
return Response({'action': "Add Issue", 'message': "Opening Not Found"},
status=status.HTTP_400_BAD_REQUEST)
@ -375,10 +376,10 @@ def addIssue(request, id, email, user_type):
subject=ISSUE_SUBMITTED_TEMPLATE_SUBJECT
data={
"name":student.name,
"application_type":PLACEMENT if isinstance(issue.opening,Placement) else INTERNSHIP,
"company_name":issue.opening.company_name,
"application_type":issue.opening_type,
"company_name":opening.company_name,
"additional_info":{
"Title":issue.title,
"Abstract":issue.title,
"Description":issue.description
},
"email":email

View File

@ -254,7 +254,7 @@ def InternshipApplicationConditions(student, internship):
try:
selected_companies = InternshipApplication.objects.filter(student=student, selected=True)
if len(selected_companies)>=1:
print("selected companies > 1")
# print("selected companies > 1")
return False, "You have already secured a Internship"
return True, "Conditions Satisfied"
@ -420,6 +420,12 @@ def send_opening_notifications(opening_id, opening_type=PLACEMENT):
if (isinstance(opening,Placement) and PlacementApplicationConditions(student, opening)[0]) or (isinstance(opening,Internship) and InternshipApplicationConditions(student, opening)[0]):
try:
student_user = get_object_or_404(User, id=student.id)
emails.append(student_user.email)
#sendEmail(student_user.email, subject, data, NOTIFY_STUDENTS_OPENING_TEMPLATE)
except Http404:
logger.warning('Utils - send_opening_notifications: user not found : ' + student.id)
except Exception as e:
logger.warning('Utils - send_opening_notifications: For Loop' + str(e))
subject = NOTIFY_STUDENTS_OPENING_TEMPLATE_SUBJECT.format(
company_name=opening.company_name)
deadline_datetime = opening.deadline_datetime.astimezone(pytz.timezone('Asia/Kolkata'))
@ -430,13 +436,6 @@ def send_opening_notifications(opening_id, opening_type=PLACEMENT):
"deadline": deadline_datetime.strftime("%A, %-d %B %Y, %-I:%M %p"),
"link": PLACEMENT_OPENING_URL.format(id=opening.designation) if opening_type == PLACEMENT else INTERNSHIP_OPENING_URL.format(id=opening.designation),
}
emails.append(student_user.email)
#sendEmail(student_user.email, subject, data, NOTIFY_STUDENTS_OPENING_TEMPLATE)
except Http404:
logger.warning('Utils - send_opening_notifications: user not found : ' + student.id)
except Exception as e:
logger.warning('Utils - send_opening_notifications: For Loop' + str(e))
sendEmail(emails, subject, data, NOTIFY_STUDENTS_OPENING_TEMPLATE) #handled multiple mailings
except:
logger.warning('Utils - send_opening_notifications: ' + str(sys.exc_info()))

View File

@ -48,7 +48,7 @@
We have received a issue regarding a <b>{{ application_type }}</b> opening at
<b>
{{ company_name }}</b> From {{name}}.
{% if additional_info_items %}
{% if additional_info %}
We received these additional details
<br>
<p style="margin:0 0 12px 0;font-size:16px;line-height:24px;font-family:

View File

@ -48,7 +48,7 @@
We have received your issue regarding a <b>{{ application_type }}</b> opening at
<b>
{{ company_name }}</b>.
{% if additional_info_items %}
{% if additional_info %}
We received these additional details
<br>
<p style="margin:0 0 12px 0;font-size:16px;line-height:24px;font-family: