format placement added.

This commit is contained in:
gowtham 2022-05-21 16:08:30 +05:30
parent 31c73b6b20
commit f881ce5b45
4 changed files with 101 additions and 53 deletions

View File

@ -335,6 +335,7 @@ def addPPO(request, id, email, user_type):
return Response({'action': "Add PPO", 'message': "Error Occurred"}, return Response({'action': "Add PPO", 'message': "Error Occurred"},
status=status.HTTP_400_BAD_REQUEST) status=status.HTTP_400_BAD_REQUEST)
@api_view(['POST']) @api_view(['POST'])
@isAuthorized(allowed_users=[ADMIN]) @isAuthorized(allowed_users=[ADMIN])
@precheck(required_data=[STUDENT_ID, OPENING_ID]) @precheck(required_data=[STUDENT_ID, OPENING_ID])
@ -343,26 +344,34 @@ def getstudentapplication(request, id, email, user_type):
data = request.data data = request.data
student = get_object_or_404(Student, id=data[STUDENT_ID]) student = get_object_or_404(Student, id=data[STUDENT_ID])
# search for the application if there or not # search for the application if there or not
application = PlacementApplication.objects.filter(student=student, placement=get_object_or_404(Placement, id=data[OPENING_ID])) application = PlacementApplication.objects.filter(student=student,
logger.info("Get Student Application: " + str(application)) placement=get_object_or_404(Placement, id=data[OPENING_ID]))
if application: if application:
serializer = PlacementApplicationSerializer(application[0]) serializer = PlacementApplicationSerializer(application[0])
return Response({'action': "Get Student Application", 'found': "true",'application_id': serializer.data["id"] , 'application_additionalInfo': serializer.data[ADDITIONAL_INFO],"available_resumes":student.resumes, return Response(
"student_name":student.name, "student_branch":student.branch, "student_batch":student.batch }, {'action': "Get Student Application", 'found': "true", 'application_id': serializer.data["id"],
status=status.HTTP_200_OK) 'application_additionalInfo': serializer.data[ADDITIONAL_INFO], "available_resumes": student.resumes,
"student_name": student.name, "student_branch": student.branch, "student_batch": student.batch},
status=status.HTTP_200_OK)
else: else:
return Response({'action': "Get Student Application", 'found': "false", "available_resumes": student.resumes, return Response(
"student_name":student.name, "student_branch":student.branch, "student_batch":student.batch}, {'action': "Get Student Application", 'found': "false", "available_resumes": student.resumes,
status=status.HTTP_200_OK) "student_name": student.name, "student_branch": student.branch, "student_batch": student.batch},
status=status.HTTP_200_OK)
except Http404:
return Response(
{'action': "Get Student Application", 'message': "Not found"},
)
except: except:
logger.warning("Get Student Application: " + str(sys.exc_info())) logger.warning("Get Student Application: " + str(sys.exc_info()))
print(sys.exc_info()) print(sys.exc_info())
return Response({'action': "Get Student Application", 'message': "Student with given roll number not found."}, status.HTTP_400_BAD_REQUEST) return Response({'action': "Get Student Application", 'message': "Student with given roll number not found."},
status.HTTP_400_BAD_REQUEST)
@api_view(['POST']) @api_view(['POST'])
@isAuthorized(allowed_users=[ADMIN]) @isAuthorized(allowed_users=[ADMIN])
@precheck(required_data=[APPLICATION_ID,STUDENT_ID,OPENING_ID,ADDITIONAL_INFO,RESUME_FILE_NAME]) @precheck(required_data=[APPLICATION_ID, STUDENT_ID, OPENING_ID, ADDITIONAL_INFO, RESUME_FILE_NAME])
def addstudentapplication(request, id, email, user_type): def addstudentapplication(request, id, email, user_type):
try: try:
data = request.data data = request.data
@ -383,11 +392,11 @@ def addstudentapplication(request, id, email, user_type):
application.additional_info = json.dumps(data[ADDITIONAL_INFO]) application.additional_info = json.dumps(data[ADDITIONAL_INFO])
application.save() application.save()
return Response({'action': "Add Student Application", 'message': "Application updated"}, return Response({'action': "Add Student Application", 'message': "Application updated"},
status=status.HTTP_200_OK) status=status.HTTP_200_OK)
else: else:
return Response({'action': "Edit Student Application", 'message': "No Application Found"}, return Response({'action': "Edit Student Application", 'message': "No Application Found"},
status=status.HTTP_400_BAD_REQUEST) status=status.HTTP_400_BAD_REQUEST)
except: except:
logger.warning("Edit Student Application: " + str(sys.exc_info())) logger.warning("Edit Student Application: " + str(sys.exc_info()))
print(sys.exc_info()) print(sys.exc_info())

