Few Changes Done

This commit is contained in:
gowtham 2022-05-01 14:56:46 +05:30
parent 9881303969
commit d052e51df1
7 changed files with 69 additions and 57 deletions

View File

@ -288,7 +288,7 @@ def generateCSV(request, id, email, user_type):
row_details.append(apl.student.branch)
row_details.append(apl.student.batch)
row_details.append(apl.student.cpi)
link = LINK_TO_STORAGE_RESUME + urllib.parse.quote_plus(apl.student.id + "/" + apl.resume)
link = LINK_TO_STORAGE_RESUME + urllib.parse.quote(apl.student.id) + "/" + urllib.parse.quote(apl.resume)
row_details.append(link)
row_details.append(apl.selected)

View File

@ -15,7 +15,7 @@ logger = logging.getLogger('db')
IS_COMPENSATION_DETAILS_PDF,
ALLOWED_BRANCH, SELECTION_PROCEDURE_ROUNDS, SELECTION_PROCEDURE_DETAILS, IS_SELECTION_PROCEDURE_DETAILS_PDF,
TENTATIVE_DATE_OF_JOINING,
TENTATIVE_NO_OF_OFFERS, OTHER_REQUIREMENTS, RECAPTCHA_VALUE
TENTATIVE_NO_OF_OFFERS, OTHER_REQUIREMENTS, RECAPTCHA_VALUE
])
def addPlacement(request):
try:
@ -24,6 +24,7 @@ def addPlacement(request):
opening = Placement()
if not verify_recaptcha(data[RECAPTCHA_VALUE]):
raise Exception("Recaptcha Failed")
opening.id = generateRandomString()
# Add a company details in the opening
opening.company_name = data[COMPANY_NAME]
@ -32,12 +33,6 @@ def addPlacement(request):
opening.nature_of_business = data[NATURE_OF_BUSINESS]
opening.website = data[WEBSITE]
opening.company_details = data[COMPANY_DETAILS]
if data[IS_COMPANY_DETAILS_PDF] == "true":
opening.is_company_details_pdf = True
elif data[IS_COMPANY_DETAILS_PDF] == "false":
opening.is_company_details_pdf = False
else:
raise ValueError('Invalid value for is_company_details_pdf')
if opening.is_company_details_pdf:
company_details_pdf = []
@ -47,6 +42,13 @@ def addPlacement(request):
opening.company_details_pdf_names = company_details_pdf
if data[IS_COMPANY_DETAILS_PDF] == "true" and len(opening.company_details_pdf_names) > 0:
opening.is_company_details_pdf = True
elif data[IS_COMPANY_DETAILS_PDF] == "false" and len(opening.company_details_pdf_names) == 0:
opening.is_company_details_pdf = False
else:
raise ValueError('Invalid value for is_company_details_pdf')
# Add a contact person details in the opening
opening.contact_person_name = data[CONTACT_PERSON_NAME]
# Check if Phone number is Integer
@ -78,14 +80,6 @@ def addPlacement(request):
opening.designation = data[DESIGNATION]
opening.description = data[DESCRIPTION]
# Check if is_description_pdf is boolean
if data[IS_DESCRIPTION_PDF] == "true":
opening.is_description_pdf = True
elif data[IS_DESCRIPTION_PDF] == "false":
opening.is_description_pdf = False
else:
raise ValueError('Invalid value for is_description_pdf')
if opening.is_description_pdf:
description_pdf = []
for file in files.getlist(DESCRIPTION_PDF):
@ -94,6 +88,14 @@ def addPlacement(request):
opening.description_pdf_names = description_pdf
# Check if is_description_pdf is boolean
if data[IS_DESCRIPTION_PDF] == "true" and len(opening.description_pdf_names) > 0:
opening.is_description_pdf = True
elif data[IS_DESCRIPTION_PDF] == "false" and len(opening.description_pdf_names) == 0:
opening.is_description_pdf = False
else:
raise ValueError('Invalid value for is_description_pdf')
# Add a compensation details in the opening
# Check if compensation_ctc is integer
if data[COMPENSATION_CTC].isdigit():
@ -128,13 +130,6 @@ def addPlacement(request):
raise ValueError('Compensation Bonus must be an integer')
opening.compensation_details = data[COMPENSATION_DETAILS]
# Check if is_compensation_details_pdf is boolean
if data[IS_COMPENSATION_DETAILS_PDF] == "true":
opening.is_compensation_details_pdf = True
elif data[IS_COMPENSATION_DETAILS_PDF] == "false":
opening.is_compensation_details_pdf = False
else:
raise ValueError('Invalid value for is_compensation_details_pdf')
if opening.is_compensation_details_pdf:
compensation_details_pdf = []
@ -144,6 +139,14 @@ def addPlacement(request):
opening.compensation_details_pdf_names = compensation_details_pdf
# Check if is_compensation_details_pdf is boolean
if data[IS_COMPENSATION_DETAILS_PDF] == "true" and len(opening.compensation_details_pdf_names) > 0:
opening.is_compensation_details_pdf = True
elif data[IS_COMPENSATION_DETAILS_PDF] == "false" and len(opening.compensation_details_pdf_names) == 0:
opening.is_compensation_details_pdf = False
else:
raise ValueError('Invalid value for is_compensation_details_pdf')
opening.bond_details = data[BOND_DETAILS]
# Check if selection_procedure_rounds is list
@ -155,13 +158,6 @@ def addPlacement(request):
except:
raise ValueError('Selection Procedure Rounds must be a list')
opening.selection_procedure_details = data[SELECTION_PROCEDURE_DETAILS]
# Check if is_selection_procedure_details_pdf is boolean
if data[IS_SELECTION_PROCEDURE_DETAILS_PDF] == "true":
opening.is_selection_procedure_details_pdf = True
elif data[IS_SELECTION_PROCEDURE_DETAILS_PDF] == "false":
opening.is_selection_procedure_details_pdf = False
else:
raise ValueError('Invalid value for is_selection_procedure_pdf')
if opening.is_selection_procedure_details_pdf:
selection_procedure_details_pdf = []
@ -171,6 +167,16 @@ def addPlacement(request):
opening.selection_procedure_details_pdf_names = selection_procedure_details_pdf
# Check if is_selection_procedure_details_pdf is boolean
if data[IS_SELECTION_PROCEDURE_DETAILS_PDF] == "true" and len(
opening.selection_procedure_details_pdf_names) > 0:
opening.is_selection_procedure_details_pdf = True
elif data[IS_SELECTION_PROCEDURE_DETAILS_PDF] == "false" and len(
opening.selection_procedure_details_pdf_names) == 0:
opening.is_selection_procedure_details_pdf = False
else:
raise ValueError('Invalid value for is_selection_procedure_pdf')
stat, tier = getTier(opening.compensation_gross)
if stat:
opening.tier = tier
@ -296,4 +302,4 @@ def verifyEmail(request):
except:
logger.warning("Verify Email: " + str(sys.exc_info()))
return Response({'action': "Verify Email", 'message': "Something went wrong"},
status=status.HTTP_400_BAD_REQUEST)
status=status.HTTP_400_BAD_REQUEST)

