Skip to content

Commit

Permalink
chore: add filters + rework display of roles #198
Browse files Browse the repository at this point in the history
  • Loading branch information
bsilkyn committed Apr 7, 2024
1 parent 0e83335 commit 86c422b
Show file tree
Hide file tree
Showing 4 changed files with 159 additions and 152 deletions.
14 changes: 13 additions & 1 deletion backend/api/views/user_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,26 @@ def search(self, request: Request) -> Response:
self.pagination_class = BasicPagination

search = request.query_params.get("search", "")
identifier = request.query_params.get("id", "")
username = request.query_params.get("username", "")
email = request.query_params.get("email", "")

queryset1 = self.get_queryset().filter(
id__icontains=search
)
queryset2 = self.get_queryset().filter(
username__icontains=search
)
queryset3 = self.get_queryset().filter(
email__icontains=search
)
queryset1 = queryset1.union(queryset2, queryset3)
queryset = self.get_queryset().filter(
id__icontains=search,
id__icontains=identifier,
username__icontains=username,
email__icontains=email
)
queryset = queryset.intersection(queryset1)

serializer = self.serializer_class(self.paginate_queryset(queryset), many=True, context={
"request": request
Expand Down
154 changes: 77 additions & 77 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/src/types/filter/Filter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export const USER_FILTER = {
search: '',
id: '',
username: '',
email: ''
};
Expand Down
Loading

0 comments on commit 86c422b

Please sign in to comment.