View File

@ -70,7 +70,7 @@ def addPlacement(request):
raise ValueError('Pincode should be integer') raise ValueError('Pincode should be integer')
# If India then set city_type as Domestic else International # If India then set city_type as Domestic else International
if opening.country == 'India': if opening.country.upper() == 'INDIA':
opening.city_type = 'Domestic' opening.city_type = 'Domestic'
else: else:
opening.city_type = 'International' opening.city_type = 'International'

View File

@ -55,6 +55,10 @@ TIER = 'tier'
FOURTH_YEAR = '2019' FOURTH_YEAR = '2019'
MAX_OFFERS_PER_STUDENT = 2 MAX_OFFERS_PER_STUDENT = 2
EMAIL_VERIFICATION_TOKEN_TTL = 48 # in hours EMAIL_VERIFICATION_TOKEN_TTL = 48 # in hours
JNF_TEXT_MAX_CHARACTER_COUNT = 100
JNF_TEXTMEDIUM_MAX_CHARACTER_COUNT = 200
JNF_TEXTAREA_MAX_CHARACTER_COUNT = 1000
JNF_SMALLTEXT_MAX_CHARACTER_COUNT = 50
STORAGE_DESTINATION_RESUMES = "./Storage/Resumes/" STORAGE_DESTINATION_RESUMES = "./Storage/Resumes/"
STORAGE_DESTINATION_COMPANY_ATTACHMENTS = './Storage/Company_Attachments/' STORAGE_DESTINATION_COMPANY_ATTACHMENTS = './Storage/Company_Attachments/'
@ -122,10 +126,11 @@ STUDENT_ID = "student_id"
STUDENT_SELECTED = "student_selected" STUDENT_SELECTED = "student_selected"
EXCLUDE_IN_PDF = ['id', 'is_company_details_pdf', 'offer_accepted', 'is_description_pdf', EXCLUDE_IN_PDF = ['id', 'is_company_details_pdf', 'offer_accepted', 'is_description_pdf',
'is_compensation_details_pdf', 'is_selection_procedure_details_pdf', 'is_compensation_details_pdf', 'is_selection_procedure_details_pdf',
'email_verified', 'created_at'] 'email_verified', 'created_at']
SPECIAL_FORMAT_IN_PDF = ['website', 'company_details_pdf_names', 'description_pdf_names', 'compensation_details_pdf_names', SPECIAL_FORMAT_IN_PDF = ['website', 'company_details_pdf_names', 'description_pdf_names',
'selection_procedure_pdf_names'] 'compensation_details_pdf_names',
'selection_procedure_pdf_names']
COMPANY_OPENING_SUBMITTED_TEMPLATE_SUBJECT = "Notification Submitted - {id} - Career Development Cell, IIT Dharwad" COMPANY_OPENING_SUBMITTED_TEMPLATE_SUBJECT = "Notification Submitted - {id} - Career Development Cell, IIT Dharwad"
STUDENT_APPLICATION_STATUS_TEMPLATE_SUBJECT = 'Application Status : {company_name} - {id}' STUDENT_APPLICATION_STATUS_TEMPLATE_SUBJECT = 'Application Status : {company_name} - {id}'