View File

@ -40,9 +40,9 @@ CLIENT_ID = "956830229554-290mirc16pdhd5j7ph7v7ukibo4t1qcp.apps.googleuserconten
# To be Configured Properly
PLACEMENT_OPENING_URL = "https://www.googleapis.com/auth/adwords/{id}" # On frontend, this is the URL to be opened
LINK_TO_STORAGE_COMPANY_ATTACHMENT = "https://storage.googleapis.com/cdc-backend-attachments/company_attachments/"
LINK_TO_STORAGE_RESUME = "https://storage.googleapis.com/cdc-backend-attachments/resume/"
LINK_TO_APPLICATIONS_CSV = "https://storage.googleapis.com/cdc-backend-attachments/applications-csv/"
LINK_TO_STORAGE_COMPANY_ATTACHMENT = "http://localhost/storage/Company_Attachments/"
LINK_TO_STORAGE_RESUME = "http://localhost/storage/Resumes/"
LINK_TO_APPLICATIONS_CSV = "http://localhost/storage/Application_CSV/"
LINK_TO_EMAIl_VERIFICATION_API = "http://localhost:3000/company/verifyEmail?token={token}"
EMAIL = "email"

View File

@ -21,6 +21,7 @@ class Student(models.Model):
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)
cpi = models.DecimalField(decimal_places=2, max_digits=4)
can_apply = models.BooleanField(default=True)
def __str__(self):
return str(self.roll_no)
@ -39,11 +40,11 @@ class Placement(models.Model):
id = models.CharField(blank=False, primary_key=True, max_length=15)
# Company Details
company_name = models.CharField(blank=False, max_length=50)
address = models.CharField(blank=False, max_length=150)
address = models.CharField(blank=False, max_length=500)
company_type = models.CharField(blank=False, max_length=50)
nature_of_business = models.CharField(blank=False, max_length=50, default="")
website = models.CharField(blank=True, max_length=50)
company_details = models.CharField(blank=False, max_length=500, default=None, null=True)
company_details = models.CharField(max_length=500, default=None, null=True)
company_details_pdf_names = ArrayField(models.CharField(null=True, default=None, max_length=100), size=5, default=list, blank=True)
is_company_details_pdf = models.BooleanField(blank=False, default=False)
contact_person_name = models.CharField(blank=False, max_length=50)
@ -55,20 +56,20 @@ class Placement(models.Model):
pin_code = models.IntegerField(blank=False, default=None,null=True)
city_type = models.CharField(blank=False, max_length=15, choices=OFFER_CITY_TYPE)
# Job Details
designation = models.CharField(blank=False, max_length=25, default=None, null=True)
description = models.CharField(blank=False, max_length=200, default=None, null=True)
designation = models.CharField(blank=False, max_length=50, default=None, null=True)
description = models.CharField(blank=False, max_length=500, default=None, null=True)
description_pdf_names = ArrayField(models.CharField(null=True, default=None, max_length=100), size=5, default=list, blank=True)
is_description_pdf = models.BooleanField(blank=False, default=False)
compensation_CTC = models.IntegerField(blank=False, default=None, null=True ) # Job - Per Year
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)
compensation_details = models.CharField(blank=True, max_length=200, default=None, null=True)
compensation_details = models.CharField(blank=True, max_length=500, default=None, null=True)
compensation_details_pdf_names = ArrayField(models.CharField(null=True, default=None, max_length=100), size=5, default=list, blank=True)
is_compensation_details_pdf = models.BooleanField(blank=False, default=False)
bond_details = models.CharField(blank=True, max_length=200)
bond_details = models.CharField(blank=True, max_length=500)
selection_procedure_rounds = ArrayField(models.CharField(null=True, default=None, max_length=100), size=10, default=list, blank=True)
selection_procedure_details = models.CharField(blank=True, max_length=200)
selection_procedure_details = models.CharField(blank=True, max_length=500)
selection_procedure_details_pdf_names = ArrayField(models.CharField(null=True, default=None, max_length=100), size=5, default=list, blank=True)
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)

