UCL-ARC / shortlister

0 stars 0 forks source link

Add filtering of applicant list #50

Open tamuri opened 2 days ago

tamuri commented 2 days ago

(Need to think about this a bit more before starting...)

When viewing list of applicants, allow users to filter (or search) the list and only display applicants matching the specified filter.

The controller will need to break the coupling between self.shortlist.applicants and the applicant list we view. We could add a field self.selected_applicants: List[Applicant]. On start, this field points to the full list of applicants. Filtering will overwrite this field by finding matching applicants in the full list (i.e. self.shortlist.applicants) and adding them to the self.selected_applicants list.

There are, in principle, many ways we would want to filter the applicant list (different operations on applicants' names, scores, notes).

In the first iteration of this functionality, we could allow the user to write a Python condition that we would use to filter the list using eval. For example:

Enter your filter: 'Emma' in a.name 

We would take this input a get the matching applicants using:

self.selected_applicants = eval(f"[a for a in self.shortlist.applicants if {filter}]")

i.e. eval() would execute [a for a in self.shortlist.applicants if 'Emma' in a.name] and put the result in self.selected_applicants

There should be a command to clear the filter.