@@ -210,4 +210,48 @@ def change_application_status_to_under_review(db: Session = Depends(dependencies
210210
211211# PATCH /applications/{job_id}_{applicant_id}/offer change status to offer sent
212212
213- # PATCH /applications/ applicationId}/rejected change status to rejected
213+ def change_application_status_to_offer_sent (db : Session = Depends (dependencies .get_db ),
214+ job_id : int = Path (),
215+ applicant_id : int = Path (),
216+ recruiter : user_model .User = Depends (dependencies .get_current_recruiter_user )):
217+
218+ application = user_profile_job_crud .get_application_by_user_id_and_job_id (db , applicant_id , job_id )
219+
220+ if application is None :
221+ raise HTTPException (status_code = status .HTTP_404_NOT_FOUND ,
222+ detail = f"Application for applicant { applicant_id } and job { job_id } not found." )
223+
224+ # check if the recruiter owns the job
225+ if application .job .user_profile_id != recruiter .id :
226+ raise HTTPException (status_code = status .HTTP_401_UNAUTHORIZED ,
227+ detail = f"Recruiter is not authorized to change the status of application { application .id } ." )
228+ else :
229+ user_profile_job_model .UserProfileJob .application_status_id = application_status_model .ApplicationStatusEnum .offer_sent
230+ status_to_offer_sent = user_profile_job_model .UserProfileJob .application_status_id
231+
232+ #TODO : Save to database using db.save()
233+ return user_profile_job_crud .update_applicant_application_status (db , applicant_id , job_id , status_to_offer_sent )
234+
235+ # PATCH /applications/ applicationId}/rejected change status to rejected
236+
237+ def change_application_status_to_rejected (db : Session = Depends (dependencies .get_db ),
238+ job_id : int = Path (),
239+ applicant_id : int = Path (),
240+ recruiter : user_model .User = Depends (dependencies .get_current_recruiter_user )):
241+
242+ application = user_profile_job_crud .get_application_by_user_id_and_job_id (db , applicant_id , job_id )
243+
244+ if application is None :
245+ raise HTTPException (status_code = status .HTTP_404_NOT_FOUND ,
246+ detail = f"Application for applicant { applicant_id } and job { job_id } not found." )
247+
248+ # check if the recruiter owns the job
249+ if application .job .user_profile_id != recruiter .id :
250+ raise HTTPException (status_code = status .HTTP_401_UNAUTHORIZED ,
251+ detail = f"Recruiter is not authorized to change the status of application { application .id } ." )
252+ else :
253+ user_profile_job_model .UserProfileJob .application_status_id = application_status_model .ApplicationStatusEnum .rejected
254+ status_to_rejected = user_profile_job_model .UserProfileJob .application_status_id
255+
256+ #TODO : Save to database using db.save()
257+ return user_profile_job_crud .update_applicant_application_status (db , applicant_id , job_id , status_to_rejected )
0 commit comments