-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #524 from open5e/523-add-document-filter-to-all-v2…
…-endpoints Adding filter to all relevant document endpoints.
- Loading branch information
Showing
9 changed files
with
97 additions
and
106 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
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 |
---|---|---|
@@ -1,16 +1,26 @@ | ||
from rest_framework import viewsets | ||
|
||
from django_filters import FilterSet | ||
|
||
from api_v2 import models | ||
from api_v2 import serializers | ||
|
||
|
||
class ConditionFilterSet(FilterSet): | ||
class Meta: | ||
model = models.Condition | ||
fields = { | ||
'key': ['in', 'iexact', 'exact' ], | ||
'name': ['iexact', 'exact','contains'], | ||
'document__key': ['in','iexact','exact'], | ||
} | ||
|
||
|
||
class ConditionViewSet(viewsets.ReadOnlyModelViewSet): | ||
""" | ||
list: API endpoint for returning a list of conditions. | ||
retrieve: API endpoint for returning a particular condition. | ||
""" | ||
queryset = models.Condition.objects.all().order_by('pk') | ||
serializer_class = serializers.ConditionSerializer | ||
|
||
|
||
|
||
filterset_class = ConditionFilterSet |
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 |
---|---|---|
@@ -1,16 +1,26 @@ | ||
from rest_framework import viewsets | ||
|
||
from django_filters import FilterSet | ||
|
||
from api_v2 import models | ||
from api_v2 import serializers | ||
|
||
|
||
class DamageTypeFilterSet(FilterSet): | ||
class Meta: | ||
model = models.DamageType | ||
fields = { | ||
'key': ['in', 'iexact', 'exact' ], | ||
'name': ['iexact', 'exact','contains'], | ||
'document__key': ['in','iexact','exact'], | ||
} | ||
|
||
|
||
class DamageTypeViewSet(viewsets.ReadOnlyModelViewSet): | ||
""" | ||
list: API endpoint for returning a list of damage types. | ||
retrieve: API endpoint for returning a particular damage type. | ||
""" | ||
queryset = models.DamageType.objects.all().order_by('pk') | ||
serializer_class = serializers.DamageTypeSerializer | ||
|
||
|
||
|
||
filterset_class = DamageTypeFilterSet |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,29 @@ | ||
from rest_framework import viewsets | ||
|
||
from django_filters import FilterSet | ||
|
||
from api_v2 import models | ||
from api_v2 import serializers | ||
|
||
|
||
class SizeFilterSet(FilterSet): | ||
class Meta: | ||
model = models.Size | ||
fields = { | ||
'key': ['in', 'iexact', 'exact' ], | ||
'name': ['iexact', 'exact','contains'], | ||
'document__key': ['in','iexact','exact'], | ||
} | ||
|
||
|
||
class SizeViewSet(viewsets.ReadOnlyModelViewSet): | ||
""" | ||
list: API endpoint for returning a list of damage types. | ||
retrieve: API endpoint for returning a particular damage type. | ||
""" | ||
queryset = models.Size.objects.all().order_by('pk') | ||
serializer_class = serializers.SizeSerializer | ||
filterset_class = SizeFilterSet | ||
|
||
|
||
|
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