View File

@ -9,20 +9,25 @@ from .constants import *
class User(models.Model): class User(models.Model):
email = models.CharField(primary_key=True, blank=False, max_length=50) email = models.EmailField(primary_key=True, blank=False, max_length=JNF_TEXT_MAX_CHARACTER_COUNT)
id = models.CharField(blank=False, max_length=25) id = models.CharField(blank=False, max_length=25)
user_type = ArrayField(models.CharField(blank=False, max_length=10), size=4, default=list, blank=False) user_type = ArrayField(models.CharField(blank=False, max_length=10), size=4, default=list, blank=False)
last_login_time = models.DateTimeField(default=timezone.now) last_login_time = models.DateTimeField(default=timezone.now)
class Meta:
verbose_name_plural = "User"
unique_together = ('email', 'id')
class Student(models.Model): class Student(models.Model):
id = models.CharField(blank=False, max_length=15, primary_key=True) id = models.CharField(blank=False, max_length=15, primary_key=True)
roll_no = models.IntegerField(blank=False) roll_no = models.IntegerField(blank=False)
name = models.CharField(blank=False, max_length=50) name = models.CharField(blank=False, max_length=JNF_TEXT_MAX_CHARACTER_COUNT)
batch = models.CharField(max_length=10, choices=BATCH_CHOICES, blank=False) batch = models.CharField(max_length=10, choices=BATCH_CHOICES, blank=False)
branch = models.CharField(choices=BRANCH_CHOICES, blank=False, max_length=10) branch = models.CharField(choices=BRANCH_CHOICES, blank=False, max_length=10)
phone_number = models.PositiveBigIntegerField(blank=True, default=None, null=True) phone_number = models.PositiveBigIntegerField(blank=True, default=None, null=True)
resumes = ArrayField(models.CharField(null=True, default=None, max_length=100), size=10, default=list, blank=True) resumes = ArrayField(models.CharField(null=True, default=None, max_length=JNF_TEXT_MAX_CHARACTER_COUNT), size=10,
default=list, blank=True)
cpi = models.DecimalField(decimal_places=2, max_digits=4) cpi = models.DecimalField(decimal_places=2, max_digits=4)
can_apply = models.BooleanField(default=True, verbose_name='Registered') can_apply = models.BooleanField(default=True, verbose_name='Registered')
@ -32,7 +37,7 @@ class Student(models.Model):
class Admin(models.Model): class Admin(models.Model):
id = models.CharField(blank=False, max_length=15, primary_key=True) id = models.CharField(blank=False, max_length=15, primary_key=True)
name = models.CharField(blank=False, max_length=50) name = models.CharField(blank=False, max_length=JNF_TEXT_MAX_CHARACTER_COUNT)
def two_day_after_today(): def two_day_after_today():
@ -42,43 +47,49 @@ def two_day_after_today():
class Placement(models.Model): class Placement(models.Model):
id = models.CharField(blank=False, primary_key=True, max_length=15) id = models.CharField(blank=False, primary_key=True, max_length=15)
# Company Details # Company Details
company_name = models.CharField(blank=False, max_length=50) company_name = models.CharField(blank=False, max_length=JNF_SMALLTEXT_MAX_CHARACTER_COUNT)
address = models.CharField(blank=False, max_length=500) address = models.CharField(blank=False, max_length=JNF_TEXTAREA_MAX_CHARACTER_COUNT)
company_type = models.CharField(blank=False, max_length=50) company_type = models.CharField(blank=False, max_length=JNF_SMALLTEXT_MAX_CHARACTER_COUNT)
nature_of_business = models.CharField(blank=False, max_length=50, default="") nature_of_business = models.CharField(blank=False, max_length=JNF_SMALLTEXT_MAX_CHARACTER_COUNT, default="")
website = models.CharField(blank=True, max_length=50) website = models.CharField(blank=True, max_length=JNF_TEXT_MAX_CHARACTER_COUNT)
company_details = models.CharField(max_length=500, default=None, null=True) company_details = models.CharField(max_length=JNF_TEXTAREA_MAX_CHARACTER_COUNT, default=None, null=True)
company_details_pdf_names = ArrayField(models.CharField(null=True, default=None, max_length=100), size=5, company_details_pdf_names = ArrayField(
default=list, blank=True) models.CharField(null=True, default=None, max_length=JNF_TEXT_MAX_CHARACTER_COUNT), size=5,
default=list, blank=True)
is_company_details_pdf = models.BooleanField(blank=False, default=False) is_company_details_pdf = models.BooleanField(blank=False, default=False)
contact_person_name = models.CharField(blank=False, max_length=50) contact_person_name = models.CharField(blank=False, max_length=JNF_TEXT_MAX_CHARACTER_COUNT)
phone_number = models.PositiveBigIntegerField(blank=False) phone_number = models.PositiveBigIntegerField(blank=False)
email = models.CharField(blank=False, max_length=50, default="") email = models.CharField(blank=False, max_length=JNF_SMALLTEXT_MAX_CHARACTER_COUNT, default="")
city = models.CharField(blank=False, max_length=100, default="") city = models.CharField(blank=False, max_length=JNF_SMALLTEXT_MAX_CHARACTER_COUNT, default="")
state = models.CharField(blank=False, max_length=100, default="") state = models.CharField(blank=False, max_length=JNF_SMALLTEXT_MAX_CHARACTER_COUNT, default="")
country = models.CharField(blank=False, max_length=100, default="") country = models.CharField(blank=False, max_length=JNF_SMALLTEXT_MAX_CHARACTER_COUNT, default="")
pin_code = models.IntegerField(blank=False, default=None, null=True) pin_code = models.IntegerField(blank=False, default=None, null=True)
city_type = models.CharField(blank=False, max_length=15, choices=OFFER_CITY_TYPE) city_type = models.CharField(blank=False, max_length=15, choices=OFFER_CITY_TYPE)
# Job Details # Job Details
designation = models.CharField(blank=False, max_length=50, default=None, null=True) designation = models.CharField(blank=False, max_length=JNF_TEXT_MAX_CHARACTER_COUNT, default=None, null=True)
description = models.CharField(blank=False, max_length=500, default=None, null=True) description = models.CharField(blank=False, max_length=JNF_TEXTAREA_MAX_CHARACTER_COUNT, default=None, null=True)
description_pdf_names = ArrayField(models.CharField(null=True, default=None, max_length=100), size=5, default=list, description_pdf_names = ArrayField(
blank=True) models.CharField(null=True, default=None, max_length=JNF_TEXT_MAX_CHARACTER_COUNT), size=5, default=list,
blank=True)
is_description_pdf = models.BooleanField(blank=False, default=False) is_description_pdf = models.BooleanField(blank=False, default=False)
compensation_CTC = models.IntegerField(blank=False, default=None, null=True) # Job - Per Year compensation_CTC = models.IntegerField(blank=False, default=None, null=True) # Job - Per Year
compensation_gross = models.IntegerField(blank=False, default=None, null=True) compensation_gross = models.IntegerField(blank=False, default=None, null=True)
compensation_take_home = models.IntegerField(blank=False, default=None, null=True) compensation_take_home = models.IntegerField(blank=False, default=None, null=True)
compensation_bonus = models.IntegerField(blank=True, default=None, null=True) compensation_bonus = models.IntegerField(blank=True, default=None, null=True)
compensation_details = models.CharField(blank=True, max_length=500, default=None, null=True) compensation_details = models.CharField(blank=True, max_length=JNF_TEXTAREA_MAX_CHARACTER_COUNT, default=None,
compensation_details_pdf_names = ArrayField(models.CharField(null=True, default=None, max_length=100), size=5, null=True)
default=list, blank=True) compensation_details_pdf_names = ArrayField(
models.CharField(null=True, default=None, max_length=JNF_TEXT_MAX_CHARACTER_COUNT), size=5,
default=list, blank=True)
is_compensation_details_pdf = models.BooleanField(blank=False, default=False) is_compensation_details_pdf = models.BooleanField(blank=False, default=False)
bond_details = models.CharField(blank=True, max_length=500) bond_details = models.CharField(blank=True, max_length=JNF_TEXTAREA_MAX_CHARACTER_COUNT)
selection_procedure_rounds = ArrayField(models.CharField(null=True, default=None, max_length=100), size=10, selection_procedure_rounds = ArrayField(
default=list, blank=True) models.CharField(null=True, default=None, max_length=JNF_TEXT_MAX_CHARACTER_COUNT), size=10,
selection_procedure_details = models.CharField(blank=True, max_length=500) default=list, blank=True)
selection_procedure_details_pdf_names = ArrayField(models.CharField(null=True, default=None, max_length=100), selection_procedure_details = models.CharField(blank=True, max_length=JNF_TEXTAREA_MAX_CHARACTER_COUNT)
size=5, default=list, blank=True) selection_procedure_details_pdf_names = ArrayField(
models.CharField(null=True, default=None, max_length=JNF_TEXT_MAX_CHARACTER_COUNT),
size=5, default=list, blank=True)
is_selection_procedure_details_pdf = models.BooleanField(blank=False, default=False) is_selection_procedure_details_pdf = models.BooleanField(blank=False, default=False)
tier = models.CharField(blank=False, choices=TIERS, max_length=10, default=None, null=True) tier = models.CharField(blank=False, choices=TIERS, max_length=10, default=None, null=True)
tentative_date_of_joining = models.DateField(blank=False, verbose_name="Tentative Date", default=timezone.now) tentative_date_of_joining = models.DateField(blank=False, verbose_name="Tentative Date", default=timezone.now)
@ -94,18 +105,40 @@ class Placement(models.Model):
default=list default=list
) )
tentative_no_of_offers = models.IntegerField(blank=False, default=None, null=True) tentative_no_of_offers = models.IntegerField(blank=False, default=None, null=True)
other_requirements = models.CharField(blank=True, max_length=200, default="") rs_eligible = models.BooleanField(blank=False, default=False)
additional_info = ArrayField(models.CharField(blank=True, max_length=200), size=15, default=list, blank=True) other_requirements = models.CharField(blank=True, max_length=JNF_TEXTAREA_MAX_CHARACTER_COUNT, default="")
additional_info = ArrayField(models.CharField(blank=True, max_length=JNF_TEXTMEDIUM_MAX_CHARACTER_COUNT), size=15,
default=list, blank=True)
email_verified = models.BooleanField(blank=False, default=False) email_verified = models.BooleanField(blank=False, default=False)
offer_accepted = models.BooleanField(blank=False, default=None, null=True) offer_accepted = models.BooleanField(blank=False, default=None, null=True)
deadline_datetime = models.DateTimeField(blank=False, verbose_name="Deadline Date", default=two_day_after_today) deadline_datetime = models.DateTimeField(blank=False, verbose_name="Deadline Date", default=two_day_after_today)
created_at = models.DateTimeField(blank=False, default=None, null=True) created_at = models.DateTimeField(blank=False, default=None, null=True)
def format(self):
self.company_name = self.company_name.strip()[:JNF_SMALLTEXT_MAX_CHARACTER_COUNT]
self.company_type = self.company_type.strip()[:JNF_SMALLTEXT_MAX_CHARACTER_COUNT]
self.nature_of_business = self.nature_of_business.strip()[:JNF_SMALLTEXT_MAX_CHARACTER_COUNT]
self.website = self.website.strip()[:JNF_TEXT_MAX_CHARACTER_COUNT]
self.company_details = self.company_details.strip()[:JNF_TEXTAREA_MAX_CHARACTER_COUNT]
self.contact_person_name = self.contact_person_name.strip()[:JNF_TEXT_MAX_CHARACTER_COUNT]
self.email = self.email.strip()[:JNF_SMALLTEXT_MAX_CHARACTER_COUNT]
self.city = self.city.strip()[:JNF_SMALLTEXT_MAX_CHARACTER_COUNT]
self.state = self.state.strip()[:JNF_SMALLTEXT_MAX_CHARACTER_COUNT]
self.country = self.country.strip()[:JNF_SMALLTEXT_MAX_CHARACTER_COUNT]
self.city_type = self.city_type.strip()[:JNF_SMALLTEXT_MAX_CHARACTER_COUNT]
self.designation = self.designation.strip()[:JNF_TEXT_MAX_CHARACTER_COUNT]
self.description = self.description.strip()[:JNF_TEXTAREA_MAX_CHARACTER_COUNT]
self.compensation_details = self.compensation_details.strip()[:JNF_TEXTAREA_MAX_CHARACTER_COUNT]
self.selection_procedure_details = self.selection_procedure_details.strip()[:JNF_TEXTAREA_MAX_CHARACTER_COUNT]
self.bond_details = self.bond_details.strip()[:JNF_TEXTAREA_MAX_CHARACTER_COUNT]
self.other_requirements = self.other_requirements.strip()[:JNF_TEXTAREA_MAX_CHARACTER_COUNT]
self.additinal_info = [info.strip()[:JNF_TEXTMEDIUM_MAX_CHARACTER_COUNT] for info in self.additional_info]
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
''' On save, add timestamps ''' ''' On save, add timestamps '''
if not self.created_at: if not self.created_at:
self.created_at = timezone.now() self.created_at = timezone.now()
self.format()
return super(Placement, self).save(*args, **kwargs) return super(Placement, self).save(*args, **kwargs)
def __str__(self): def __str__(self):
@ -116,7 +149,7 @@ class PlacementApplication(models.Model):
id = models.CharField(blank=False, primary_key=True, max_length=15) id = models.CharField(blank=False, primary_key=True, max_length=15)
placement = models.ForeignKey(Placement, blank=False, on_delete=models.RESTRICT, default=None, null=True) placement = models.ForeignKey(Placement, blank=False, on_delete=models.RESTRICT, default=None, null=True)
student = models.ForeignKey(Student, blank=False, on_delete=models.CASCADE) student = models.ForeignKey(Student, blank=False, on_delete=models.CASCADE)
resume = models.CharField(max_length=100, blank=False, null=True, default=None) resume = models.CharField(max_length=JNF_TEXT_MAX_CHARACTER_COUNT, blank=False, null=True, default=None)
additional_info = models.JSONField(blank=True, null=True, default=None) additional_info = models.JSONField(blank=True, null=True, default=None)
selected = models.BooleanField(null=True, default=None, blank=True) selected = models.BooleanField(null=True, default=None, blank=True)
applied_at = models.DateTimeField(blank=False, default=None, null=True) applied_at = models.DateTimeField(blank=False, default=None, null=True)
@ -139,7 +172,8 @@ class PlacementApplication(models.Model):
class PrePlacementOffer(models.Model): class PrePlacementOffer(models.Model):
id = models.AutoField(primary_key=True) id = models.AutoField(primary_key=True)
student = models.ForeignKey(Student, on_delete=models.CASCADE, blank=False) student = models.ForeignKey(Student, on_delete=models.CASCADE, blank=False)
company = models.CharField(max_length=50, blank=False, default="", verbose_name="Company Name") company = models.CharField(max_length=JNF_SMALLTEXT_MAX_CHARACTER_COUNT, blank=False, default="",
verbose_name="Company Name")
compensation = models.IntegerField(blank=False) # Job - Per Year compensation = models.IntegerField(blank=False) # Job - Per Year
compensation_details = models.CharField(blank=True, max_length=200) compensation_details = models.CharField(blank=True, max_length=200)
tier = models.CharField(blank=False, choices=TIERS, max_length=10) tier = models.CharField(blank=False, choices=TIERS, max_length=10)