diff --git a/CDC_Backend/APIs/models.py b/CDC_Backend/APIs/models.py
index 9321cc6..fcbaac0 100644
--- a/CDC_Backend/APIs/models.py
+++ b/CDC_Backend/APIs/models.py
@@ -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)
diff --git a/CDC_Backend/APIs/studentViews.py b/CDC_Backend/APIs/studentViews.py
index 2f7c7e1..0d7e010 100644
--- a/CDC_Backend/APIs/studentViews.py
+++ b/CDC_Backend/APIs/studentViews.py
@@ -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,23 +362,24 @@ 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"])
+ 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:
- try:
- issue.opening=get_object_or_404(Internship, id=data["opening_id"])
- except:
- return Response({'action': "Add Issue", 'message': "Opening Not Found"},
+ return Response({'action': "Add Issue", 'message': "Opening Not Found"},
status=status.HTTP_400_BAD_REQUEST)
issue.save()
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
diff --git a/CDC_Backend/APIs/utils.py b/CDC_Backend/APIs/utils.py
index 60ea4da..a31d5d1 100644
--- a/CDC_Backend/APIs/utils.py
+++ b/CDC_Backend/APIs/utils.py
@@ -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,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]):
try:
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)
#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'))
+ 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
except:
logger.warning('Utils - send_opening_notifications: ' + str(sys.exc_info()))
diff --git a/CDC_Backend/templates/reps_issue_submitted.html b/CDC_Backend/templates/reps_issue_submitted.html
index ac6ca1f..48fcc86 100644
--- a/CDC_Backend/templates/reps_issue_submitted.html
+++ b/CDC_Backend/templates/reps_issue_submitted.html
@@ -48,7 +48,7 @@
We have received a issue regarding a {{ application_type }} opening at
{{ company_name }} From {{name}}.
- {% if additional_info_items %}
+ {% if additional_info %}
We received these additional details