updates issuhandlers and mailer
This commit is contained in:
parent
59c1a0a59e
commit
17299b1861
|
@ -485,7 +485,9 @@ class Issues(models.Model):
|
||||||
id = models.AutoField(primary_key=True)
|
id = models.AutoField(primary_key=True)
|
||||||
title = models.CharField(max_length=JNF_SMALLTEXT_MAX_CHARACTER_COUNT, blank=False, default="")
|
title = models.CharField(max_length=JNF_SMALLTEXT_MAX_CHARACTER_COUNT, blank=False, default="")
|
||||||
description = models.CharField(max_length=200, 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="")
|
#status = models.CharField(max_length=JNF_SMALLTEXT_MAX_CHARACTER_COUNT, blank=False, default="")
|
||||||
student=models.ForeignKey(Student, on_delete=models.CASCADE, blank=False)
|
student=models.ForeignKey(Student, on_delete=models.CASCADE, blank=False)
|
||||||
created_at = models.DateTimeField(blank=False, default=None, null=True)
|
created_at = models.DateTimeField(blank=False, default=None, null=True)
|
||||||
|
|
|
@ -353,7 +353,7 @@ def studentAcceptOffer(request, id, email, user_type):
|
||||||
|
|
||||||
@api_view(['POST'])
|
@api_view(['POST'])
|
||||||
@isAuthorized(allowed_users=[STUDENT])
|
@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):
|
def addIssue(request, id, email, user_type):
|
||||||
try:
|
try:
|
||||||
data = request.data
|
data = request.data
|
||||||
|
@ -362,23 +362,24 @@ def addIssue(request, id, email, user_type):
|
||||||
issue.student = student
|
issue.student = student
|
||||||
issue.title = data["Title"]
|
issue.title = data["Title"]
|
||||||
issue.description = data["Description"]
|
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:
|
try:
|
||||||
issue.opening=get_object_or_404(Placement, 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:
|
except:
|
||||||
try:
|
return Response({'action': "Add Issue", 'message': "Opening Not Found"},
|
||||||
issue.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)
|
status=status.HTTP_400_BAD_REQUEST)
|
||||||
issue.save()
|
issue.save()
|
||||||
subject=ISSUE_SUBMITTED_TEMPLATE_SUBJECT
|
subject=ISSUE_SUBMITTED_TEMPLATE_SUBJECT
|
||||||
data={
|
data={
|
||||||
"name":student.name,
|
"name":student.name,
|
||||||
"application_type":PLACEMENT if isinstance(issue.opening,Placement) else INTERNSHIP,
|
"application_type":issue.opening_type,
|
||||||
"company_name":issue.opening.company_name,
|
"company_name":opening.company_name,
|
||||||
"additional_info":{
|
"additional_info":{
|
||||||
"Title":issue.title,
|
"Abstract":issue.title,
|
||||||
"Description":issue.description
|
"Description":issue.description
|
||||||
},
|
},
|
||||||
"email":email
|
"email":email
|
||||||
|
|
|
@ -254,7 +254,7 @@ def InternshipApplicationConditions(student, internship):
|
||||||
try:
|
try:
|
||||||
selected_companies = InternshipApplication.objects.filter(student=student, selected=True)
|
selected_companies = InternshipApplication.objects.filter(student=student, selected=True)
|
||||||
if len(selected_companies)>=1:
|
if len(selected_companies)>=1:
|
||||||
print("selected companies > 1")
|
# print("selected companies > 1")
|
||||||
return False, "You have already secured a Internship"
|
return False, "You have already secured a Internship"
|
||||||
return True, "Conditions Satisfied"
|
return True, "Conditions Satisfied"
|
||||||
|
|
||||||
|
@ -420,23 +420,22 @@ 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]):
|
if (isinstance(opening,Placement) and PlacementApplicationConditions(student, opening)[0]) or (isinstance(opening,Internship) and InternshipApplicationConditions(student, opening)[0]):
|
||||||
try:
|
try:
|
||||||
student_user = get_object_or_404(User, id=student.id)
|
student_user = get_object_or_404(User, id=student.id)
|
||||||
subject = NOTIFY_STUDENTS_OPENING_TEMPLATE_SUBJECT.format(
|
|
||||||
company_name=opening.company_name)
|
|
||||||
deadline_datetime = opening.deadline_datetime.astimezone(pytz.timezone('Asia/Kolkata'))
|
|
||||||
data = {
|
|
||||||
"company_name": opening.company_name,
|
|
||||||
"opening_type": "INTERNSHIP" if isinstance(opening, Internship) else "PLACEMENT",
|
|
||||||
"designation": opening.designation,
|
|
||||||
"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)
|
emails.append(student_user.email)
|
||||||
#sendEmail(student_user.email, subject, data, NOTIFY_STUDENTS_OPENING_TEMPLATE)
|
#sendEmail(student_user.email, subject, data, NOTIFY_STUDENTS_OPENING_TEMPLATE)
|
||||||
except Http404:
|
except Http404:
|
||||||
logger.warning('Utils - send_opening_notifications: user not found : ' + student.id)
|
logger.warning('Utils - send_opening_notifications: user not found : ' + student.id)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning('Utils - send_opening_notifications: For Loop' + str(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'))
|
||||||
|
data = {
|
||||||
|
"company_name": opening.company_name,
|
||||||
|
"opening_type": "INTERNSHIP" if isinstance(opening, Internship) else "PLACEMENT",
|
||||||
|
"designation": opening.designation,
|
||||||
|
"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),
|
||||||
|
}
|
||||||
sendEmail(emails, subject, data, NOTIFY_STUDENTS_OPENING_TEMPLATE) #handled multiple mailings
|
sendEmail(emails, subject, data, NOTIFY_STUDENTS_OPENING_TEMPLATE) #handled multiple mailings
|
||||||
except:
|
except:
|
||||||
logger.warning('Utils - send_opening_notifications: ' + str(sys.exc_info()))
|
logger.warning('Utils - send_opening_notifications: ' + str(sys.exc_info()))
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
We have received a issue regarding a <b>{{ application_type }}</b> opening at
|
We have received a issue regarding a <b>{{ application_type }}</b> opening at
|
||||||
<b>
|
<b>
|
||||||
{{ company_name }}</b> From {{name}}.
|
{{ company_name }}</b> From {{name}}.
|
||||||
{% if additional_info_items %}
|
{% if additional_info %}
|
||||||
We received these additional details
|
We received these additional details
|
||||||
<br>
|
<br>
|
||||||
<p style="margin:0 0 12px 0;font-size:16px;line-height:24px;font-family:
|
<p style="margin:0 0 12px 0;font-size:16px;line-height:24px;font-family:
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
We have received your issue regarding a <b>{{ application_type }}</b> opening at
|
We have received your issue regarding a <b>{{ application_type }}</b> opening at
|
||||||
<b>
|
<b>
|
||||||
{{ company_name }}</b>.
|
{{ company_name }}</b>.
|
||||||
{% if additional_info_items %}
|
{% if additional_info %}
|
||||||
We received these additional details
|
We received these additional details
|
||||||
<br>
|
<br>
|
||||||
<p style="margin:0 0 12px 0;font-size:16px;line-height:24px;font-family:
|
<p style="margin:0 0 12px 0;font-size:16px;line-height:24px;font-family:
|
||||||
|
|
Loading…
Reference in New Issue