From aac7bf55d1f6f09146927b22becd434540d5ad91 Mon Sep 17 00:00:00 2001 From: Jaya Surya Date: Thu, 25 Jul 2024 19:58:26 +0530 Subject: [PATCH] changes for new config --- .DS_Store | Bin 8196 -> 8196 bytes .gitignore | 3 +- CDC_Backend/.DS_Store | Bin 8196 -> 10244 bytes CDC_Backend/APIs/constants.py | 1 + CDC_Backend/APIs/models.py | 4 +- CDC_Backend/APIs/studentViews.py | 18 +++++-- CDC_Backend/APIs/utils.py | 75 +++++++++++++++++----------- CDC_Backend/CDC_Backend/settings.py | 2 +- 8 files changed, 65 insertions(+), 38 deletions(-) diff --git a/.DS_Store b/.DS_Store index b4c80e42b4f70ae56b414c81b32c47570ccce153..a7251e0238e4afbe37dccdc04bc62655457f9194 100644 GIT binary patch delta 869 zcmZp1XmOa}XEU^hRb=42iL2NuSNZ<><>1SHrWX5Bh}MD5t*d;v)~yI(+3j4`%= z0SMR`^cd0^G8sx3G8jr3k|v7@%h#ic<)j-1C+Fval`}AKzQfd&oA2V1l#`zXl;JpF zwLU*v_?RO$RVhTMD#+kPwoYL3YJsGBR-h|08B!Qh84^)lqf-R52T2y$C6levm(@XB zf}#T93hXKhGLRi$0JLDTlc2QM1R)*{ z6oGw0Jj~4E29xatr6<1-;-73PtX9tq^h-WNGOAyso&&9d${-uBQ87O-2jUO7EW!_% zvY75?5NB{@$Yn?bhG7mvJVWv1Ga|g3%Y_dxaB3l zIa4rca-)#=<|H8nMivI!6Q3s62}w;}Ak4$Q*gSsiDxj{1!qSt^q43q28C)Mst`(A= ztR}+G$UiwjSd4=~kD-bolc8YpJ^}g3rXp(0;tZ~n4a6ijKNmT`xUuX4(`I&wZ!D8@ L#jG}#on-<5c}zJ} diff --git a/.gitignore b/.gitignore index 40fddbd..2208f8f 100644 --- a/.gitignore +++ b/.gitignore @@ -143,4 +143,5 @@ dmypy.json dev.env #vscode settings -.vscode/ \ No newline at end of file +.vscode/ +.DS_Store \ No newline at end of file diff --git a/CDC_Backend/.DS_Store b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t)_TvujBbCSu3(Jxl}t@=k7n!$4Y7k25*F29(MB1dWLOANYqRk87@Cap~5# zI?7BK&x|n7Mn+cT>7U!YE}JX^mI2FvWxz6E8F&R4m{vA=eE+|m{Qv(euo7#cWxz7< zUm0*xMZZ{p_R~wL_&|Ku?jc`6=ES(6l2QeQypD&I*YRlZbv)lKGB(4K6Y6;_hf3lN V(u@Byz@Go@`G5Cn^>sY|KLOqFtjGWW delta 140 zcmZn(XmOBWU|?W$DortDU;r^WfEYvza8E20o2aKK$^()I@)T4n*${l zvu|eSVBuio*}O!6g>kcjkR{_}PLa2h=ZT(}yg^)e@ 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") return True, "Conditions Satisfied" @@ -275,9 +276,17 @@ 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") + return True, "Conditions Satisfied" except PermissionError as e: @@ -410,6 +419,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 +472,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 = { diff --git a/CDC_Backend/CDC_Backend/settings.py b/CDC_Backend/CDC_Backend/settings.py index 174d9c7..ddddada 100644 --- a/CDC_Backend/CDC_Backend/settings.py +++ b/CDC_Backend/CDC_Backend/settings.py @@ -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 = [