Merge pull request #197 from CDC-IITDH/vnitin

changes
This commit is contained in:
Jaya Surya P 2024-07-19 15:39:49 +05:30 committed by GitHub
commit 7f2e4d24dd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 176 additions and 38 deletions

View File

@ -11,11 +11,11 @@ logger = logging.getLogger('db')
IS_COMPANY_DETAILS_PDF, CONTACT_PERSON_NAME, PHONE_NUMBER, EMAIL, CITY, STATE, COUNTRY, PINCODE, DESIGNATION,
DESCRIPTION,
IS_DESCRIPTION_PDF, COMPENSATION_CTC, COMPENSATION_GROSS, COMPENSATION_TAKE_HOME, COMPENSATION_BONUS,
IS_COMPENSATION_DETAILS_PDF, ALLOWED_BRANCH, RS_ELIGIBLE, SELECTION_PROCEDURE_ROUNDS,
IS_COMPENSATION_DETAILS_PDF, ALLOWED_BRANCH, ELIGIBLESTUDENTS, SELECTION_PROCEDURE_ROUNDS,
SELECTION_PROCEDURE_DETAILS,
IS_SELECTION_PROCEDURE_DETAILS_PDF, TENTATIVE_DATE_OF_JOINING, TENTATIVE_NO_OF_OFFERS, OTHER_REQUIREMENTS,
RECAPTCHA_VALUE, JOB_LOCATION
])
RECAPTCHA_VALUE, JOB_LOCATION,PSYCHOMETRIC_TEST,MEDICAL_TEST,COMPANY_TURNOVER,NUMBER_OF_EMPLOYEES,BACKLOG_ELIGIBLE,PWD_ELIGIBLE,CPI ,COMPANY_TURNOVER,ESTABLISHMENT_DATE ,EXPECTED_NO_OF_OFFERS])
def addPlacement(request):
logger.info("JNF filled by " + str(request.data['email']))
logger.info(request.data)
@ -36,11 +36,36 @@ def addPlacement(request):
opening.website = data[WEBSITE]
opening.company_details = data[COMPANY_DETAILS]
opening.is_company_details_pdf = data[IS_COMPANY_DETAILS_PDF]
if data[RS_ELIGIBLE] == 'Yes':
opening.rs_eligible = True
# if data[RS_ELIGIBLE] == 'Yes':
# opening.rs_eligible = True
# else:
# opening.rs_eligible = False
print(data[ELIGIBLESTUDENTS])
if data[ELIGIBLESTUDENTS] is None:
raise ValueError('Eligible Students cannot be empty')
elif set(json.loads(data[ELIGIBLESTUDENTS])).issubset(ELIGIBLE):
opening.eligiblestudents = json.loads(data[ELIGIBLESTUDENTS])
else:
opening.rs_eligible = False
raise ValueError('Allowed Branch must be a subset of ' + str(ELIGIBLE))
print(opening.eligiblestudents)
if data[PWD_ELIGIBLE] == 'Yes':
opening.pwd_eligible = True
else:
opening.pwd_eligible = False
if data[BACKLOG_ELIGIBLE] == 'Yes':
opening.backlog_eligible = True
else:
opening.backlog_eligible = False
if data[PSYCHOMETRIC_TEST] == 'Yes':
opening.psychometric_test = True
else:
opening.psychometric_test = False
if data[MEDICAL_TEST] == 'Yes':
opening.medical_test = True
else:
opening.medical_test = False
opening.cpi_eligible = data[CPI]
if opening.is_company_details_pdf:
company_details_pdf = []
for file in files.getlist(COMPANY_DETAILS_PDF):
@ -113,6 +138,13 @@ def addPlacement(request):
opening.compensation_CTC = None
else:
raise ValueError('Compensation CTC must be an integer')
# Newly added
if data[COMPANY_TURNOVER].isdigit():
opening.company_turnover = int(data[COMPANY_TURNOVER])
elif data[COMPANY_TURNOVER] is None:
opening.company_turnover = None
else:
raise ValueError('Company Turnover must be an integer')
# Check if compensation_gross is integer
if data[COMPENSATION_GROSS].isdigit():
@ -195,6 +227,8 @@ def addPlacement(request):
# Convert to date object
opening.tentative_date_of_joining = datetime.datetime.strptime(data[TENTATIVE_DATE_OF_JOINING],
'%d-%m-%Y').date()
opening.establishment_date = datetime.datetime.strptime(data[ESTABLISHMENT_DATE],
'%d-%m-%Y').date() # newly added field
# Only Allowing Fourth Year for Placement
opening.allowed_batch = [FOURTH_YEAR,]
@ -213,8 +247,17 @@ def addPlacement(request):
opening.tentative_no_of_offers = None
else:
raise ValueError('Tentative No Of Offers must be an integer')
# newly added
if data[EXPECTED_NO_OF_OFFERS].isdigit():
opening.expected_no_of_offers = int(data[EXPECTED_NO_OF_OFFERS])
elif data[EXPECTED_NO_OF_OFFERS] == 'null':
opening.expected_no_of_offers = None
opening.other_requirements = data[OTHER_REQUIREMENTS]
# newly added
if data[NUMBER_OF_EMPLOYEES].isdigit():
opening.number_of_employees = int(data[NUMBER_OF_EMPLOYEES])
elif data[NUMBER_OF_EMPLOYEES] == 'null':
opening.number_of_employees = None
opening.save()
@ -235,20 +278,19 @@ def addPlacement(request):
except ValueError as e:
store_all_files(request)
#exception_email(data)
logger.warning("ValueError in addPlacement: " + str(e))
logger.warning(traceback.format_exc())
return Response({'action': "Add Placement", 'message': str(e)},
status=status.HTTP_400_BAD_REQUEST)
except:
except Exception as e:
store_all_files(request)
#exception_email(data)
logger.warning("Add New Placement: " + str(sys.exc_info()))
logger.warning("Add New Placement: " + str(e))
logger.warning(traceback.format_exc())
return Response({'action': "Add Placement", 'message': "Something went wrong"},
return Response({'action': "Add Placement", 'message': "Something went wrong: " + str(e)},
status=status.HTTP_400_BAD_REQUEST)
@api_view(['POST'])
@precheck([TOKEN])
def verifyEmail(request):
@ -349,10 +391,10 @@ def autoFillInf(request):
@precheck([COMPANY_NAME, WEBSITE, IS_COMPANY_DETAILS_PDF, COMPANY_DETAILS, ADDRESS,
CITY, STATE, COUNTRY, PINCODE, COMPANY_TYPE, NATURE_OF_BUSINESS, IS_DESCRIPTION_PDF,
DESIGNATION, INTERNSHIP_LOCATION, DESCRIPTION, SEASON, START_DATE, END_DATE, WORK_TYPE,
ALLOWED_BRANCH, SOPHOMORES_ELIIGIBLE, RS_ELIGIBLE, NUM_OFFERS, IS_STIPEND_DETAILS_PDF, STIPEND,
ALLOWED_BRANCH, ELIGIBLESTUDENTS, NUM_OFFERS, IS_STIPEND_DETAILS_PDF, STIPEND,
FACILITIES, OTHER_FACILITIES, SELECTION_PROCEDURE_ROUNDS, SELECTION_PROCEDURE_DETAILS, IS_SELECTION_PROCEDURE_DETAILS_PDF,
SELECTION_PROCEDURE_DETAILS, OTHER_REQUIREMENTS,
CONTACT_PERSON_NAME, PHONE_NUMBER, EMAIL, RECAPTCHA_VALUE])
CONTACT_PERSON_NAME, PHONE_NUMBER, EMAIL, RECAPTCHA_VALUE ,ESTABLISHMENT_DATE,PWD_ELIGIBLE,BACKLOG_ELIGIBLE,PSYCHOMETRIC_TEST,MEDICAL_TEST,CPI,EXPECTED_NO_OF_OFFERS,NUMBER_OF_EMPLOYEES,COMPANY_TURNOVER])
def addInternship(request):
logger.info("INF filled by " + str(request.data['email']))
logger.info(request.data)
@ -413,7 +455,7 @@ def addInternship(request):
raise ValueError('Season must be a subset of ' + str(SEASONS))
internship.interning_period_from = datetime.datetime.strptime(data[START_DATE], '%d-%m-%Y').date()
internship.interning_period_to = datetime.datetime.strptime(data[END_DATE], '%d-%m-%Y').date()
internship.establishment_date = datetime.datetime.strptime(data[ESTABLISHMENT_DATE], '%d-%m-%Y').date() # newly added field
if data[WORK_TYPE] == 'Work from home':
internship.is_work_from_home = True
else:
@ -434,14 +476,35 @@ def addInternship(request):
else:
raise ValueError('Allowed Branch must be a subset of ' + str(BRANCHES))
if data[SOPHOMORES_ELIIGIBLE] == 'Yes':
internship.sophomore_eligible = True
# if data[SOPHOMORES_ELIIGIBLE] == 'Yes':
# internship.sophomore_eligible = True
# else:
# internship.sophomore_eligible = False
if data[ELIGIBLESTUDENTS] is None:
raise ValueError('Eligible Students cannot be empty')
elif set(json.loads(data[ELIGIBLESTUDENTS])).issubset(ELIGIBLE):
internship.eligiblestudents = json.loads(data[ELIGIBLESTUDENTS])
else:
internship.sophomore_eligible = False
if data[RS_ELIGIBLE] == 'Yes':
internship.rs_eligible = True
raise ValueError('Allowed Branch must be a subset of ' + str(ELIGIBLE))
print(internship.eligiblestudents)
if data[PWD_ELIGIBLE] == 'Yes':
internship.pwd_eligible = True
else:
internship.rs_eligible = False
internship.pwd_eligible = False
if data[BACKLOG_ELIGIBLE] == 'Yes':
internship.backlog_eligible = True
else:
internship.backlog_eligible = False
if data[PSYCHOMETRIC_TEST] == 'Yes':
internship.psychometric_test = True
else:
internship.psychometric_test = False
if data[MEDICAL_TEST] == 'Yes':
internship.medical_test = True
else:
internship.medical_test = False
internship.cpi_eligible = data[CPI]
if data[NUM_OFFERS].isdigit():
internship.tentative_no_of_offers = int(data[NUM_OFFERS])
else:
@ -463,6 +526,24 @@ def addInternship(request):
internship.stipend = int(data[STIPEND])
else:
raise ValueError('Stipend must be an integer')
# Newly added
if data[COMPANY_TURNOVER].isdigit():
internship.company_turnover = int(data[COMPANY_TURNOVER])
elif data[COMPANY_TURNOVER] is None:
internship.company_turnover = None
else:
raise ValueError('Company Turnover must be an integer')
# newly added
if data[EXPECTED_NO_OF_OFFERS].isdigit():
internship.expected_no_of_offers = int(data[EXPECTED_NO_OF_OFFERS])
elif data[EXPECTED_NO_OF_OFFERS] == 'null':
internship.expected_no_of_offers = None
internship.other_requirements = data[OTHER_REQUIREMENTS]
# newly added
if data[NUMBER_OF_EMPLOYEES].isdigit():
internship.number_of_employees = int(data[NUMBER_OF_EMPLOYEES])
elif data[NUMBER_OF_EMPLOYEES] == 'null':
internship.number_of_employees = None
if data[FACILITIES] != "" :
if json.loads(data[FACILITIES]) == "":
internship.facilities_provided = []
@ -527,15 +608,15 @@ def addInternship(request):
status=status.HTTP_200_OK)
except ValueError as e:
store_all_files(request)
# exception_email(data)
logger.warning("ValueError in addInternship: " + str(e))
logger.warning(traceback.format_exc())
return Response({'action': "Add Internship", 'message': str(e)},
status=status.HTTP_400_BAD_REQUEST)
except:
except Exception as e:
store_all_files(request)
# exception_email(data)
logger.warning("Add New Internship: " + str(sys.exc_info()))
logger.warning("Add New Internship: " + str(e))
logger.warning(traceback.format_exc())
return Response({'action': "Add Internship", 'message': "Something went wrong"},
return Response({'action': "Add Internship", 'message': "Something went wrong: " + str(e)},
status=status.HTTP_400_BAD_REQUEST)

View File

@ -12,6 +12,12 @@ BRANCH_CHOICES = [
['CHEMICAL', 'CHEMICAL'],
['BSMS', 'BSMS'],
]
ELIGIBLE_CHOICES = [
["Btech", "Btech"],
["MS", "MS"],
["MTech", "MTech"],
["PHD", "PHD"],
]
BRANCHES = [
"CSE",
"EE",
@ -21,6 +27,12 @@ BRANCHES = [
"CHEMICAL",
"BSMS",
]
ELIGIBLE =[
"Btech",
"MS",
"MTech",
"PHD",
]
BATCHES = [ #change it accordingly
"2023",
"2022",
@ -156,6 +168,7 @@ IS_DESCRIPTION_PDF = 'is_description_pdf'
OPENING_TYPE = 'opening_type'
JOB_LOCATION = 'job_location'
COMPENSATION_CTC = 'compensation_ctc'
COMPANY_TURNOVER = 'company_turnover' # newly added field
COMPENSATION_GROSS = 'compensation_gross'
COMPENSATION_TAKE_HOME = 'compensation_take_home'
COMPENSATION_BONUS = 'compensation_bonus'
@ -165,7 +178,13 @@ COMPENSATION_DETAILS_PDF_NAMES = 'compensation_details_pdf_names'
IS_COMPENSATION_DETAILS_PDF = 'is_compensation_details_pdf'
ALLOWED_BATCH = 'allowed_batch'
ALLOWED_BRANCH = 'allowed_branch'
RS_ELIGIBLE = 'rs_eligible'
# RS_ELIGIBLE = 'rs_eligible' removed
ELIGIBLESTUDENTS= 'eligiblestudents'# newly adde field
PWD_ELIGIBLE = 'pwd_eligible' # newly added field
BACKLOG_ELIGIBLE = 'backlog_eligible' # newly added field
PSYCHOMETRIC_TEST = 'pyschometric_test' # newly added field
MEDICAL_TEST = 'medical_test' # newly added field
CPI = 'cpi' # newly added field
BOND_DETAILS = 'bond_details'
SELECTION_PROCEDURE_ROUNDS = 'selection_procedure_rounds'
SELECTION_PROCEDURE_DETAILS = 'selection_procedure_details'
@ -173,7 +192,10 @@ SELECTION_PROCEDURE_DETAILS_PDF = 'selection_procedure_details_pdf'
SELECTION_PROCEDURE_DETAILS_PDF_NAMES = 'selection_procedure_details_pdf_names'
IS_SELECTION_PROCEDURE_DETAILS_PDF = 'is_selection_procedure_details_pdf'
TENTATIVE_DATE_OF_JOINING = 'tentative_date_of_joining'
ESTABLISHMENT_DATE = 'establishment_date' # newly added field
TENTATIVE_NO_OF_OFFERS = 'tentative_no_of_offers'
EXPECTED_NO_OF_OFFERS = 'expected_no_of_offers' # newly added field
NUMBER_OF_EMPLOYEES = 'number_of_employees' # newly added field
OTHER_REQUIREMENTS = 'other_requirements'
DEADLINE_DATETIME = 'deadline_datetime'
OFFER_ACCEPTED = 'offer_accepted'

View File

@ -97,6 +97,7 @@ class Placement(models.Model):
country = models.CharField(blank=False, max_length=JNF_SMALLTEXT_MAX_CHARACTER_COUNT, default="")
pin_code = models.IntegerField(blank=False, default=None, null=True)
city_type = models.CharField(blank=False, max_length=15, choices=OFFER_CITY_TYPE)
cpi_eligible = models.DecimalField(decimal_places=2, default=0.00, max_digits=4) #newly added field
# Job Details
designation = models.CharField(blank=False, max_length=JNF_TEXT_MAX_CHARACTER_COUNT, default=None, null=True)
description = models.CharField(blank=False, max_length=JNF_TEXTAREA_MAX_CHARACTER_COUNT, default=None, null=True)
@ -106,6 +107,7 @@ class Placement(models.Model):
blank=True)
is_description_pdf = models.BooleanField(blank=False, default=False)
compensation_CTC = models.IntegerField(blank=False, default=None, null=True) # Job - Per Year
company_turnover = models.IntegerField(blank=False, default=None, null=True) # newly added field
compensation_gross = 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)
@ -124,6 +126,7 @@ class Placement(models.Model):
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)
tentative_date_of_joining = models.DateField(blank=False, verbose_name="Tentative Date", default=timezone.now)
establishment_date = models.DateField(blank=True, default=None, null=True) # newly added field
allowed_batch = ArrayField(
models.CharField(max_length=10, choices=BATCH_CHOICES),
size=TOTAL_BATCHES,
@ -136,7 +139,18 @@ class Placement(models.Model):
default=list
)
tentative_no_of_offers = models.IntegerField(blank=False, default=None, null=True)
rs_eligible = models.BooleanField(blank=False, default=False)
expected_no_of_offers = models.IntegerField(blank=False , default=None , null=True) # newly added
number_of_employees = models.IntegerField(blank=False, default=None, null=True) # newly added field
rs_eligible = models.BooleanField(blank=True, default=False) # needs to be deleted
eligiblestudents = ArrayField(
models.CharField(choices=ELIGIBLE_CHOICES, blank=False, max_length=10),
size=10,
default=list
)
pwd_eligible = models.BooleanField(blank=True, default=False) #newly added field
backlog_eligible = models.BooleanField(blank=True, default=False) #newly added field
psychometric_test = models.BooleanField(blank=True, default=False) #newly added field
medical_test = models.BooleanField(blank=True, default=False) #newly added field
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)
@ -325,8 +339,22 @@ class Internship(models.Model):
default=list
)
sophomore_eligible = models.BooleanField(blank=False, default=False)
rs_eligible = models.BooleanField(blank=False, default=False)
rs_eligible = models.BooleanField(blank=False, default=False) # needs to be deleted
eligiblestudents = ArrayField(
models.CharField(choices=ELIGIBLE_CHOICES, blank=False, max_length=10),
size=10,
default=list
)
tentative_no_of_offers = models.IntegerField(blank=False, default=None, null=True)
company_turnover = models.IntegerField(blank=True, default=None, null=True) # newly added field
establishment_date = models.DateField(blank=True, default=None, null=True) # newly added field
expected_no_of_offers = models.IntegerField(blank=True , default=None , null=True) # newly added
number_of_employees = models.IntegerField(blank=True, default=None, null=True) # newly added field
pwd_eligible = models.BooleanField(blank=True, default=False) #newly added field
backlog_eligible = models.BooleanField(blank=True, default=False) #newly added field
psychometric_test = models.BooleanField(blank=True, default=False) #newly added field
medical_test = models.BooleanField(blank=True, default=False) #newly added field
cpi_eligible = models.DecimalField(decimal_places=2, default=0.00, max_digits=4) #newly added field
is_stipend_description_pdf = models.BooleanField(blank=False, default=False)
stipend_description_pdf_names=ArrayField(
models.CharField(null=True, default=None, max_length=JNF_TEXT_MAX_CHARACTER_COUNT), size=5, default=list,

View File

@ -81,22 +81,22 @@ def precheck(required_data=None):
request_data = request.data
if not len(request_data):
request_data = request.POST
if len(request_data):
if request_data and len(request_data):
for i in required_data:
# print(i)
if i not in request_data:
return Response({'action': "Pre check", 'message': str(i) + " Not Found"},
status=status.HTTP_400_BAD_REQUEST)
else:
return Response({'action': "Pre check", 'message': "Message Data not Found"},
status=status.HTTP_400_BAD_REQUEST)
# print("Pre check: " + str(request_data))
return view_func(request, *args, **kwargs)
except:
# print what exception is
print(traceback.format_exc())
logger.warning("Pre check: " + str(sys.exc_info()))
return Response({'action': "Pre check", 'message': "Something went wrong"},
except Exception as e:
# Log the full traceback for debugging purposes
logger.error("Pre check error: %s", traceback.format_exc())
return Response({'action': "Pre check", 'message': "Something went wrong: " + str(e)},
status=status.HTTP_400_BAD_REQUEST)
return wrapper_func

7
start_backend_service.sh Normal file
View File

@ -0,0 +1,7 @@
#!/bin/bash
source /home/cdc/Desktop/CDC_Web_Portal_Backend/cdc-placement-website-backend/venv/bin/activate
cd /home/cdc/Desktop/CDC_Web_Portal_Backend/cdc-placement-website-backend/CDC_Backend
bash run_prod.sh