Merge c2ebf5a600
into 18f509e6a4
This commit is contained in:
commit
efcc72c50e
|
@ -144,3 +144,4 @@ dev.env
|
|||
|
||||
#vscode settings
|
||||
.vscode/
|
||||
.DS_Store
|
Binary file not shown.
|
@ -66,6 +66,7 @@ TIERS = [
|
|||
['8', 'Open Tier'],
|
||||
]
|
||||
|
||||
# not being used anywhere
|
||||
DEGREE_CHOICES = [
|
||||
['bTech', 'B.Tech'],
|
||||
['ms/phd', 'MS/ PhD'],
|
||||
|
|
|
@ -32,9 +32,9 @@ class Student(models.Model):
|
|||
default=list, blank=True)
|
||||
cpi = models.DecimalField(decimal_places=2, max_digits=4)
|
||||
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)
|
||||
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')
|
||||
isBacklog = models.BooleanField(default=False, verbose_name='Has Backlog')
|
||||
history = HistoricalRecords(user_model=User)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from rest_framework.decorators import api_view
|
||||
from django.db.models import Q
|
||||
|
||||
from .serializers import *
|
||||
from .utils import *
|
||||
|
@ -48,7 +49,6 @@ def refresh(request):
|
|||
@isAuthorized(allowed_users=[STUDENT])
|
||||
def studentProfile(request, id, email, user_type):
|
||||
try:
|
||||
#print(id)
|
||||
studentDetails = get_object_or_404(Student, id=id)
|
||||
|
||||
data = StudentSerializer(studentDetails).data
|
||||
|
@ -101,10 +101,18 @@ def getDashboard(request, id, email, user_type):
|
|||
try:
|
||||
studentDetails = get_object_or_404(Student, id=id)
|
||||
|
||||
placements = Placement.objects.filter(allowed_batch__contains=[studentDetails.batch],
|
||||
filters = Q(
|
||||
allowed_branch__contains=[studentDetails.branch],
|
||||
deadline_datetime__gte=datetime.datetime.now(),
|
||||
offer_accepted=True, email_verified=True).order_by('deadline_datetime')
|
||||
eligiblestudents__contains=[studentDetails.degree],
|
||||
deadline_datetime__gte=datetime.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)
|
||||
|
||||
placementsdata = PlacementSerializerForStudent(filtered_placements, many=True).data
|
||||
|
|
|
@ -250,18 +250,25 @@ def PlacementApplicationConditions(student, placement):
|
|||
return True, "Conditions Satisfied"
|
||||
|
||||
for i in selected_companies:
|
||||
if int(i.placement.tier) != 1 and int(i.placement.tier) <= int(placement.tier):
|
||||
return False, "Can't apply for this tier"
|
||||
elif int(i.placement.tier) == 1 and int(placement.tier) != 1:
|
||||
return False, "Can't apply for this tier"
|
||||
if 1.5 * i.compensation_CTC > placement.compensation_CTC:
|
||||
return False, "Can't apply for this Placement, 1.5 times CTC condition not satisfied"
|
||||
|
||||
for i in PPO:
|
||||
if int(i.tier) != 1 and int(i.tier) <= int(placement.tier):
|
||||
return False, "Can't apply for this tier"
|
||||
elif int(i.tier) == 1 and int(placement.tier) != 1:
|
||||
return False, "Can't apply for this tier"
|
||||
|
||||
if student.degree != 'bTech' and not placement.rs_eligible:
|
||||
if 1.5 * i.compensation_CTC > placement.compensation_CTC:
|
||||
return False, "Can't apply for this Placement, 1.5 times CTC condition not satisfied"
|
||||
if student.degree not in placement.eligiblestudents:
|
||||
raise PermissionError("Can't apply for this placement")
|
||||
if student.degree == 'bTech' and student.batch not in placement.allowed_batch:
|
||||
raise PermissionError("Can't apply for this placement")
|
||||
if student.branch not in placement.allowed_branch:
|
||||
raise PermissionError("Can't apply for this placement")
|
||||
if student.can_apply == False:
|
||||
raise PermissionError("Can't apply for this placement")
|
||||
if student.isBacklog == True and placement.backlog_eligible == False:
|
||||
raise PermissionError("Can't apply for this placement")
|
||||
if student.isPwd == True and placement.pwd_eligible == False:
|
||||
raise PermissionError("Can't apply for this placement")
|
||||
if placement.cpi_eligible > student.cpi:
|
||||
raise PermissionError("Can't apply for this placement")
|
||||
|
||||
return True, "Conditions Satisfied"
|
||||
|
@ -275,9 +282,23 @@ def PlacementApplicationConditions(student, placement):
|
|||
def InternshipApplicationConditions(student, internship):
|
||||
try:
|
||||
selected_companies = InternshipApplication.objects.filter(student=student, selected=True)
|
||||
if len(selected_companies)>=1:
|
||||
# print("selected companies > 1")
|
||||
if len(selected_companies) >= 1:
|
||||
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"
|
||||
|
||||
except PermissionError as e:
|
||||
|
@ -410,6 +431,8 @@ def placement_eligibility_filters(student, placements):
|
|||
except:
|
||||
logger.warning("Utils - placement_eligibility_filters: " + str(sys.exc_info()))
|
||||
return placements
|
||||
|
||||
|
||||
def internship_eligibility_filters(student, internships):
|
||||
try:
|
||||
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()))
|
||||
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:
|
||||
# print(opening_id, opening_type)
|
||||
if opening_type == PLACEMENT:
|
||||
if opening_type == 'PLACEMENT':
|
||||
opening = get_object_or_404(Placement, id=opening_id)
|
||||
else:
|
||||
opening = get_object_or_404(Internship, id=opening_id)
|
||||
emails=[]
|
||||
|
||||
emails = []
|
||||
students = Student.objects.all()
|
||||
|
||||
for student in students.iterator():
|
||||
if student.branch in opening.allowed_branch:
|
||||
if student.degree == 'bTech' or opening.rs_eligible is True:
|
||||
if (isinstance(opening,Placement) and PlacementApplicationConditions(student, opening)[0]) or (
|
||||
isinstance(opening,Internship) and InternshipApplicationConditions(student, opening)[0]):
|
||||
try:
|
||||
if student.branch in opening.allowed_branch and student.degree in opening.eligiblestudents:
|
||||
if student.degree == 'Btech' and student.batch in opening.allowed_batch:
|
||||
if (isinstance(opening, Placement) and PlacementApplicationConditions(student, opening)[0]) or (
|
||||
isinstance(opening, Internship) and InternshipApplicationConditions(student, opening)[0]):
|
||||
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)
|
||||
#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:
|
||||
emails.append(student_user.email)
|
||||
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():
|
||||
continue
|
||||
else:
|
||||
if InternshipApplication.objects.filter(student=student, internship=opening).exists():
|
||||
continue
|
||||
|
||||
emails.append(student_user.email)
|
||||
except Exception as e:
|
||||
logger.warning('Utils - send_opening_notifications: For Loop' + str(e))
|
||||
return False, []
|
||||
|
||||
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, []
|
||||
|
||||
|
||||
def exception_email(opening):
|
||||
opening = opening.dict()
|
||||
data = {
|
||||
|
|
|
@ -30,7 +30,7 @@ DEBUG = os.environ.get('DEBUG') == "True"
|
|||
|
||||
ALLOWED_HOSTS = ['cdc.iitdh.ac.in', 'localhost']
|
||||
|
||||
ADMINS = [ ('Karthik Mv', '200010030@iitdh.ac.in')]
|
||||
ADMINS = [ ('Jaya Surya', '210020040@iitdh.ac.in')]
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = [
|
||||
|
|
Loading…
Reference in New Issue