View File

@ -12,7 +12,7 @@ class StudentSerializer(serializers.ModelSerializer):
links = []
for i in obj.resumes:
ele = {}
ele['link'] = LINK_TO_STORAGE_RESUME + urllib.parse.quote_plus(obj.id + "/" + i)
ele['link'] = LINK_TO_STORAGE_RESUME + urllib.parse.quote(obj.id + "/" + i)
ele['name'] = i
links.append(ele)
return links
@ -45,7 +45,7 @@ class PlacementSerializerForStudent(serializers.ModelSerializer):
links = []
for pdf_name in obj.company_details_pdf_names:
ele = {}
link = LINK_TO_STORAGE_COMPANY_ATTACHMENT + urllib.parse.quote_plus(obj.id + "/" + pdf_name)
link = LINK_TO_STORAGE_COMPANY_ATTACHMENT + urllib.parse.quote(obj.id + "/" + pdf_name)
ele['link'] = link
ele['name'] = pdf_name
links.append(ele)
@ -55,7 +55,7 @@ class PlacementSerializerForStudent(serializers.ModelSerializer):
links = []
for pdf_name in obj.description_pdf_names:
ele = {}
link = LINK_TO_STORAGE_COMPANY_ATTACHMENT + urllib.parse.quote_plus(obj.id + "/" + pdf_name)
link = LINK_TO_STORAGE_COMPANY_ATTACHMENT + urllib.parse.quote(obj.id + "/" + pdf_name)
ele['link'] = link
ele['name'] = pdf_name
links.append(ele)
@ -65,7 +65,7 @@ class PlacementSerializerForStudent(serializers.ModelSerializer):
links = []
for pdf_name in obj.compensation_details_pdf_names:
ele = {}
link = LINK_TO_STORAGE_COMPANY_ATTACHMENT + urllib.parse.quote_plus(obj.id + "/" + pdf_name)
link = LINK_TO_STORAGE_COMPANY_ATTACHMENT + urllib.parse.quote(obj.id + "/" + pdf_name)
ele['link'] = link
ele['name'] = pdf_name
links.append(ele)
@ -75,7 +75,7 @@ class PlacementSerializerForStudent(serializers.ModelSerializer):
links = []
for pdf_name in obj.selection_procedure_details_pdf_names:
ele = {}
link = LINK_TO_STORAGE_COMPANY_ATTACHMENT + urllib.parse.quote_plus(obj.id + "/" + pdf_name)
link = LINK_TO_STORAGE_COMPANY_ATTACHMENT + urllib.parse.quote(obj.id + "/" + pdf_name)
ele['link'] = link
ele['name'] = pdf_name
links.append(ele)
@ -100,7 +100,7 @@ class PlacementSerializerForAdmin(serializers.ModelSerializer):
links = []
for pdf_name in obj.company_details_pdf_names:
ele = {}
link = LINK_TO_STORAGE_COMPANY_ATTACHMENT + urllib.parse.quote_plus(obj.id + "/" + pdf_name)
link = LINK_TO_STORAGE_COMPANY_ATTACHMENT + urllib.parse.quote(obj.id + "/" + pdf_name)
ele['link'] = link
ele['name'] = pdf_name
links.append(ele)
@ -110,7 +110,7 @@ class PlacementSerializerForAdmin(serializers.ModelSerializer):
links = []
for pdf_name in obj.description_pdf_names:
ele = {}
link = LINK_TO_STORAGE_COMPANY_ATTACHMENT + urllib.parse.quote_plus(obj.id + "/" + pdf_name)
link = LINK_TO_STORAGE_COMPANY_ATTACHMENT + urllib.parse.quote(obj.id + "/" + pdf_name)
ele['link'] = link
ele['name'] = pdf_name
links.append(ele)
@ -120,7 +120,7 @@ class PlacementSerializerForAdmin(serializers.ModelSerializer):
links = []
for pdf_name in obj.compensation_details_pdf_names:
ele = {}
link = LINK_TO_STORAGE_COMPANY_ATTACHMENT + urllib.parse.quote_plus(obj.id + "/" + pdf_name)
link = LINK_TO_STORAGE_COMPANY_ATTACHMENT + urllib.parse.quote(obj.id + "/" + pdf_name)
ele['link'] = link
ele['name'] = pdf_name
links.append(ele)
@ -130,7 +130,7 @@ class PlacementSerializerForAdmin(serializers.ModelSerializer):
links = []
for pdf_name in obj.selection_procedure_details_pdf_names:
ele = {}
link = LINK_TO_STORAGE_COMPANY_ATTACHMENT + urllib.parse.quote_plus(obj.id + "/" + pdf_name)
link = LINK_TO_STORAGE_COMPANY_ATTACHMENT + urllib.parse.quote(obj.id + "/" + pdf_name)
ele['link'] = link
ele['name'] = pdf_name
links.append(ele)
@ -153,7 +153,7 @@ class PlacementApplicationSerializer(serializers.ModelSerializer):
def get_resume_link(self, obj):
ele = {}
ele['link'] = LINK_TO_STORAGE_RESUME + urllib.parse.quote_plus(obj.id + "/" + obj.resume)
ele['link'] = LINK_TO_STORAGE_RESUME + urllib.parse.quote(obj.id + "/" + obj.resume)
ele['name'] = obj.resume
return ele
@ -171,7 +171,7 @@ class PlacementApplicationSerializerForAdmin(serializers.ModelSerializer):
return data
def get_resume_link(self, obj):
link = LINK_TO_STORAGE_RESUME + urllib.parse.quote_plus(obj.id + "/" + obj.resume)
link = LINK_TO_STORAGE_RESUME + urllib.parse.quote(obj.id + "/" + obj.resume)
return link
class Meta:

View File

@ -134,6 +134,9 @@ def submitApplication(request, id, email, user_type):
try:
data = request.data
student = get_object_or_404(Student, id=id)
if not student.can_apply:
return Response({'action': "Submit Application", 'message': "Student Can't Apply"},
status=status.HTTP_400_BAD_REQUEST)
# Only Allowing Applications for Placements
if data[OPENING_TYPE] == PLACEMENT:
if not len(PlacementApplication.objects.filter(

View File

@ -1,5 +1,5 @@
#user nobody;
user root;
worker_processes 1;
error_log logs/error.log;
@ -53,13 +53,15 @@ http {
# Server static files /storage
location /storage {
alias '/home/gowtham/Gowtham/Shared Projects/cdc-placement-website-backend/CDC_Backend/Storage';
# autoindex on;
alias '/home/gowtham/Gowtham/Projects/cdc-placement-website-backend/CDC_Backend/Storage/';
autoindex on;
autoindex_exact_size on;
}
location /static {
# autoindex on;
alias '/home/gowtham/Gowtham/Shared Projects/cdc-placement-website-backend/CDC_Backend/static';
autoindex on;
autoindex_exact_size on;
alias '/home/gowtham/Gowtham/Projects/cdc-placement-website-backend/CDC_Backend/static/';
}
location /api/ {