Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to filter users with no home facility #2332

Merged
merged 4 commits into from
Aug 21, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions care/users/api/viewsets/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,13 @@
)
last_login = filters.DateFromToRangeFilter(field_name="last_login")
district_id = filters.NumberFilter(field_name="district_id", lookup_expr="exact")
home_facility = filters.UUIDFilter(
field_name="home_facility__external_id", lookup_expr="exact"
)
home_facility = filters.CharFilter(method="filter_home_facility")

def filter_home_facility(self, queryset, name, value):
if value == "NONE":
return queryset.filter(home_facility__isnull=True)
return queryset.filter(home_facility__external_id=value)

Check warning on line 65 in care/users/api/viewsets/users.py

View check run for this annotation

Codecov / codecov/patch

care/users/api/viewsets/users.py#L64-L65

Added lines #L64 - L65 were not covered by tests

last_active_days = filters.CharFilter(method="last_active_after")

def get_user_type(
Expand Down