2021-12-17 19:23:32 +05:30
|
|
|
import csv
|
2024-06-19 22:22:41 +05:30
|
|
|
import zipfile
|
2021-12-03 01:04:49 +05:30
|
|
|
|
|
|
|
from rest_framework.decorators import api_view
|
2021-12-17 19:23:32 +05:30
|
|
|
|
2021-12-03 01:04:49 +05:30
|
|
|
from .serializers import *
|
2021-12-17 19:23:32 +05:30
|
|
|
from .utils import *
|
2021-12-03 01:04:49 +05:30
|
|
|
|
|
|
|
|
|
|
|
@api_view(['POST'])
|
|
|
|
@isAuthorized([ADMIN])
|
|
|
|
@precheck([OPENING_ID, STUDENT_LIST])
|
|
|
|
def markStatus(request, id, email, user_type):
|
|
|
|
try:
|
|
|
|
data = request.data
|
2023-10-03 01:47:26 +05:30
|
|
|
if OPENING_TYPE in data:
|
|
|
|
opening_type= data[OPENING_TYPE] #not to break the code
|
|
|
|
else:
|
|
|
|
opening_type= "Placement"
|
|
|
|
if opening_type == "Internship":
|
|
|
|
applications = InternshipApplication.objects.filter(internship_id=data[OPENING_ID])
|
|
|
|
else:
|
|
|
|
applications = PlacementApplication.objects.filter(placement_id=data[OPENING_ID])
|
2021-12-03 01:04:49 +05:30
|
|
|
for i in data[STUDENT_LIST]:
|
2021-12-17 17:15:56 +05:30
|
|
|
application = applications.filter(student__roll_no=i[STUDENT_ID]) # Filtering student's application
|
2021-12-03 01:04:49 +05:30
|
|
|
if len(application) > 0:
|
|
|
|
application = application[0]
|
2022-05-19 19:10:58 +05:30
|
|
|
if not application.selected:
|
|
|
|
if i[STUDENT_SELECTED] == True:
|
|
|
|
application.selected = True
|
|
|
|
else:
|
|
|
|
application.selected = False
|
|
|
|
else:
|
|
|
|
raise ValueError("Student already selected")
|
2021-12-03 01:04:49 +05:30
|
|
|
|
|
|
|
email = str(application.student.roll_no) + "@iitdh.ac.in" # Only allowing for IITDh emails
|
2023-10-03 01:47:26 +05:30
|
|
|
if opening_type == "Internship":
|
|
|
|
subject = STUDENT_APPLICATION_STATUS_TEMPLATE_SUBJECT.format(
|
|
|
|
company_name=application.internship.company_name,id=application.id)
|
|
|
|
data = {
|
|
|
|
"company_name": application.internship.company_name,
|
|
|
|
"designation": application.internship.designation,
|
|
|
|
"student_name": application.student.name
|
|
|
|
}
|
|
|
|
else:
|
|
|
|
subject = STUDENT_APPLICATION_STATUS_TEMPLATE_SUBJECT.format(
|
|
|
|
company_name=application.placement.company_name,
|
|
|
|
id=application.id)
|
|
|
|
data = {
|
|
|
|
"company_name": application.placement.company_name,
|
|
|
|
"designation": application.placement.designation,
|
|
|
|
"student_name": application.student.name
|
|
|
|
}
|
2021-12-03 01:04:49 +05:30
|
|
|
if application.selected: # Sending corresponding email to students
|
|
|
|
sendEmail(email, subject, data, STUDENT_APPLICATION_STATUS_SELECTED_TEMPLATE)
|
|
|
|
else:
|
|
|
|
sendEmail(email, subject, data, STUDENT_APPLICATION_STATUS_NOT_SELECTED_TEMPLATE)
|
2022-07-21 16:41:31 +05:30
|
|
|
application.chaged_by = get_object_or_404(User, id=id)
|
2021-12-03 01:04:49 +05:30
|
|
|
application.save()
|
|
|
|
else:
|
2023-10-06 03:19:25 +05:30
|
|
|
raise ValueError("Student - " + str(i[STUDENT_ID]) + " didn't apply for this opening")
|
2021-12-03 01:04:49 +05:30
|
|
|
return Response({'action': "Mark Status", 'message': "Marked Status"},
|
|
|
|
status=status.HTTP_200_OK)
|
|
|
|
|
|
|
|
except ValueError as e:
|
|
|
|
return Response({'action': "Mark Status", 'message': str(e)},
|
|
|
|
status=status.HTTP_400_BAD_REQUEST)
|
|
|
|
except:
|
|
|
|
logger.warning("Mark Status: " + str(sys.exc_info()))
|
|
|
|
return Response({'action': "Mark Status", 'message': "Something went wrong"},
|
|
|
|
status=status.HTTP_400_BAD_REQUEST)
|
|
|
|
|
|
|
|
|
|
|
|
@api_view(['GET'])
|
|
|
|
@isAuthorized([ADMIN])
|
|
|
|
def getDashboard(request, id, email, user_type):
|
|
|
|
try:
|
|
|
|
placements = Placement.objects.all().order_by('-created_at')
|
2022-05-24 15:07:32 +05:30
|
|
|
ongoing = placements.filter(deadline_datetime__gt=timezone.now(), offer_accepted=True, email_verified=True)
|
|
|
|
previous = placements.exclude(deadline_datetime__gt=timezone.now()).filter(
|
2022-05-23 00:21:47 +05:30
|
|
|
offer_accepted=True, email_verified=True)
|
|
|
|
new = placements.filter(offer_accepted__isnull=True, email_verified=True)
|
2023-10-03 01:47:26 +05:30
|
|
|
internships=Internship.objects.all().order_by('-created_at')
|
|
|
|
ongoing_internships = internships.filter(deadline_datetime__gt=timezone.now(), offer_accepted=True, email_verified=True)
|
|
|
|
previous_internships = internships.exclude(deadline_datetime__gt=timezone.now()).filter(
|
|
|
|
offer_accepted=True, email_verified=True)
|
|
|
|
new_internships = internships.filter(offer_accepted__isnull=True, email_verified=True)
|
2021-12-03 01:04:49 +05:30
|
|
|
ongoing = PlacementSerializerForAdmin(ongoing, many=True).data
|
|
|
|
previous = PlacementSerializerForAdmin(previous, many=True).data
|
2021-12-16 23:05:04 +05:30
|
|
|
new = PlacementSerializerForAdmin(new, many=True).data
|
2023-10-03 01:47:26 +05:30
|
|
|
ongoing_internships = InternshipSerializerForAdmin(ongoing_internships, many=True).data
|
|
|
|
previous_internships = InternshipSerializerForAdmin(previous_internships, many=True).data
|
|
|
|
new_internships = InternshipSerializerForAdmin(new_internships, many=True).data
|
2021-12-03 01:04:49 +05:30
|
|
|
|
|
|
|
return Response(
|
2021-12-17 19:23:32 +05:30
|
|
|
{'action': "Get Dashboard - Admin", 'message': "Data Found", "ongoing": ongoing, "previous": previous,
|
2023-10-03 01:47:26 +05:30
|
|
|
"new": new, "ongoing_internships": ongoing_internships, "previous_internships": previous_internships,
|
|
|
|
"new_internships": new_internships},
|
2021-12-03 01:04:49 +05:30
|
|
|
status=status.HTTP_200_OK)
|
|
|
|
except Http404:
|
|
|
|
return Response({'action': "Get Dashboard - Admin", 'message': 'Student Not Found'},
|
|
|
|
status=status.HTTP_404_NOT_FOUND)
|
|
|
|
except:
|
|
|
|
logger.warning("Get Dashboard - Admin: " + str(sys.exc_info()))
|
|
|
|
return Response({'action': "Get Dashboard - Admin", 'message': "Something went wrong"},
|
|
|
|
status=status.HTTP_400_BAD_REQUEST)
|
|
|
|
|
|
|
|
|
|
|
|
@api_view(['POST'])
|
|
|
|
@isAuthorized([ADMIN])
|
|
|
|
@precheck([OPENING_ID, DEADLINE_DATETIME])
|
|
|
|
def updateDeadline(request, id, email, user_type):
|
|
|
|
try:
|
|
|
|
data = request.data
|
2023-10-03 01:47:26 +05:30
|
|
|
if OPENING_TYPE in data:
|
|
|
|
opening_type= data[OPENING_TYPE]
|
|
|
|
else:
|
|
|
|
opening_type= "Placement"
|
|
|
|
if opening_type == "Internship":
|
|
|
|
opening = get_object_or_404(Internship, pk=data[OPENING_ID])
|
|
|
|
else:
|
|
|
|
opening = get_object_or_404(Placement, pk=data[OPENING_ID])
|
|
|
|
|
2021-12-03 01:04:49 +05:30
|
|
|
# Updating deadline date with correct format in datetime field
|
2021-12-17 19:23:32 +05:30
|
|
|
opening.deadline_datetime = datetime.datetime.strptime(data[DEADLINE_DATETIME], '%Y-%m-%d %H:%M:%S %z')
|
2022-07-21 16:41:31 +05:30
|
|
|
opening.changed_by = get_object_or_404(User, id=id)
|
2021-12-03 01:04:49 +05:30
|
|
|
opening.save()
|
2023-11-30 11:37:12 +05:30
|
|
|
if opening.offer_accepted:
|
|
|
|
send_opening_to_notifications_service(id=opening.id,name=opening.company_name,deadline=data[DEADLINE_DATETIME],role=opening.designation,opening_type=opening_type)
|
2021-12-03 01:04:49 +05:30
|
|
|
return Response({'action': "Update Deadline", 'message': "Deadline Updated"},
|
|
|
|
status=status.HTTP_200_OK)
|
|
|
|
except Http404:
|
|
|
|
return Response({'action': "Update Deadline", 'message': 'Opening Not Found'},
|
|
|
|
status=status.HTTP_404_NOT_FOUND)
|
|
|
|
except:
|
|
|
|
logger.warning("Update Deadline: " + str(sys.exc_info()))
|
|
|
|
return Response({'action': "Update Deadline", 'message': "Something went wrong"},
|
|
|
|
status=status.HTTP_400_BAD_REQUEST)
|
|
|
|
|
2021-12-17 19:23:32 +05:30
|
|
|
|
2021-12-03 01:04:49 +05:30
|
|
|
@api_view(['POST'])
|
2022-09-12 11:24:50 +05:30
|
|
|
@isAuthorized([SUPER_ADMIN])
|
2021-12-03 01:04:49 +05:30
|
|
|
@precheck([OPENING_ID, OFFER_ACCEPTED])
|
|
|
|
def updateOfferAccepted(request, id, email, user_type):
|
|
|
|
try:
|
|
|
|
data = request.data
|
2022-09-12 11:24:50 +05:30
|
|
|
offer_accepted = data[OFFER_ACCEPTED]
|
2023-10-03 01:47:26 +05:30
|
|
|
if OPENING_TYPE in data:
|
|
|
|
opening_type= data[OPENING_TYPE]
|
|
|
|
else:
|
|
|
|
opening_type= "Placement"
|
|
|
|
if opening_type == "Internship":
|
|
|
|
opening = get_object_or_404(Internship, pk=data[OPENING_ID])
|
|
|
|
else:
|
|
|
|
opening = get_object_or_404(Placement, pk=data[OPENING_ID])
|
2022-09-12 11:24:50 +05:30
|
|
|
if opening.offer_accepted is None:
|
|
|
|
opening.offer_accepted = offer_accepted == "true"
|
2022-07-28 18:01:55 +05:30
|
|
|
opening.changed_by = get_object_or_404(User, id=id)
|
|
|
|
opening.save()
|
2022-09-20 15:49:20 +05:30
|
|
|
if opening.offer_accepted:
|
2023-11-30 12:58:07 +05:30
|
|
|
deadline_datetime = datetime.datetime.strftime(opening.deadline_datetime, '%Y-%m-%d %H:%M:%S %z')
|
|
|
|
send_opening_to_notifications_service(id=opening.id,name=opening.company_name,deadline=deadline_datetime,role=opening.designation,opening_type=opening_type)
|
2023-10-03 02:16:33 +05:30
|
|
|
send_opening_notifications(opening.id,opening_type)
|
2022-09-12 11:24:50 +05:30
|
|
|
else:
|
|
|
|
raise ValueError("Offer Status already updated")
|
|
|
|
|
2021-12-03 01:04:49 +05:30
|
|
|
return Response({'action': "Update Offer Accepted", 'message': "Offer Accepted Updated"},
|
|
|
|
status=status.HTTP_200_OK)
|
|
|
|
except Http404:
|
|
|
|
return Response({'action': "Update Offer Accepted", 'message': 'Opening Not Found'},
|
|
|
|
status=status.HTTP_404_NOT_FOUND)
|
2022-09-12 11:24:50 +05:30
|
|
|
except ValueError as e:
|
|
|
|
return Response({'action': "Update Offer Accepted", 'message': str(e)},
|
|
|
|
status=status.HTTP_400_BAD_REQUEST)
|
2021-12-03 01:04:49 +05:30
|
|
|
except:
|
|
|
|
logger.warning("Update Offer Accepted: " + str(sys.exc_info()))
|
|
|
|
return Response({'action': "Update Offer Accepted", 'message': "Something went wrong"},
|
|
|
|
status=status.HTTP_400_BAD_REQUEST)
|
|
|
|
|
2021-12-17 19:23:32 +05:30
|
|
|
|
2021-12-03 01:04:49 +05:30
|
|
|
@api_view(['POST'])
|
|
|
|
@isAuthorized([ADMIN])
|
|
|
|
@precheck([OPENING_ID, EMAIL_VERIFIED])
|
|
|
|
def updateEmailVerified(request, id, email, user_type):
|
|
|
|
try:
|
|
|
|
data = request.data
|
2023-10-03 01:47:26 +05:30
|
|
|
if OPENING_TYPE in data:
|
|
|
|
opening_type= data[OPENING_TYPE]
|
|
|
|
else:
|
|
|
|
opening_type= "Placement"
|
|
|
|
if opening_type == "Internship":
|
|
|
|
opening = get_object_or_404(Internship, pk=data[OPENING_ID])
|
|
|
|
else:
|
|
|
|
opening = get_object_or_404(Placement, pk=data[OPENING_ID])
|
2021-12-03 01:04:49 +05:30
|
|
|
opening.email_verified = True if data[EMAIL_VERIFIED] == "true" else False
|
2022-07-21 16:41:31 +05:30
|
|
|
opening.changed_by = get_object_or_404(User, id=id)
|
2021-12-03 01:04:49 +05:30
|
|
|
opening.save()
|
|
|
|
return Response({'action': "Update Email Verified", 'message': "Email Verified Updated"},
|
|
|
|
status=status.HTTP_200_OK)
|
|
|
|
except Http404:
|
|
|
|
return Response({'action': "Update Email Verified", 'message': 'Opening Not Found'},
|
|
|
|
status=status.HTTP_404_NOT_FOUND)
|
|
|
|
except:
|
|
|
|
logger.warning("Update Email Verified: " + str(sys.exc_info()))
|
|
|
|
return Response({'action': "Update Email Verified", 'message': "Something went wrong"},
|
|
|
|
status=status.HTTP_400_BAD_REQUEST)
|
|
|
|
|
2021-12-17 19:23:32 +05:30
|
|
|
|
2021-12-03 01:04:49 +05:30
|
|
|
@api_view(['POST'])
|
|
|
|
@isAuthorized([ADMIN])
|
2022-06-06 11:07:41 +05:30
|
|
|
@precheck([OPENING_ID, FIELD])
|
|
|
|
def deleteAdditionalInfo(request, id, email, user_type):
|
2021-12-03 01:04:49 +05:30
|
|
|
try:
|
|
|
|
data = request.data
|
2023-10-03 01:47:26 +05:30
|
|
|
if OPENING_TYPE in data:
|
|
|
|
opening_type= data[OPENING_TYPE]
|
|
|
|
else:
|
|
|
|
opening_type= "Placement"
|
|
|
|
if opening_type == "Internship":
|
|
|
|
opening = get_object_or_404(Internship, pk=data[OPENING_ID])
|
|
|
|
else:
|
|
|
|
opening = get_object_or_404(Placement, pk=data[OPENING_ID])
|
2022-06-06 11:07:41 +05:30
|
|
|
if data[FIELD] in opening.additional_info:
|
|
|
|
opening.additional_info.remove(data[FIELD])
|
2022-07-21 16:41:31 +05:30
|
|
|
opening.changed_by = get_object_or_404(User, id=id)
|
2022-06-06 11:07:41 +05:30
|
|
|
opening.save()
|
|
|
|
return Response({'action': "Delete Additional Info", 'message': "Additional Info Deleted"},
|
|
|
|
status=status.HTTP_200_OK)
|
2021-12-03 01:04:49 +05:30
|
|
|
else:
|
2022-06-06 11:07:41 +05:30
|
|
|
raise ValueError("Additional Info Not Found")
|
2021-12-03 01:04:49 +05:30
|
|
|
except Http404:
|
2022-06-06 11:55:56 +05:30
|
|
|
return Response({'action': "Delete Additional Info", 'message': 'Opening Not Found'},
|
2021-12-03 01:04:49 +05:30
|
|
|
status=status.HTTP_404_NOT_FOUND)
|
|
|
|
except ValueError:
|
2022-06-06 11:55:56 +05:30
|
|
|
return Response({'action': "Delete Additional Info", 'message': "Additional Info not found"},
|
|
|
|
status=status.HTTP_404_NOT_FOUND)
|
|
|
|
except Exception as e:
|
|
|
|
logger.warning("Delete Additional Info: " + str(e))
|
|
|
|
return Response({'action': "Delete Additional Info", 'message': "Something went wrong"},
|
|
|
|
status=status.HTTP_400_BAD_REQUEST)
|
|
|
|
|
2022-07-28 18:01:55 +05:30
|
|
|
|
2022-06-06 11:55:56 +05:30
|
|
|
@api_view(['POST'])
|
|
|
|
@isAuthorized([ADMIN])
|
|
|
|
@precheck([OPENING_ID, FIELD])
|
|
|
|
def addAdditionalInfo(request, id, email, user_type):
|
|
|
|
try:
|
|
|
|
data = request.data
|
2023-10-03 01:47:26 +05:30
|
|
|
if OPENING_TYPE in data:
|
|
|
|
opening_type= data[OPENING_TYPE]
|
|
|
|
else:
|
|
|
|
opening_type= "Placement"
|
|
|
|
if opening_type == "Internship":
|
|
|
|
opening = get_object_or_404(Internship, pk=data[OPENING_ID])
|
|
|
|
else:
|
|
|
|
opening = get_object_or_404(Placement, pk=data[OPENING_ID])
|
2022-06-06 11:55:56 +05:30
|
|
|
if data[FIELD] not in opening.additional_info:
|
|
|
|
opening.additional_info.append(data[FIELD])
|
|
|
|
opening.save()
|
|
|
|
return Response({'action': "Add Additional Info", 'message': "Additional Info Added"},
|
|
|
|
status=status.HTTP_200_OK)
|
|
|
|
else:
|
|
|
|
raise ValueError("Additional Info Found")
|
2022-07-21 16:41:31 +05:30
|
|
|
|
2022-06-06 11:55:56 +05:30
|
|
|
except Http404:
|
|
|
|
return Response({'action': "Add Additional Info", 'message': 'Opening Not Found'},
|
|
|
|
status=status.HTTP_404_NOT_FOUND)
|
|
|
|
except ValueError:
|
|
|
|
return Response({'action': "Add Additional Info", 'message': "Additional Info already found"},
|
2021-12-03 01:04:49 +05:30
|
|
|
status=status.HTTP_400_BAD_REQUEST)
|
2022-05-19 19:10:58 +05:30
|
|
|
except Exception as e:
|
2022-06-06 11:55:56 +05:30
|
|
|
logger.warning("Add Additional Info: " + str(e))
|
|
|
|
return Response({'action': "Add Additional Info", 'message': "Something went wrong"},
|
2021-12-12 19:14:27 +05:30
|
|
|
status=status.HTTP_400_BAD_REQUEST)
|
|
|
|
|
|
|
|
|
|
|
|
@api_view(['GET'])
|
|
|
|
@isAuthorized([ADMIN])
|
|
|
|
@precheck([OPENING_ID])
|
|
|
|
def getApplications(request, id, email, user_type):
|
|
|
|
try:
|
|
|
|
data = request.GET
|
2023-10-03 01:47:26 +05:30
|
|
|
if OPENING_TYPE in data:
|
|
|
|
opening_type= data[OPENING_TYPE]
|
|
|
|
else:
|
|
|
|
opening_type= "Placement"
|
|
|
|
if opening_type == "Internship":
|
|
|
|
opening = get_object_or_404(Internship, pk=data[OPENING_ID])
|
|
|
|
applications = InternshipApplication.objects.filter(internship=opening)
|
|
|
|
serializer = InternshipApplicationSerializerForAdmin(applications, many=True)
|
|
|
|
else:
|
|
|
|
opening = get_object_or_404(Placement, pk=data[OPENING_ID])
|
|
|
|
applications = PlacementApplication.objects.filter(placement=opening)
|
|
|
|
serializer = PlacementApplicationSerializerForAdmin(applications, many=True)
|
2021-12-17 19:23:32 +05:30
|
|
|
return Response({'action': "Get Applications", 'message': 'Data Found', 'applications': serializer.data},
|
2023-10-03 01:47:26 +05:30
|
|
|
status=status.HTTP_200_OK)
|
2021-12-12 19:14:27 +05:30
|
|
|
except Http404:
|
|
|
|
return Response({'action': "Get Applications", 'message': 'Opening Not Found'},
|
|
|
|
status=status.HTTP_404_NOT_FOUND)
|
|
|
|
except:
|
|
|
|
logger.warning("Get Applications: " + str(sys.exc_info()))
|
|
|
|
return Response({'action': "Get Applications", 'message': "Something went wrong"},
|
|
|
|
status=status.HTTP_400_BAD_REQUEST)
|
|
|
|
|
|
|
|
|
|
|
|
@api_view(['POST'])
|
|
|
|
@isAuthorized(allowed_users=[ADMIN])
|
2022-05-24 15:07:32 +05:30
|
|
|
@precheck(required_data=[APPLICATION_ID, STUDENT_ID, OPENING_ID, ADDITIONAL_INFO, RESUME_FILE_NAME])
|
2021-12-12 19:14:27 +05:30
|
|
|
def submitApplication(request, id, email, user_type):
|
|
|
|
try:
|
|
|
|
data = request.data
|
2023-10-03 02:35:33 +05:30
|
|
|
if OPENING_TYPE in data:
|
2024-10-24 20:10:02 +05:30
|
|
|
if data[OPENING_TYPE] == "Internship":
|
|
|
|
opening_type= "Internship"
|
|
|
|
elif data[OPENING_TYPE] == "placements":
|
|
|
|
opening_type= "Placement"
|
2023-10-03 01:47:26 +05:30
|
|
|
else:
|
|
|
|
opening_type= "Placement"
|
|
|
|
if opening_type == "Internship":
|
|
|
|
opening = get_object_or_404(Internship, pk=data[OPENING_ID])
|
2023-10-03 02:35:33 +05:30
|
|
|
else:
|
|
|
|
opening = get_object_or_404(Placement, pk=data[OPENING_ID])
|
2024-10-24 20:10:02 +05:30
|
|
|
# print(opening);
|
2023-10-03 02:35:33 +05:30
|
|
|
student = get_object_or_404(Student, pk=data[STUDENT_ID])
|
|
|
|
# opening = get_object_or_404(Placement, pk=data[OPENING_ID])
|
|
|
|
student_user = get_object_or_404(User, id=student.id)
|
|
|
|
if data[APPLICATION_ID] == "":
|
|
|
|
application = PlacementApplication() if opening_type == "Placement" else InternshipApplication()
|
|
|
|
application.id = generateRandomString()
|
|
|
|
if(opening_type == "Placement"):
|
|
|
|
application.placement = opening
|
|
|
|
else:
|
2023-10-03 01:47:26 +05:30
|
|
|
application.internship = opening
|
2023-10-03 02:35:33 +05:30
|
|
|
application.student = student
|
|
|
|
if data[RESUME_FILE_NAME] in student.resumes:
|
|
|
|
application.resume = data[RESUME_FILE_NAME]
|
2023-10-03 01:47:26 +05:30
|
|
|
else:
|
2023-10-03 02:35:33 +05:30
|
|
|
raise FileNotFoundError(RESUME_FILE_NAME + " Not Found")
|
|
|
|
additional_info = {}
|
|
|
|
for i in opening.additional_info:
|
|
|
|
if i not in data[ADDITIONAL_INFO]:
|
|
|
|
raise AttributeError(i + " not found in Additional Info")
|
2023-10-03 01:47:26 +05:30
|
|
|
else:
|
2023-10-03 02:35:33 +05:30
|
|
|
additional_info[i] = data[ADDITIONAL_INFO][i]
|
|
|
|
application.additional_info = json.dumps(additional_info)
|
|
|
|
data = {
|
|
|
|
"name": student.name,
|
|
|
|
"company_name": opening.company_name,
|
|
|
|
"application_type": "Placement" if opening_type == "Placement" else "Internship",
|
|
|
|
"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(student_user.email, subject, data, STUDENT_APPLICATION_SUBMITTED_TEMPLATE)
|
|
|
|
return Response({'action': "Add Student Application", 'message': "Application added"},
|
|
|
|
status=status.HTTP_200_OK)
|
2021-12-12 19:14:27 +05:30
|
|
|
else:
|
2023-10-03 02:35:33 +05:30
|
|
|
if opening_type == "Internship":
|
|
|
|
application = get_object_or_404(InternshipApplication, id=data[APPLICATION_ID])
|
|
|
|
else:
|
|
|
|
application = get_object_or_404(PlacementApplication, id=data[APPLICATION_ID])
|
|
|
|
if application:
|
2022-05-24 15:07:32 +05:30
|
|
|
if data[RESUME_FILE_NAME] in student.resumes:
|
|
|
|
application.resume = data[RESUME_FILE_NAME]
|
|
|
|
else:
|
|
|
|
raise FileNotFoundError(RESUME_FILE_NAME + " Not Found")
|
2023-10-03 02:35:33 +05:30
|
|
|
application.resume = data[RESUME_FILE_NAME]
|
2022-05-24 15:07:32 +05:30
|
|
|
additional_info = {}
|
|
|
|
for i in opening.additional_info:
|
|
|
|
if i not in data[ADDITIONAL_INFO]:
|
|
|
|
raise AttributeError(i + " not found in Additional Info")
|
|
|
|
else:
|
|
|
|
additional_info[i] = data[ADDITIONAL_INFO][i]
|
2023-10-03 02:35:33 +05:30
|
|
|
|
2022-05-24 15:07:32 +05:30
|
|
|
application.additional_info = json.dumps(additional_info)
|
2022-07-28 14:37:41 +05:30
|
|
|
data = {
|
|
|
|
"name": student.name,
|
|
|
|
"company_name": opening.company_name,
|
2023-10-03 02:35:33 +05:30
|
|
|
"application_type": "Placement" if opening_type == "Placement" else "Internship",
|
|
|
|
"resume": application.resume[16:],
|
|
|
|
"additional_info_items": dict(json.loads(application.additional_info)),
|
2022-07-28 14:37:41 +05:30
|
|
|
}
|
2023-10-03 02:35:33 +05:30
|
|
|
subject = STUDENT_APPLICATION_UPDATED_TEMPLATE_SUBJECT.format(company_name=opening.company_name)
|
2022-07-21 16:41:31 +05:30
|
|
|
application.changed_by = get_object_or_404(User, id=id)
|
2022-05-24 15:07:32 +05:30
|
|
|
application.save()
|
2023-10-03 02:35:33 +05:30
|
|
|
sendEmail(student_user.email, subject, data, STUDENT_APPLICATION_UPDATED_TEMPLATE)
|
|
|
|
return Response({'action': "Add Student Application", 'message': "Application updated"},
|
2023-10-03 01:47:26 +05:30
|
|
|
status=status.HTTP_200_OK)
|
2023-10-03 02:35:33 +05:30
|
|
|
else:
|
|
|
|
return Response({'action': "Edit Student Application", 'message': "No Application Found"},
|
2022-05-24 15:07:32 +05:30
|
|
|
status=status.HTTP_400_BAD_REQUEST)
|
2021-12-12 19:14:27 +05:30
|
|
|
|
|
|
|
except Http404 as e:
|
|
|
|
return Response({'action': "Submit Application", 'message': str(e)},
|
|
|
|
status=status.HTTP_404_NOT_FOUND)
|
|
|
|
except PermissionError as e:
|
|
|
|
return Response({'action': "Submit Application", 'message': str(e)},
|
|
|
|
status=status.HTTP_403_FORBIDDEN)
|
|
|
|
except FileNotFoundError as e:
|
|
|
|
return Response({'action': "Submit Application", 'message': str(e)},
|
|
|
|
status=status.HTTP_404_NOT_FOUND)
|
2023-10-07 02:43:42 +05:30
|
|
|
except AttributeError as e:
|
|
|
|
return Response({'action': "Submit Application", 'message': str(e)},
|
|
|
|
status=status.HTTP_400_BAD_REQUEST)
|
2021-12-12 19:14:27 +05:30
|
|
|
except:
|
|
|
|
logger.warning("Submit Application: " + str(sys.exc_info()))
|
|
|
|
return Response({'action': "Submit Application", 'message': "Something Went Wrong"},
|
|
|
|
status=status.HTTP_400_BAD_REQUEST)
|
|
|
|
|
|
|
|
@api_view(['POST'])
|
|
|
|
@isAuthorized(allowed_users=[ADMIN])
|
|
|
|
@precheck(required_data=[OPENING_ID])
|
|
|
|
def generateCSV(request, id, email, user_type):
|
|
|
|
try:
|
|
|
|
data = request.data
|
2023-10-03 01:47:26 +05:30
|
|
|
if OPENING_TYPE in data:
|
|
|
|
opening_type= data[OPENING_TYPE]
|
|
|
|
else:
|
|
|
|
opening_type= "Placement"
|
|
|
|
if opening_type == "Internship":
|
|
|
|
opening = get_object_or_404(Internship, id=data[OPENING_ID])
|
|
|
|
applications = InternshipApplication.objects.filter(internship=opening)
|
|
|
|
else:
|
|
|
|
opening = get_object_or_404(Placement, id=data[OPENING_ID])
|
|
|
|
applications = PlacementApplication.objects.filter(placement=opening)
|
2021-12-12 19:14:27 +05:30
|
|
|
filename = generateRandomString()
|
|
|
|
if not os.path.isdir(STORAGE_DESTINATION_APPLICATION_CSV):
|
2023-10-11 06:29:44 +05:30
|
|
|
os.makedirs(STORAGE_DESTINATION_APPLICATION_CSV, exist_ok=True)
|
2021-12-12 19:14:27 +05:30
|
|
|
destination_path = STORAGE_DESTINATION_APPLICATION_CSV + filename + ".csv"
|
|
|
|
f = open(destination_path, 'w')
|
|
|
|
writer = csv.writer(f)
|
|
|
|
header_row = APPLICATION_CSV_COL_NAMES.copy()
|
|
|
|
|
2023-10-03 01:47:26 +05:30
|
|
|
header_row.extend(opening.additional_info)
|
2021-12-12 19:14:27 +05:30
|
|
|
writer.writerow(header_row)
|
|
|
|
for apl in applications:
|
2021-12-17 19:23:32 +05:30
|
|
|
row_details = []
|
2021-12-12 19:14:27 +05:30
|
|
|
|
|
|
|
row_details.append(apl.applied_at)
|
|
|
|
row_details.append(apl.student.roll_no)
|
|
|
|
row_details.append(apl.student.name)
|
2021-12-17 19:23:32 +05:30
|
|
|
row_details.append(str(apl.student.roll_no) + "@iitdh.ac.in")
|
2021-12-12 19:14:27 +05:30
|
|
|
row_details.append(apl.student.phone_number)
|
|
|
|
row_details.append(apl.student.branch)
|
|
|
|
row_details.append(apl.student.batch)
|
|
|
|
row_details.append(apl.student.cpi)
|
2023-10-07 02:43:42 +05:30
|
|
|
link = LINK_TO_STORAGE_RESUME + urllib.parse.quote(str(apl.student.id)) + "/" + urllib.parse.quote(str(apl.resume))
|
2021-12-12 19:14:27 +05:30
|
|
|
row_details.append(link)
|
|
|
|
row_details.append(apl.selected)
|
|
|
|
|
2023-10-03 01:47:26 +05:30
|
|
|
for i in opening.additional_info:
|
2021-12-12 19:14:27 +05:30
|
|
|
row_details.append(json.loads(apl.additional_info)[i])
|
|
|
|
|
|
|
|
writer.writerow(row_details)
|
|
|
|
f.close()
|
2021-12-17 19:23:32 +05:30
|
|
|
file_path = LINK_TO_APPLICATIONS_CSV + urllib.parse.quote_plus(filename + ".csv")
|
2021-12-12 19:14:27 +05:30
|
|
|
return Response({'action': "Create csv", 'message': "CSV created", 'file': file_path},
|
|
|
|
status=status.HTTP_200_OK)
|
2024-06-19 22:22:41 +05:30
|
|
|
except:
|
|
|
|
logger.warning("Create csv: " + str(sys.exc_info()))
|
|
|
|
return Response({'action': "Create csv", 'message': "Something Went Wrong"},
|
|
|
|
status=status.HTTP_400_BAD_REQUEST)
|
|
|
|
|
|
|
|
|
|
|
|
@api_view(['POST'])
|
|
|
|
@isAuthorized(allowed_users=[ADMIN])
|
|
|
|
@precheck(required_data=[OPENING_ID])
|
|
|
|
def downloadResume(request, id, email, user_type):
|
|
|
|
try:
|
|
|
|
data = request.data
|
|
|
|
if OPENING_TYPE in data:
|
|
|
|
opening_type= data[OPENING_TYPE]
|
2024-09-06 18:58:02 +05:30
|
|
|
|
2024-06-19 22:22:41 +05:30
|
|
|
if opening_type == "Internship":
|
|
|
|
opening = get_object_or_404(Internship, id=data[OPENING_ID])
|
|
|
|
applications = InternshipApplication.objects.filter(internship=opening)
|
|
|
|
else:
|
|
|
|
opening = get_object_or_404(Placement, id=data[OPENING_ID])
|
|
|
|
applications = PlacementApplication.objects.filter(placement=opening)
|
|
|
|
zip_filename = generateRandomString() + ".zip"
|
|
|
|
if not os.path.isdir(STORAGE_DESTINATION_RESUME_ZIP):
|
|
|
|
os.makedirs(STORAGE_DESTINATION_RESUME_ZIP, exist_ok=True)
|
|
|
|
resumes = {}
|
2024-09-05 15:21:05 +05:30
|
|
|
for apl in applications:
|
|
|
|
|
|
|
|
resumes[apl.student.roll_no] = STORAGE_DESTINATION_RESUMES + apl.student.id + '/' + apl.resume # Check if the folder name is student id or user id
|
2024-06-19 22:22:41 +05:30
|
|
|
|
|
|
|
with zipfile.ZipFile(STORAGE_DESTINATION_RESUME_ZIP + zip_filename, 'w', zipfile.ZIP_DEFLATED) as zip_file:
|
|
|
|
for student_roll_no, resume_path in resumes.items():
|
|
|
|
zip_file.write(resume_path, os.path.basename(str(student_roll_no) + ".pdf"))
|
|
|
|
|
|
|
|
file_path = LINK_TO_RESUMES_ZIP + urllib.parse.quote_plus(zip_filename)
|
|
|
|
return Response({'action': "Download resumes", 'message': "Resumes zip created", 'file': file_path},
|
|
|
|
status=status.HTTP_200_OK)
|
2021-12-12 19:14:27 +05:30
|
|
|
except:
|
|
|
|
logger.warning("Create csv: " + str(sys.exc_info()))
|
2023-10-11 07:18:28 +05:30
|
|
|
return Response({'action': "Create csv", 'message': "Something Went Wrong"},
|
2021-12-17 19:23:32 +05:30
|
|
|
status=status.HTTP_400_BAD_REQUEST)
|
2022-05-01 22:51:14 +05:30
|
|
|
|
2022-05-02 17:16:56 +05:30
|
|
|
|
2022-05-01 22:51:14 +05:30
|
|
|
@api_view(['POST'])
|
|
|
|
@isAuthorized(allowed_users=[ADMIN])
|
|
|
|
@precheck(required_data=[COMPANY_NAME, COMPENSATION_GROSS, OFFER_ACCEPTED, STUDENT_ID, DESIGNATION, TIER])
|
|
|
|
def addPPO(request, id, email, user_type):
|
|
|
|
try:
|
|
|
|
data = request.data
|
|
|
|
PPO = PrePlacementOffer()
|
|
|
|
PPO.company = data[COMPANY_NAME]
|
2022-09-20 01:34:27 +05:30
|
|
|
PPO.compensation = int(data[COMPENSATION_GROSS])
|
2022-05-01 22:51:14 +05:30
|
|
|
if data[OFFER_ACCEPTED] == "true":
|
|
|
|
PPO.accepted = True
|
|
|
|
elif data[OFFER_ACCEPTED] == "false":
|
|
|
|
PPO.accepted = False
|
|
|
|
else:
|
|
|
|
PPO.accepted = None
|
|
|
|
PPO.student = get_object_or_404(Student, id=data[STUDENT_ID])
|
|
|
|
PPO.designation = data[DESIGNATION]
|
2022-09-20 01:34:27 +05:30
|
|
|
PPO.tier = int(data[TIER])
|
2022-05-01 22:51:14 +05:30
|
|
|
if COMPENSATION_DETAILS in data:
|
|
|
|
PPO.compensation_details = data[COMPENSATION_DETAILS]
|
2022-07-21 16:41:31 +05:30
|
|
|
PPO.changed_by = get_object_or_404(User, id=id)
|
2022-05-01 22:51:14 +05:30
|
|
|
PPO.save()
|
|
|
|
return Response({'action': "Add PPO", 'message': "PPO added"},
|
|
|
|
status=status.HTTP_200_OK)
|
|
|
|
except:
|
|
|
|
logger.warning("Add PPO: " + str(sys.exc_info()))
|
2022-05-24 15:07:32 +05:30
|
|
|
return Response({'action': "Add PPO", 'message': "Something Went Wrong"},
|
2022-05-01 22:51:14 +05:30
|
|
|
status=status.HTTP_400_BAD_REQUEST)
|
2022-05-24 15:07:32 +05:30
|
|
|
|
|
|
|
|
|
|
|
@api_view(['POST'])
|
|
|
|
@isAuthorized(allowed_users=[ADMIN])
|
|
|
|
@precheck(required_data=[STUDENT_ID, OPENING_ID])
|
|
|
|
def getStudentApplication(request, id, email, user_type):
|
|
|
|
try:
|
|
|
|
data = request.data
|
2023-10-03 01:47:26 +05:30
|
|
|
if OPENING_TYPE in data:
|
|
|
|
opening_type= data[OPENING_TYPE]
|
|
|
|
else:
|
|
|
|
opening_type= "Placement"
|
2022-05-24 15:07:32 +05:30
|
|
|
student = get_object_or_404(Student, id=data[STUDENT_ID])
|
|
|
|
student_serializer = StudentSerializer(student)
|
|
|
|
student_details = {
|
|
|
|
"name": student_serializer.data['name'],
|
|
|
|
"batch": student.batch,
|
|
|
|
"branch": student.branch,
|
|
|
|
"resume_list": student_serializer.data['resume_list'],
|
|
|
|
}
|
|
|
|
# search for the application if there or not
|
2023-10-03 01:47:26 +05:30
|
|
|
if opening_type == "Internship":
|
|
|
|
application = InternshipApplication.objects.filter(student=student,
|
|
|
|
internship=get_object_or_404(Internship,
|
|
|
|
id=data[OPENING_ID]))
|
|
|
|
else:
|
|
|
|
application = PlacementApplication.objects.filter(student=student,
|
2022-05-24 15:07:32 +05:30
|
|
|
placement=get_object_or_404(Placement, id=data[OPENING_ID]))
|
2023-10-03 01:47:26 +05:30
|
|
|
|
2022-05-24 15:07:32 +05:30
|
|
|
if application:
|
2023-10-03 01:47:26 +05:30
|
|
|
if opening_type == "Internship":
|
|
|
|
serializer = InternshipApplicationSerializer(application[0])
|
|
|
|
application_info = {
|
|
|
|
"id": serializer.data['id'],
|
|
|
|
"additional_info": serializer.data['additional_info'],
|
|
|
|
"resume": serializer.data['resume_link'],
|
|
|
|
}
|
|
|
|
else:
|
|
|
|
serializer = PlacementApplicationSerializer(application[0])
|
|
|
|
application_info = {
|
|
|
|
"id": serializer.data['id'],
|
|
|
|
"additional_info": serializer.data['additional_info'],
|
|
|
|
"resume": serializer.data['resume_link'],
|
|
|
|
}
|
2022-05-24 15:07:32 +05:30
|
|
|
return Response(
|
|
|
|
{'action': "Get Student Application", 'application_found': "true", "application_info": application_info,
|
|
|
|
"student_details": student_details}, status=status.HTTP_200_OK)
|
|
|
|
else:
|
|
|
|
return Response(
|
|
|
|
{'action': "Get Student Application", 'application_found': "false", "student_details": student_details},
|
|
|
|
status=status.HTTP_404_NOT_FOUND)
|
|
|
|
except Http404:
|
|
|
|
return Response({'action': "Get Student Application", 'message': "Student not found."},
|
|
|
|
status.HTTP_404_NOT_FOUND)
|
|
|
|
except:
|
|
|
|
logger.warning("Get Student Application: " + str(sys.exc_info()))
|
|
|
|
return Response({'action': "Get Student Application", 'message': "Something Went Wrong"},
|
|
|
|
status.HTTP_400_BAD_REQUEST)
|
2022-11-08 21:57:51 +05:30
|
|
|
|
|
|
|
@api_view(['GET'])
|
|
|
|
@isAuthorized(allowed_users=[ADMIN])
|
|
|
|
def getStats(request, id, email, user_type):
|
|
|
|
try:
|
|
|
|
stats = []
|
|
|
|
placement_ids = {}
|
|
|
|
|
|
|
|
tier_count = {
|
|
|
|
"CSE": {
|
|
|
|
"1":0,
|
|
|
|
"2":0,
|
|
|
|
"3":0,
|
|
|
|
"4":0,
|
|
|
|
"5":0,
|
|
|
|
"6":0,
|
|
|
|
"7":0,
|
2023-10-19 03:09:01 +05:30
|
|
|
"8":0,
|
2022-11-08 21:57:51 +05:30
|
|
|
"psu":0,
|
|
|
|
},
|
|
|
|
"EE": {
|
|
|
|
"1":0,
|
|
|
|
"2":0,
|
|
|
|
"3":0,
|
|
|
|
"4":0,
|
|
|
|
"5":0,
|
|
|
|
"6":0,
|
|
|
|
"7":0,
|
|
|
|
"psu":0,
|
|
|
|
},
|
|
|
|
"MMAE": {
|
|
|
|
"1":0,
|
|
|
|
"2":0,
|
|
|
|
"3":0,
|
|
|
|
"4":0,
|
|
|
|
"5":0,
|
|
|
|
"6":0,
|
|
|
|
"7":0,
|
2023-10-19 03:09:01 +05:30
|
|
|
"8":0,
|
2022-11-08 21:57:51 +05:30
|
|
|
"psu":0,
|
|
|
|
|
|
|
|
},
|
2024-09-26 12:18:55 +05:30
|
|
|
"EP":{
|
|
|
|
"1":0,
|
|
|
|
"2":0,
|
|
|
|
"3":0,
|
|
|
|
"4":0,
|
|
|
|
"5":0,
|
|
|
|
"6":0,
|
|
|
|
"7":0,
|
|
|
|
"8":0,
|
|
|
|
"psu":0,
|
|
|
|
},
|
2022-11-08 21:57:51 +05:30
|
|
|
"Total": {
|
|
|
|
"1":0,
|
|
|
|
"2":0,
|
|
|
|
"3":0,
|
|
|
|
"4":0,
|
|
|
|
"5":0,
|
|
|
|
"6":0,
|
|
|
|
"7":0,
|
2023-10-19 03:09:01 +05:30
|
|
|
"8":0,
|
2022-11-08 21:57:51 +05:30
|
|
|
"psu":0,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
number_of_students_placed = {
|
|
|
|
"CSE": 0,
|
|
|
|
"EE": 0,
|
|
|
|
"MMAE": 0,
|
2024-09-26 12:18:55 +05:30
|
|
|
"EP": 0,
|
2022-11-08 21:57:51 +05:30
|
|
|
"Total": 0,
|
|
|
|
}
|
|
|
|
number_of_students_with_multiple_offers = 0
|
|
|
|
number_of_students_with_no_offers = {
|
|
|
|
"CSE": 0,
|
|
|
|
"EE": 0,
|
|
|
|
"MMAE": 0,
|
2024-09-26 12:18:55 +05:30
|
|
|
"EP": 0,
|
2022-11-08 21:57:51 +05:30
|
|
|
"Total": 0,
|
|
|
|
}
|
|
|
|
max_CTC = {
|
|
|
|
"CSE": 0,
|
|
|
|
"EE": 0,
|
2024-09-26 12:18:55 +05:30
|
|
|
"MMAE": 0,
|
|
|
|
"EP": 0,
|
2022-11-08 21:57:51 +05:30
|
|
|
}
|
|
|
|
average_CTC = {
|
|
|
|
"CSE": 0,
|
|
|
|
"EE": 0,
|
2024-09-26 12:18:55 +05:30
|
|
|
"MMAE": 0,
|
|
|
|
"EP": 0,
|
2022-11-08 21:57:51 +05:30
|
|
|
}
|
|
|
|
count = {
|
|
|
|
"CSE": 0,
|
|
|
|
"EE": 0,
|
2024-09-26 12:18:55 +05:30
|
|
|
"MMAE": 0,
|
|
|
|
"EP": 0,
|
2022-11-08 21:57:51 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-12-06 16:22:27 +05:30
|
|
|
students = Student.objects.all().order_by("roll_no")
|
2022-11-08 21:57:51 +05:30
|
|
|
for student in students.iterator():
|
|
|
|
|
|
|
|
applications = PlacementApplication.objects.filter(student=student, selected=True)
|
|
|
|
ppos = PrePlacementOffer.objects.filter(student=student, accepted=True)
|
|
|
|
|
|
|
|
first_offer_data = None
|
|
|
|
|
|
|
|
second_offer_data = None
|
|
|
|
|
|
|
|
# get the first and second offer
|
|
|
|
offers = []
|
|
|
|
offers.extend(applications)
|
|
|
|
offers.extend(ppos)
|
|
|
|
|
|
|
|
if len(offers) == 0:
|
|
|
|
number_of_students_with_no_offers[student.branch] += 1
|
|
|
|
number_of_students_with_no_offers["Total"] += 1
|
|
|
|
else:
|
|
|
|
number_of_students_placed[student.branch] += 1
|
|
|
|
number_of_students_placed["Total"] += 1
|
|
|
|
if len(offers) > 1:
|
|
|
|
number_of_students_with_multiple_offers += 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for offer in offers:
|
|
|
|
if type(offer) == PrePlacementOffer:
|
|
|
|
if first_offer_data is None:
|
|
|
|
first_offer_data = {
|
|
|
|
"id": offer.id,
|
|
|
|
"company": offer.company,
|
|
|
|
"compensation": offer.compensation,
|
|
|
|
"tier": offer.tier,
|
|
|
|
"type": "PPO",
|
|
|
|
}
|
|
|
|
elif second_offer_data is None:
|
|
|
|
second_offer_data = {
|
|
|
|
"id": offer.id,
|
|
|
|
"company": offer.company,
|
|
|
|
"compensation": offer.compensation,
|
|
|
|
"tier": offer.tier,
|
|
|
|
"type": "PPO",
|
|
|
|
}
|
|
|
|
elif type(offer) == PlacementApplication:
|
|
|
|
if first_offer_data is None:
|
|
|
|
first_offer_data = {
|
|
|
|
"id": offer.placement.id,
|
|
|
|
"company": offer.placement.company_name,
|
|
|
|
"compensation": offer.placement.compensation_CTC,
|
|
|
|
"tier": offer.placement.tier,
|
|
|
|
"type": "Placement",
|
|
|
|
}
|
|
|
|
elif second_offer_data is None:
|
|
|
|
second_offer_data = {
|
|
|
|
"id": offer.placement.id,
|
|
|
|
"company": offer.placement.company_name,
|
|
|
|
"compensation": offer.placement.compensation_CTC,
|
|
|
|
"tier": offer.placement.tier,
|
|
|
|
"type": "Placement",
|
|
|
|
}
|
|
|
|
|
|
|
|
data = {
|
|
|
|
"id": student.id,
|
|
|
|
"name": student.name,
|
|
|
|
"roll_no": student.roll_no,
|
|
|
|
"batch": student.batch,
|
|
|
|
"branch": student.branch,
|
|
|
|
"cpi": student.cpi,
|
|
|
|
"first_offer": first_offer_data['company'] if first_offer_data is not None else None,
|
|
|
|
"first_offer_tier": first_offer_data['tier'] if first_offer_data is not None else None,
|
|
|
|
"first_offer_compensation": first_offer_data['compensation'] if first_offer_data is not None else None,
|
|
|
|
|
|
|
|
"second_offer": second_offer_data['company'] if second_offer_data is not None else None,
|
|
|
|
"second_offer_tier": second_offer_data['tier'] if second_offer_data is not None else None,
|
|
|
|
"second_offer_compensation": second_offer_data['compensation'] if second_offer_data is not None else None,
|
|
|
|
}
|
|
|
|
if first_offer_data is not None:
|
|
|
|
tier_count[student.branch][first_offer_data['tier']] += 1
|
|
|
|
tier_count['Total'][first_offer_data['tier']] += 1
|
|
|
|
max_CTC[student.branch] = max(max_CTC[student.branch], first_offer_data['compensation'])
|
|
|
|
average_CTC[student.branch] += first_offer_data['compensation']
|
|
|
|
count[student.branch] += 1
|
|
|
|
|
|
|
|
if first_offer_data['type'] == "Placement":
|
|
|
|
placement_ids[first_offer_data['company']] = first_offer_data['id']
|
|
|
|
|
|
|
|
if second_offer_data is not None:
|
|
|
|
tier_count[student.branch][second_offer_data['tier']] += 1
|
|
|
|
tier_count['Total'][second_offer_data['tier']] += 1
|
|
|
|
max_CTC[student.branch] = max(max_CTC[student.branch], second_offer_data['compensation'])
|
|
|
|
average_CTC[student.branch] += second_offer_data['compensation']
|
|
|
|
count[student.branch] += 1
|
|
|
|
|
|
|
|
if second_offer_data['type'] == "Placement":
|
|
|
|
placement_ids[second_offer_data['company']] = second_offer_data['id']
|
|
|
|
|
|
|
|
stats.append(data)
|
|
|
|
|
|
|
|
for branch in average_CTC:
|
|
|
|
if count[branch] > 0:
|
|
|
|
average_CTC[branch] /= count[branch]
|
|
|
|
# round off to 2 decimal places
|
|
|
|
average_CTC[branch] = round(average_CTC[branch], 2)
|
|
|
|
else:
|
|
|
|
average_CTC[branch] = 0
|
|
|
|
return Response({'action': "Get Stats", 'message': "Stats fetched", 'stats': stats, 'placement_ids': placement_ids,
|
|
|
|
"tier_count": {br: tier_count[br].values() for br in tier_count},
|
|
|
|
"number_of_students_placed": number_of_students_placed,
|
|
|
|
"number_of_students_with_multiple_offers": number_of_students_with_multiple_offers,
|
|
|
|
"number_of_students_with_no_offers": number_of_students_with_no_offers,
|
|
|
|
"max_CTC": max_CTC,
|
|
|
|
"average_CTC": average_CTC,
|
|
|
|
},
|
|
|
|
status=status.HTTP_200_OK)
|
|
|
|
except:
|
|
|
|
logger.warning("Get Stats: " + str(sys.exc_info()))
|
|
|
|
return Response({'action': "Get Stats", 'message': "Something Went Wrong"},
|
|
|
|
status=status.HTTP_400_BAD_REQUEST)
|
2023-10-19 06:30:46 +05:30
|
|
|
|
|
|
|
|
|
|
|
@api_view(['GET'])
|
|
|
|
@isAuthorizedService()
|
|
|
|
@precheck(required_data=[OPENING_ID])
|
|
|
|
def get_eligible_students(request):
|
|
|
|
try:
|
|
|
|
data = request.GET
|
|
|
|
opening_id = data[OPENING_ID]
|
|
|
|
if OPENING_TYPE in data:
|
|
|
|
opening_type= data[OPENING_TYPE]
|
|
|
|
else:
|
|
|
|
opening_type= "Placement"
|
2023-10-29 16:51:48 +05:30
|
|
|
if "send_all" in data:
|
|
|
|
send_all = "True"==data["send_all"]
|
|
|
|
else:
|
|
|
|
send_all = False
|
|
|
|
eligible_students=get_eligible_emails(opening_id=opening_id, opening_type=opening_type, send_all=send_all)
|
2023-10-19 06:30:46 +05:30
|
|
|
return Response({'action': "Get Eligible Students", 'message': "Eligible Students Fetched",
|
|
|
|
'eligible_students': eligible_students},
|
|
|
|
status=status.HTTP_200_OK)
|
|
|
|
except Http404:
|
|
|
|
return Response({'action': "Get Eligible Students", 'message': "Opening Not Found"},
|
|
|
|
status=status.HTTP_404_NOT_FOUND)
|
|
|
|
except:
|
|
|
|
logger.warning("Get Eligible Students: " + str(sys.exc_info()))
|
|
|
|
return Response({'action': "Get Eligible Students", 'message': "Something Went Wrong"},
|
|
|
|
status=status.HTTP_400_BAD_REQUEST)
|
|
|
|
|