Now we will deal with the views.py file which contains all the views which are related to the recruiters part of our app.
It is the longest part of the backend section of the Recruiters app since many things are working in this part and almost all the logic of the app is being written here. So, we will try to break these in small parts, taking a single function at a time and discussing it.
First up, we need to import various things, all of which has separate functions. We will discuss them when they are being used.
So, let’s start:-
This is a very simple function which has a simple work — to serve the recruiters’ details page.
This function is used to add a new job post. It requires a user to be logged in to be able to perform this function. It displays the NewJobForm and then parses details from the form and save it into the database. It then redirects it to the job list page.
This function is used to update an existing job post. It requires a user to be logged in to be able to perform this function. It displays the NewJobForm with an instance with the already existing details and then parses details from the form and save it into the database. It then redirects it to the job detail page.
This function is used to display the details of a particular job post. It is used to display the full information of the job post.
This function is used to get and display all the jobs posted by a recruiter. It also uses a paginator to restrict the job posts to 20 per page.
This function lets a recruiter search for candidates based on location and job type they are looking for. This is like an access to the resume database and the recruiter can scan through resumes of all the candidates. Location and job type help us provide more relevant candidates for recruiters.
This function is very similar to the intelligent search feature we had in the candidate’s section of our App. Now, we have a similar function here which does just the opposite work.
This function allows the recruiter to see candidates which are perfect matches to a particular job post. It works similarly and matches the skill set required for the job with the skill set of candidates. It also filters out candidates based on the job type.
Then it displays a list of candidates who are perfect matches for the job post to the recruiter in order of most perfect being first up.
This function is used to display the candidates who have applied for a particular job post. It first gets the applicants and then it gets the profile of all the applicants by filtering based on the applicant’s username.
This function is similar to the Applicants list but contains the applicant’s profile who have been selected from the applicant’s list by the recruiter.
This function is used to select an applicant from the Applicant’s list. It creates an object for that candidate in the selected list. It then deletes the candidate from the Applicants list after adding it to the Selected list.
This function is used to reject an applicant who has applied to a particular job post. It deletes the candidate from the Applicants list.
So, that sums up the views.py file of the Recruiters App. Here’s a look at the complete code:-
This content was originally published here.