-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add some filters to the volunteers list
- Loading branch information
Showing
6 changed files
with
80 additions
and
2 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,28 @@ | ||
from django.contrib.auth.models import User | ||
|
||
import django_filters | ||
|
||
from crowdsourcer.models import ResponseType | ||
|
||
|
||
def filter_not_empty(queryset, name, value): | ||
lookup = "__".join([name, "isnull"]) | ||
return queryset.filter(**{lookup: not value}) | ||
|
||
|
||
class VolunteerFilter(django_filters.FilterSet): | ||
has_assignments = django_filters.BooleanFilter( | ||
field_name="num_assignments", method=filter_not_empty, label="Has assignments" | ||
) | ||
marker__response_type = django_filters.ChoiceFilter( | ||
label="Stage", choices=ResponseType.choices() | ||
) | ||
# have to specify it like this otherwise bootstrap doesn't recognise it as a bound field | ||
username = django_filters.CharFilter(field_name="username", lookup_expr="icontains") | ||
|
||
class Meta: | ||
model = User | ||
fields = { | ||
"marker__response_type": ["exact"], | ||
"is_active": ["exact"], | ||
} |
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 |
---|---|---|
|
@@ -8,3 +8,9 @@ | |
margin-bottom: 0; | ||
} | ||
} | ||
|
||
#volunteer_filter { | ||
.btn-primary { | ||
margin-top: 2rem; | ||
} | ||
} |
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