This commit is contained in:
Jaya Surya P 2024-08-04 11:56:13 +00:00 committed by GitHub
commit b6643d012f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 94 additions and 51 deletions

BIN
.DS_Store vendored

Binary file not shown.

1
.gitignore vendored
View File

@ -144,3 +144,4 @@ dev.env
#vscode settings #vscode settings
.vscode/ .vscode/
.DS_Store

BIN
CDC_Backend/.DS_Store vendored

Binary file not shown.

View File

@ -84,10 +84,8 @@ def addPlacement(request):
# Add a contact person details in the opening # Add a contact person details in the opening
opening.contact_person_name = data[CONTACT_PERSON_NAME] opening.contact_person_name = data[CONTACT_PERSON_NAME]
# Check if Phone number is Integer # Check if Phone number is Integer
if data[PHONE_NUMBER].isdigit():
opening.phone_number = int(data[PHONE_NUMBER]) opening.phone_number = data[PHONE_NUMBER]
else:
raise ValueError('Phone number should be integer')
opening.email = data[EMAIL] opening.email = data[EMAIL]

View File

@ -10,6 +10,7 @@ BRANCH_CHOICES = [
['EP', 'EP'], ['EP', 'EP'],
['CIVIL', 'CIVIL'], ['CIVIL', 'CIVIL'],
['CHEMICAL', 'CHEMICAL'], ['CHEMICAL', 'CHEMICAL'],
['MNC','MNC']
] ]
ELIGIBLE_CHOICES = [ ELIGIBLE_CHOICES = [
["Btech", "Btech"], ["Btech", "Btech"],
@ -41,6 +42,7 @@ BATCHES = [ #change it accordingly
"2020", "2020",
] ]
BATCH_CHOICES = [ BATCH_CHOICES = [
["2023","2023"],
["2022", "2022"], ["2022", "2022"],
["2021", "2021"], ["2021", "2021"],
["2020", "2020"], ["2020", "2020"],
@ -65,7 +67,8 @@ TIERS = [
['7', 'Tier 7'], ['7', 'Tier 7'],
['8', 'Open Tier'], ['8', 'Open Tier'],
] ]
bTech = 'Btech'
# not being used anywhere
DEGREE_CHOICES = [ DEGREE_CHOICES = [
['bTech', 'B.Tech'], ['bTech', 'B.Tech'],
['ms/phd', 'MS/ PhD'], ['ms/phd', 'MS/ PhD'],
@ -83,7 +86,10 @@ CDC_REPS_EMAILS = [
"satyapriya.gupta@iitdh.ac.in", "satyapriya.gupta@iitdh.ac.in",
"dhriti.ghosh@iitdh.ac.in", "dhriti.ghosh@iitdh.ac.in",
"suvamay.jana@iitdh.ac.in", "suvamay.jana@iitdh.ac.in",
"ramesh.nayaka@iitdh.ac.in" "ramesh.nayaka@iitdh.ac.in",
"210010003@iitdh.ac.in",
"210010046@iitdh.ac.in",
"210030035@iitdh.ac.in",
] ]
CDC_REPS_EMAILS_FOR_ISSUE=[ #add reps emails CDC_REPS_EMAILS_FOR_ISSUE=[ #add reps emails
"cdc.support@iitdh.ac.in", "cdc.support@iitdh.ac.in",

View File

@ -32,9 +32,9 @@ class Student(models.Model):
default=list, blank=True) 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')
can_apply_internship = models.BooleanField(default=True, verbose_name='Internship Registered') #added for internship can_apply_internship = models.BooleanField(default=True, verbose_name='Internship Registered')
changed_by = models.ForeignKey(User, blank=True, on_delete=models.RESTRICT, default=None, null=True) changed_by = models.ForeignKey(User, blank=True, on_delete=models.RESTRICT, default=None, null=True)
degree = models.CharField(choices=DEGREE_CHOICES, blank=False, max_length=10, default=DEGREE_CHOICES[0][0]) degree = models.CharField(choices=ELIGIBLE_CHOICES, blank=False, max_length=10, default=ELIGIBLE_CHOICES[0][0]) # should be ELIGIBLE_CHOICES
isPwd = models.BooleanField(default=False, verbose_name='Person with Disability') isPwd = models.BooleanField(default=False, verbose_name='Person with Disability')
isBacklog = models.BooleanField(default=False, verbose_name='Has Backlog') isBacklog = models.BooleanField(default=False, verbose_name='Has Backlog')
history = HistoricalRecords(user_model=User) history = HistoricalRecords(user_model=User)
@ -92,7 +92,7 @@ class Placement(models.Model):
default=list, blank=True) 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=JNF_TEXT_MAX_CHARACTER_COUNT) contact_person_name = models.CharField(blank=False, max_length=JNF_TEXT_MAX_CHARACTER_COUNT)
phone_number = models.PositiveBigIntegerField(blank=False) phone_number = models.CharField(max_length=15, blank=False)
email = models.CharField(blank=False, max_length=JNF_SMALLTEXT_MAX_CHARACTER_COUNT, default="") email = models.CharField(blank=False, max_length=JNF_SMALLTEXT_MAX_CHARACTER_COUNT, default="")
city = models.CharField(blank=False, max_length=JNF_SMALLTEXT_MAX_CHARACTER_COUNT, default="") city = models.CharField(blank=False, max_length=JNF_SMALLTEXT_MAX_CHARACTER_COUNT, default="")
state = models.CharField(blank=False, max_length=JNF_SMALLTEXT_MAX_CHARACTER_COUNT, default="") state = models.CharField(blank=False, max_length=JNF_SMALLTEXT_MAX_CHARACTER_COUNT, default="")
@ -383,7 +383,7 @@ class Internship(models.Model):
is_selection_procedure_details_pdf = models.BooleanField(blank=False, default=False) is_selection_procedure_details_pdf = models.BooleanField(blank=False, default=False)
#contact details of company person #contact details of company person
contact_person_name = models.CharField(blank=False, max_length=JNF_TEXT_MAX_CHARACTER_COUNT) contact_person_name = models.CharField(blank=False, max_length=JNF_TEXT_MAX_CHARACTER_COUNT)
phone_number = models.PositiveBigIntegerField(blank=False) phone_number = models.CharField(max_length=15, blank=False)
email = models.EmailField(blank=False) email = models.EmailField(blank=False)
# contact_person_designation = models.CharField(blank=False, max_length=JNF_SMALLTEXT_MAX_CHARACTER_COUNT, default="") # contact_person_designation = models.CharField(blank=False, max_length=JNF_SMALLTEXT_MAX_CHARACTER_COUNT, default="")
# telephone_number = models.PositiveBigIntegerField(blank=True, default=None, null=True) # telephone_number = models.PositiveBigIntegerField(blank=True, default=None, null=True)

View File

@ -1,4 +1,6 @@
from datetime import datetime as dt
from rest_framework.decorators import api_view from rest_framework.decorators import api_view
from django.db.models import Q
from .serializers import * from .serializers import *
from .utils import * from .utils import *
@ -48,7 +50,6 @@ def refresh(request):
@isAuthorized(allowed_users=[STUDENT]) @isAuthorized(allowed_users=[STUDENT])
def studentProfile(request, id, email, user_type): def studentProfile(request, id, email, user_type):
try: try:
#print(id)
studentDetails = get_object_or_404(Student, id=id) studentDetails = get_object_or_404(Student, id=id)
data = StudentSerializer(studentDetails).data data = StudentSerializer(studentDetails).data
@ -101,10 +102,18 @@ def getDashboard(request, id, email, user_type):
try: try:
studentDetails = get_object_or_404(Student, id=id) studentDetails = get_object_or_404(Student, id=id)
placements = Placement.objects.filter(allowed_batch__contains=[studentDetails.batch], filters = Q(
allowed_branch__contains=[studentDetails.branch], allowed_branch__contains=[studentDetails.branch],
deadline_datetime__gte=datetime.datetime.now(), eligiblestudents__contains=[studentDetails.degree],
offer_accepted=True, email_verified=True).order_by('deadline_datetime') deadline_datetime__gte=dt.now(),
offer_accepted=True,
email_verified=True
)
if studentDetails.degree == 'Btech':
filters &= Q(allowed_batch__contains=[studentDetails.batch])
placements = Placement.objects.filter(filters).order_by('deadline_datetime')
filtered_placements = placement_eligibility_filters(studentDetails, placements) filtered_placements = placement_eligibility_filters(studentDetails, placements)
placementsdata = PlacementSerializerForStudent(filtered_placements, many=True).data placementsdata = PlacementSerializerForStudent(filtered_placements, many=True).data

View File

@ -238,31 +238,38 @@ def PlacementApplicationConditions(student, placement):
PPO_PSU = [i for i in PPO if i.tier == 'psu'] PPO_PSU = [i for i in PPO if i.tier == 'psu']
# find length of PPO # find length of PPO
if len(selected_companies) + len(PPO) >= MAX_OFFERS_PER_STUDENT: if len(selected_companies) + len(PPO) >= MAX_OFFERS_PER_STUDENT:
raise PermissionError("Max Applications Reached for the Season") raise PermissionError("Max Applications Reached for the Season1")
if len(selected_companies_PSU) > 0: if len(selected_companies_PSU) > 0:
raise PermissionError('Selected for PSU Can\'t apply anymore') raise PermissionError('Selected for PSU Can\'t apply anymore2')
if len(PPO_PSU) > 0: if len(PPO_PSU) > 0:
raise PermissionError('Selected for PSU Can\'t apply anymore') raise PermissionError('Selected for PSU Can\'t apply anymore3')
if placement.tier == 'psu': if placement.tier == 'psu':
return True, "Conditions Satisfied" return True, "Conditions Satisfied"
for i in selected_companies: for i in selected_companies:
if int(i.placement.tier) != 1 and int(i.placement.tier) <= int(placement.tier): if 1.5 * i.placement.compensation_CTC > placement.compensation_CTC:
return False, "Can't apply for this tier" return False, "Can't apply for this Placement, 1.5 times CTC condition not satisfied"
elif int(i.placement.tier) == 1 and int(placement.tier) != 1:
return False, "Can't apply for this tier"
for i in PPO: for i in PPO:
if int(i.tier) != 1 and int(i.tier) <= int(placement.tier): if 1.5 * i.compensation > placement.compensation_CTC:
return False, "Can't apply for this tier" return False, "Can't apply for this Placement, 1.5 times CTC condition not satisfied"
elif int(i.tier) == 1 and int(placement.tier) != 1: if student.degree not in placement.eligiblestudents:
return False, "Can't apply for this tier" raise PermissionError("Can't apply for this placement4")
if student.degree == bTech and student.batch not in placement.allowed_batch:
if student.degree != 'bTech' and not placement.rs_eligible: raise PermissionError("Can't apply for this placement5")
raise PermissionError("Can't apply for this placement") if student.branch not in placement.allowed_branch:
raise PermissionError("Can't apply for this placement6")
if student.can_apply == False:
raise PermissionError("Can't apply for this placement7")
if student.isBacklog == True and placement.backlog_eligible == False:
raise PermissionError("Can't apply for this placement8")
if student.isPwd == True and placement.pwd_eligible == False:
raise PermissionError("Can't apply for this placement9")
if placement.cpi_eligible > student.cpi:
raise PermissionError("Can't apply for this placement10")
return True, "Conditions Satisfied" return True, "Conditions Satisfied"
@ -275,9 +282,23 @@ def PlacementApplicationConditions(student, placement):
def InternshipApplicationConditions(student, internship): def InternshipApplicationConditions(student, internship):
try: try:
selected_companies = InternshipApplication.objects.filter(student=student, selected=True) selected_companies = InternshipApplication.objects.filter(student=student, selected=True)
if len(selected_companies)>=1: if len(selected_companies) >= 1:
# print("selected companies > 1")
return False, "You have already secured a Internship" return False, "You have already secured a Internship"
if student.degree not in internship.eligiblestudents:
raise PermissionError("Can't apply for this Internship")
if student.branch not in internship.allowed_branch:
raise PermissionError("Can't apply for this Internship")
if student.degree == 'bTech' and student.batch not in internship.allowed_batch:
raise PermissionError("Can't apply for this Internship")
if student.can_apply_internship == False:
raise PermissionError("Can't apply for this Internship")
if student.isBacklog == True and internship.backlog_eligible == False:
raise PermissionError("Can't apply for this Internship")
if student.isPwd == True and internship.pwd_eligible == False:
raise PermissionError("Can't apply for this Internship")
if internship.cpi_eligible > student.cpi:
raise PermissionError("Can't apply for this Internship")
return True, "Conditions Satisfied" return True, "Conditions Satisfied"
except PermissionError as e: except PermissionError as e:
@ -410,6 +431,8 @@ def placement_eligibility_filters(student, placements):
except: except:
logger.warning("Utils - placement_eligibility_filters: " + str(sys.exc_info())) logger.warning("Utils - placement_eligibility_filters: " + str(sys.exc_info()))
return placements return placements
def internship_eligibility_filters(student, internships): def internship_eligibility_filters(student, internships):
try: try:
filtered_internships = [] filtered_internships = []
@ -461,42 +484,48 @@ def send_opening_notifications(opening_id, opening_type=PLACEMENT):
logger.warning('Utils - send_opening_notifications: ' + str(sys.exc_info())) logger.warning('Utils - send_opening_notifications: ' + str(sys.exc_info()))
return False return False
def get_eligible_emails(opening_id, opening_type=PLACEMENT,send_all=False):
def get_eligible_emails(opening_id, opening_type='PLACEMENT', send_all=False):
try: try:
# print(opening_id, opening_type) if opening_type == 'PLACEMENT':
if opening_type == PLACEMENT:
opening = get_object_or_404(Placement, id=opening_id) opening = get_object_or_404(Placement, id=opening_id)
else: else:
opening = get_object_or_404(Internship, id=opening_id) opening = get_object_or_404(Internship, id=opening_id)
emails=[]
emails = []
students = Student.objects.all() students = Student.objects.all()
for student in students.iterator(): for student in students.iterator():
if student.branch in opening.allowed_branch: if student.branch in opening.allowed_branch and student.degree in opening.eligiblestudents:
if student.degree == 'bTech' or opening.rs_eligible is True: if student.degree == 'Btech' and student.batch in opening.allowed_batch:
if (isinstance(opening,Placement) and PlacementApplicationConditions(student, opening)[0]) or ( if (isinstance(opening, Placement) and PlacementApplicationConditions(student, opening)[0]) or (
isinstance(opening,Internship) and InternshipApplicationConditions(student, opening)[0]): isinstance(opening, Internship) and InternshipApplicationConditions(student, opening)[0]):
try: if (opening_type == 'PLACEMENT' and student.can_apply) or (
opening_type == 'INTERNSHIP' and student.can_apply_internship):
student_user = get_object_or_404(User, id=student.id) student_user = get_object_or_404(User, id=student.id)
#if send_all True send all students eligible for the opening
# if send_all True send all students eligible for the opening
if send_all: if send_all:
emails.append(student_user.email) emails.append(student_user.email)
continue continue
# check if he applied
if opening_type == PLACEMENT: # check if the student applied
if opening_type == 'PLACEMENT':
if PlacementApplication.objects.filter(student=student, placement=opening).exists(): if PlacementApplication.objects.filter(student=student, placement=opening).exists():
continue continue
else: else:
if InternshipApplication.objects.filter(student=student, internship=opening).exists(): if InternshipApplication.objects.filter(student=student, internship=opening).exists():
continue continue
emails.append(student_user.email) emails.append(student_user.email)
except Exception as e:
logger.warning('Utils - send_opening_notifications: For Loop' + str(e))
return False, []
return True, emails return True, emails
except:
logger.warning('Utils - send_opening_notifications: ' + str(sys.exc_info())) except Exception as e:
logger.warning('Utils - send_opening_notifications: ' + str(e))
return False, [] return False, []
def exception_email(opening): def exception_email(opening):
opening = opening.dict() opening = opening.dict()
data = { data = {

View File

@ -30,7 +30,7 @@ DEBUG = os.environ.get('DEBUG') == "True"
ALLOWED_HOSTS = ['cdc.iitdh.ac.in', 'localhost'] ALLOWED_HOSTS = ['cdc.iitdh.ac.in', 'localhost']
ADMINS = [ ('Karthik Mv', '200010030@iitdh.ac.in')] ADMINS = [ ('Jaya Surya', '210020040@iitdh.ac.in')]
# Application definition # Application definition
INSTALLED_APPS = [ INSTALLED_APPS = [