2021-12-03 01:04:49 +05:30
|
|
|
import urllib
|
|
|
|
|
2021-10-15 20:47:23 +05:30
|
|
|
from rest_framework import serializers
|
|
|
|
from .models import *
|
|
|
|
|
|
|
|
|
|
|
|
class StudentSerializer(serializers.ModelSerializer):
|
2021-12-03 01:04:49 +05:30
|
|
|
resume_list = serializers.SerializerMethodField()
|
|
|
|
offers = serializers.SerializerMethodField()
|
|
|
|
|
|
|
|
def get_resume_list(self, obj):
|
|
|
|
links = []
|
|
|
|
for i in obj.resumes:
|
|
|
|
ele = {}
|
2022-05-01 14:56:46 +05:30
|
|
|
ele['link'] = LINK_TO_STORAGE_RESUME + urllib.parse.quote(obj.id + "/" + i)
|
2021-12-03 01:04:49 +05:30
|
|
|
ele['name'] = i
|
|
|
|
links.append(ele)
|
|
|
|
return links
|
|
|
|
|
|
|
|
def get_offers(self, obj):
|
|
|
|
selected_companies = PlacementApplication.objects.filter(student_id=obj.id, selected=True)
|
2022-05-01 22:51:14 +05:30
|
|
|
pre_placement_offers = PrePlacementOffer.objects.filter(student_id=obj.id)
|
2021-12-03 01:04:49 +05:30
|
|
|
companies = []
|
|
|
|
|
|
|
|
for i in selected_companies:
|
|
|
|
ele = {}
|
|
|
|
ele['designation'] = i.placement.designation
|
|
|
|
ele['company_name'] = i.placement.company_name
|
|
|
|
ele['application_id'] = i.id
|
2022-05-01 22:51:14 +05:30
|
|
|
ele['placement_offer_type'] = 'Normal'
|
|
|
|
companies.append(ele)
|
|
|
|
for i in pre_placement_offers:
|
|
|
|
ele = {}
|
|
|
|
ele['designation'] = i.designation
|
|
|
|
ele['company_name'] = i.company
|
|
|
|
ele['application_id'] = i.id
|
|
|
|
ele['placement_offer_type'] = 'PPO'
|
2021-12-03 01:04:49 +05:30
|
|
|
companies.append(ele)
|
|
|
|
|
|
|
|
return companies
|
|
|
|
|
2021-10-15 20:47:23 +05:30
|
|
|
class Meta:
|
|
|
|
model = Student
|
2021-12-03 01:04:49 +05:30
|
|
|
exclude = ['resumes']
|
2021-10-15 20:47:23 +05:30
|
|
|
|
2022-04-30 22:27:49 +05:30
|
|
|
|
2021-12-03 01:04:49 +05:30
|
|
|
class PlacementSerializerForStudent(serializers.ModelSerializer):
|
|
|
|
company_details_pdf_links = serializers.SerializerMethodField()
|
|
|
|
description_pdf_links = serializers.SerializerMethodField()
|
|
|
|
compensation_pdf_links = serializers.SerializerMethodField()
|
|
|
|
selection_procedure_details_pdf_links = serializers.SerializerMethodField()
|
2021-10-15 20:47:23 +05:30
|
|
|
|
2021-12-03 01:04:49 +05:30
|
|
|
def get_company_details_pdf_links(self, obj):
|
2022-04-30 22:27:49 +05:30
|
|
|
links = []
|
2021-12-03 01:04:49 +05:30
|
|
|
for pdf_name in obj.company_details_pdf_names:
|
|
|
|
ele = {}
|
2022-05-01 14:56:46 +05:30
|
|
|
link = LINK_TO_STORAGE_COMPANY_ATTACHMENT + urllib.parse.quote(obj.id + "/" + pdf_name)
|
2021-12-03 01:04:49 +05:30
|
|
|
ele['link'] = link
|
|
|
|
ele['name'] = pdf_name
|
|
|
|
links.append(ele)
|
|
|
|
return links
|
|
|
|
|
|
|
|
def get_description_pdf_links(self, obj):
|
2022-04-30 22:27:49 +05:30
|
|
|
links = []
|
2021-12-03 01:04:49 +05:30
|
|
|
for pdf_name in obj.description_pdf_names:
|
|
|
|
ele = {}
|
2022-05-01 14:56:46 +05:30
|
|
|
link = LINK_TO_STORAGE_COMPANY_ATTACHMENT + urllib.parse.quote(obj.id + "/" + pdf_name)
|
2021-12-03 01:04:49 +05:30
|
|
|
ele['link'] = link
|
|
|
|
ele['name'] = pdf_name
|
|
|
|
links.append(ele)
|
|
|
|
return links
|
|
|
|
|
|
|
|
def get_compensation_pdf_links(self, obj):
|
2022-04-30 22:27:49 +05:30
|
|
|
links = []
|
2021-12-03 01:04:49 +05:30
|
|
|
for pdf_name in obj.compensation_details_pdf_names:
|
|
|
|
ele = {}
|
2022-05-01 14:56:46 +05:30
|
|
|
link = LINK_TO_STORAGE_COMPANY_ATTACHMENT + urllib.parse.quote(obj.id + "/" + pdf_name)
|
2021-12-03 01:04:49 +05:30
|
|
|
ele['link'] = link
|
|
|
|
ele['name'] = pdf_name
|
|
|
|
links.append(ele)
|
|
|
|
return links
|
|
|
|
|
|
|
|
def get_selection_procedure_details_pdf_links(self, obj):
|
2022-04-30 22:27:49 +05:30
|
|
|
links = []
|
2021-12-03 01:04:49 +05:30
|
|
|
for pdf_name in obj.selection_procedure_details_pdf_names:
|
|
|
|
ele = {}
|
2022-05-01 14:56:46 +05:30
|
|
|
link = LINK_TO_STORAGE_COMPANY_ATTACHMENT + urllib.parse.quote(obj.id + "/" + pdf_name)
|
2021-12-03 01:04:49 +05:30
|
|
|
ele['link'] = link
|
|
|
|
ele['name'] = pdf_name
|
|
|
|
links.append(ele)
|
|
|
|
return links
|
|
|
|
|
2021-10-15 20:47:23 +05:30
|
|
|
class Meta:
|
|
|
|
model = Placement
|
2021-12-03 01:04:49 +05:30
|
|
|
exclude = [CONTACT_PERSON_NAME, PHONE_NUMBER, EMAIL, COMPANY_DETAILS_PDF_NAMES, DESCRIPTION_PDF_NAMES,
|
2022-04-30 22:27:49 +05:30
|
|
|
COMPENSATION_DETAILS_PDF_NAMES, SELECTION_PROCEDURE_DETAILS_PDF_NAMES, OFFER_ACCEPTED,
|
|
|
|
EMAIL_VERIFIED,
|
|
|
|
]
|
2021-10-15 20:47:23 +05:30
|
|
|
depth = 1
|
|
|
|
|
2022-04-30 22:27:49 +05:30
|
|
|
|
2021-12-03 01:04:49 +05:30
|
|
|
class PlacementSerializerForAdmin(serializers.ModelSerializer):
|
|
|
|
company_details_pdf_links = serializers.SerializerMethodField()
|
|
|
|
description_pdf_links = serializers.SerializerMethodField()
|
|
|
|
compensation_pdf_links = serializers.SerializerMethodField()
|
|
|
|
selection_procedure_details_pdf_links = serializers.SerializerMethodField()
|
2021-10-15 20:47:23 +05:30
|
|
|
|
2021-12-03 01:04:49 +05:30
|
|
|
def get_company_details_pdf_links(self, obj):
|
2022-04-30 22:27:49 +05:30
|
|
|
links = []
|
2021-12-03 01:04:49 +05:30
|
|
|
for pdf_name in obj.company_details_pdf_names:
|
|
|
|
ele = {}
|
2022-05-01 14:56:46 +05:30
|
|
|
link = LINK_TO_STORAGE_COMPANY_ATTACHMENT + urllib.parse.quote(obj.id + "/" + pdf_name)
|
2021-12-03 01:04:49 +05:30
|
|
|
ele['link'] = link
|
|
|
|
ele['name'] = pdf_name
|
|
|
|
links.append(ele)
|
|
|
|
return links
|
2021-10-15 20:47:23 +05:30
|
|
|
|
2021-12-03 01:04:49 +05:30
|
|
|
def get_description_pdf_links(self, obj):
|
2022-04-30 22:27:49 +05:30
|
|
|
links = []
|
2021-12-03 01:04:49 +05:30
|
|
|
for pdf_name in obj.description_pdf_names:
|
|
|
|
ele = {}
|
2022-05-01 14:56:46 +05:30
|
|
|
link = LINK_TO_STORAGE_COMPANY_ATTACHMENT + urllib.parse.quote(obj.id + "/" + pdf_name)
|
2021-12-03 01:04:49 +05:30
|
|
|
ele['link'] = link
|
|
|
|
ele['name'] = pdf_name
|
|
|
|
links.append(ele)
|
|
|
|
return links
|
2021-10-15 20:47:23 +05:30
|
|
|
|
2021-12-03 01:04:49 +05:30
|
|
|
def get_compensation_pdf_links(self, obj):
|
2022-04-30 22:27:49 +05:30
|
|
|
links = []
|
2021-12-03 01:04:49 +05:30
|
|
|
for pdf_name in obj.compensation_details_pdf_names:
|
|
|
|
ele = {}
|
2022-05-01 14:56:46 +05:30
|
|
|
link = LINK_TO_STORAGE_COMPANY_ATTACHMENT + urllib.parse.quote(obj.id + "/" + pdf_name)
|
2021-12-03 01:04:49 +05:30
|
|
|
ele['link'] = link
|
|
|
|
ele['name'] = pdf_name
|
|
|
|
links.append(ele)
|
|
|
|
return links
|
2021-10-15 20:47:23 +05:30
|
|
|
|
2021-12-03 01:04:49 +05:30
|
|
|
def get_selection_procedure_details_pdf_links(self, obj):
|
2022-04-30 22:27:49 +05:30
|
|
|
links = []
|
2021-12-03 01:04:49 +05:30
|
|
|
for pdf_name in obj.selection_procedure_details_pdf_names:
|
|
|
|
ele = {}
|
2022-05-01 14:56:46 +05:30
|
|
|
link = LINK_TO_STORAGE_COMPANY_ATTACHMENT + urllib.parse.quote(obj.id + "/" + pdf_name)
|
2021-12-03 01:04:49 +05:30
|
|
|
ele['link'] = link
|
|
|
|
ele['name'] = pdf_name
|
|
|
|
links.append(ele)
|
|
|
|
return links
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = Placement
|
|
|
|
exclude = [COMPANY_DETAILS_PDF_NAMES, DESCRIPTION_PDF_NAMES,
|
2022-04-30 22:27:49 +05:30
|
|
|
COMPENSATION_DETAILS_PDF_NAMES, SELECTION_PROCEDURE_DETAILS_PDF_NAMES]
|
2021-12-03 01:04:49 +05:30
|
|
|
depth = 1
|
|
|
|
|
|
|
|
|
|
|
|
class PlacementApplicationSerializer(serializers.ModelSerializer):
|
|
|
|
placement = serializers.SerializerMethodField()
|
|
|
|
resume_link = serializers.SerializerMethodField()
|
|
|
|
|
|
|
|
def get_placement(self, obj):
|
|
|
|
data = PlacementSerializerForStudent(obj.placement).data
|
2021-10-15 20:47:23 +05:30
|
|
|
return data
|
|
|
|
|
2021-12-03 01:04:49 +05:30
|
|
|
def get_resume_link(self, obj):
|
2021-12-16 23:05:04 +05:30
|
|
|
ele = {}
|
2022-05-01 14:56:46 +05:30
|
|
|
ele['link'] = LINK_TO_STORAGE_RESUME + urllib.parse.quote(obj.id + "/" + obj.resume)
|
2021-12-16 23:05:04 +05:30
|
|
|
ele['name'] = obj.resume
|
|
|
|
return ele
|
|
|
|
|
2021-10-15 20:47:23 +05:30
|
|
|
class Meta:
|
|
|
|
model = PlacementApplication
|
2021-12-03 01:04:49 +05:30
|
|
|
exclude = [STUDENT, 'resume']
|
2021-12-12 19:14:27 +05:30
|
|
|
|
2022-04-30 22:27:49 +05:30
|
|
|
|
2021-12-12 19:14:27 +05:30
|
|
|
class PlacementApplicationSerializerForAdmin(serializers.ModelSerializer):
|
|
|
|
student_details = serializers.SerializerMethodField()
|
|
|
|
resume_link = serializers.SerializerMethodField()
|
|
|
|
|
|
|
|
def get_student_details(self, obj):
|
|
|
|
data = StudentSerializer(obj.student).data
|
|
|
|
return data
|
|
|
|
|
|
|
|
def get_resume_link(self, obj):
|
2022-05-01 14:56:46 +05:30
|
|
|
link = LINK_TO_STORAGE_RESUME + urllib.parse.quote(obj.id + "/" + obj.resume)
|
2021-12-12 19:14:27 +05:30
|
|
|
return link
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = PlacementApplication
|
2022-04-30 22:27:49 +05:30
|
|
|
exclude = ['placement', 'resume']
|