generated from ita-social-projects/DevTemplate
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a modal window for server-side error handling
- Loading branch information
Showing
11 changed files
with
354 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from django_filters import filters | ||
from django_filters.rest_framework import FilterSet | ||
|
||
|
||
class UsersFilter(FilterSet): | ||
""" | ||
Filters | ||
/?id= , /?surname=, /?email= , /?is_active= , /?is_staff=, | ||
/?is_superuser=, /?is_deleted=True or False, /?company_name=, /?registration_date=, | ||
Ordering sample | ||
/?ordering=id asc or /?ordering=-id desc | ||
""" | ||
|
||
id = filters.CharFilter(lookup_expr="icontains") | ||
surname = filters.CharFilter(lookup_expr="icontains") | ||
email = filters.CharFilter(lookup_expr="icontains") | ||
is_active = filters.CharFilter(lookup_expr="icontains") | ||
is_staff = filters.CharFilter(lookup_expr="icontains") | ||
is_superuser = filters.CharFilter(lookup_expr="icontains") | ||
is_deleted = filters.BooleanFilter(method="filter_is_deleted") | ||
company_name = filters.CharFilter( | ||
field_name="profile__name", lookup_expr="icontains" | ||
) | ||
registration_date = filters.CharFilter( | ||
field_name="profile__created_at", lookup_expr="icontains" | ||
) | ||
|
||
def filter_is_deleted(self, queryset, name, value): | ||
if value: | ||
queryset = queryset.filter(email__startswith="is_deleted_") | ||
return queryset | ||
|
||
ordering = filters.OrderingFilter( | ||
fields=( | ||
("id", "id"), | ||
("name", "name"), | ||
("surname", "surname"), | ||
("email", "email"), | ||
("is_active", "is_active"), | ||
("is_staff", "is_staff"), | ||
("is_superuser", "is_superuser"), | ||
("is_deleted", "is_deleted"), | ||
("profile__name", "company_name"), | ||
("profile__created_at", "registration_date"), | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.