diff --git a/api_v2/views/background.py b/api_v2/views/background.py index 534b7461..c56d59e4 100644 --- a/api_v2/views/background.py +++ b/api_v2/views/background.py @@ -7,8 +7,6 @@ from api_v2 import serializers - - class BackgroundFilterSet(FilterSet): class Meta: model = models.Background diff --git a/api_v2/views/characterclass.py b/api_v2/views/characterclass.py index 12b8a9cf..e5c8073b 100644 --- a/api_v2/views/characterclass.py +++ b/api_v2/views/characterclass.py @@ -1,10 +1,21 @@ """Viewset and Filterset for the CharacterClass Serializers.""" from rest_framework import viewsets +from django_filters import FilterSet + from api_v2 import models from api_v2 import serializers +class CharacterClassFilterSet(FilterSet): + class Meta: + model = models.CharacterClass + fields = { + 'key': ['in', 'iexact', 'exact' ], + 'name': ['iexact', 'exact','contains'], + 'document__key': ['in','iexact','exact'], + } + class CharacterClassViewSet(viewsets.ReadOnlyModelViewSet): """ @@ -13,4 +24,4 @@ class CharacterClassViewSet(viewsets.ReadOnlyModelViewSet): """ queryset = models.CharacterClass.objects.all().order_by('pk') serializer_class = serializers.CharacterClassSerializer - + filterset_class = CharacterClassFilterSet diff --git a/api_v2/views/condition.py b/api_v2/views/condition.py index e76e2df2..e46b1bc4 100644 --- a/api_v2/views/condition.py +++ b/api_v2/views/condition.py @@ -1,9 +1,21 @@ 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. @@ -11,6 +23,4 @@ class ConditionViewSet(viewsets.ReadOnlyModelViewSet): """ queryset = models.Condition.objects.all().order_by('pk') serializer_class = serializers.ConditionSerializer - - - + filterset_class = ConditionFilterSet \ No newline at end of file diff --git a/api_v2/views/creature.py b/api_v2/views/creature.py index b393907e..05512ddd 100644 --- a/api_v2/views/creature.py +++ b/api_v2/views/creature.py @@ -62,6 +62,16 @@ class CreatureViewSet(viewsets.ReadOnlyModelViewSet): filterset_class = CreatureFilterSet +class CreatureTypeFilterSet(FilterSet): + class Meta: + model = models.CreatureType + fields = { + 'key': ['in', 'iexact', 'exact' ], + 'name': ['iexact', 'exact','contains'], + 'document__key': ['in','iexact','exact'], + } + + class CreatureTypeViewSet(viewsets.ReadOnlyModelViewSet): """ list: API endpoint for returning a list of creatures types. @@ -69,6 +79,17 @@ class CreatureTypeViewSet(viewsets.ReadOnlyModelViewSet): """ queryset = models.CreatureType.objects.all().order_by('pk') serializer_class = serializers.CreatureTypeSerializer + filterset_class = CreatureTypeFilterSet + + +class CreatureSetFilterSet(FilterSet): + class Meta: + model = models.CreatureSet + fields = { + 'key': ['in', 'iexact', 'exact' ], + 'name': ['iexact', 'exact','contains'], + 'document__key': ['in','iexact','exact'], + } class CreatureSetViewSet(viewsets.ReadOnlyModelViewSet): @@ -78,3 +99,4 @@ class CreatureSetViewSet(viewsets.ReadOnlyModelViewSet): """ queryset = models.CreatureSet.objects.all().order_by('pk') serializer_class = serializers.CreatureSetSerializer + filterset_class = CreatureSetFilterSet diff --git a/api_v2/views/damagetype.py b/api_v2/views/damagetype.py index 13737687..5c82d9f6 100644 --- a/api_v2/views/damagetype.py +++ b/api_v2/views/damagetype.py @@ -1,9 +1,21 @@ 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. @@ -11,6 +23,4 @@ class DamageTypeViewSet(viewsets.ReadOnlyModelViewSet): """ queryset = models.DamageType.objects.all().order_by('pk') serializer_class = serializers.DamageTypeSerializer - - - + filterset_class = DamageTypeFilterSet diff --git a/api_v2/views/environment.py b/api_v2/views/environment.py index 55e2b52a..2a56bd0c 100644 --- a/api_v2/views/environment.py +++ b/api_v2/views/environment.py @@ -2,10 +2,23 @@ from rest_framework import viewsets +from django_filters import FilterSet + from api_v2 import models from api_v2 import serializers +class EnvironmentFilterSet(FilterSet): + class Meta: + model = models.Environment + fields = { + 'key': ['in', 'iexact', 'exact' ], + 'name': ['iexact', 'exact','contains'], + 'document__key': ['in','iexact','exact'], + } + + + class EnvironmentViewSet(viewsets.ReadOnlyModelViewSet): """ list: API endpoint for returning a list of environments. @@ -13,6 +26,4 @@ class EnvironmentViewSet(viewsets.ReadOnlyModelViewSet): """ queryset = models.Environment.objects.all().order_by('pk') serializer_class = serializers.EnvironmentSerializer - - - + filterset_class = EnvironmentFilterSet diff --git a/api_v2/views/item.py b/api_v2/views/item.py index 748d8b36..bb1a3f9f 100644 --- a/api_v2/views/item.py +++ b/api_v2/views/item.py @@ -141,97 +141,3 @@ class ArmorViewSet(viewsets.ReadOnlyModelViewSet): queryset = models.Armor.objects.all().order_by('pk') serializer_class = serializers.ArmorSerializer filterset_class = ArmorFilterSet - - - -class FeatFilterSet(FilterSet): - class Meta: - model = models.Feat - fields = { - 'key': ['in', 'iexact', 'exact' ], - 'name': ['iexact', 'exact'], - 'document__key': ['in','iexact','exact'], - } - -class FeatViewSet(viewsets.ReadOnlyModelViewSet): - """ - list: API endpoint for returning a list of feats. - retrieve: API endpoint for returning a particular feat. - """ - queryset = models.Feat.objects.all().order_by('pk') - serializer_class = serializers.FeatSerializer - filterset_class = FeatFilterSet - - -class CreatureFilterSet(FilterSet): - - class Meta: - model = models.Creature - fields = { - 'key': ['in', 'iexact', 'exact' ], - 'name': ['iexact', 'exact'], - 'document__key': ['in','iexact','exact'], - 'size': ['exact'], - 'armor_class': ['exact','lt','lte','gt','gte'], - 'ability_score_strength': ['exact','lt','lte','gt','gte'], - 'ability_score_dexterity': ['exact','lt','lte','gt','gte'], - 'ability_score_constitution': ['exact','lt','lte','gt','gte'], - 'ability_score_intelligence': ['exact','lt','lte','gt','gte'], - 'ability_score_wisdom': ['exact','lt','lte','gt','gte'], - 'ability_score_charisma': ['exact','lt','lte','gt','gte'], - 'saving_throw_charisma': ['isnull'], - 'saving_throw_strength': ['isnull'], - 'saving_throw_dexterity': ['isnull'], - 'saving_throw_constitution': ['isnull'], - 'saving_throw_intelligence': ['isnull'], - 'saving_throw_wisdom': ['isnull'], - 'saving_throw_charisma': ['isnull'], - 'skill_bonus_acrobatics': ['isnull'], - 'skill_bonus_animal_handling': ['isnull'], - 'skill_bonus_arcana': ['isnull'], - 'skill_bonus_athletics': ['isnull'], - 'skill_bonus_deception': ['isnull'], - 'skill_bonus_history': ['isnull'], - 'skill_bonus_insight': ['isnull'], - 'skill_bonus_intimidation': ['isnull'], - 'skill_bonus_investigation': ['isnull'], - 'skill_bonus_medicine': ['isnull'], - 'skill_bonus_nature': ['isnull'], - 'skill_bonus_perception': ['isnull'], - 'skill_bonus_performance': ['isnull'], - 'skill_bonus_persuasion': ['isnull'], - 'skill_bonus_religion': ['isnull'], - 'skill_bonus_sleight_of_hand': ['isnull'], - 'skill_bonus_stealth': ['isnull'], - 'skill_bonus_survival': ['isnull'], - 'passive_perception': ['exact','lt','lte','gt','gte'], - } - -class CreatureViewSet(viewsets.ReadOnlyModelViewSet): - """ - list: API endpoint for returning a list of creatures. - retrieve: API endpoint for returning a particular creature. - """ - queryset = models.Creature.objects.all().order_by('pk') - serializer_class = serializers.CreatureSerializer - filterset_class = CreatureFilterSet - - -class RaceFilterSet(FilterSet): - class Meta: - model = models.Race - fields = { - 'key': ['in', 'iexact', 'exact'], - 'name': ['iexact', 'exact'], - 'document__key': ['in', 'iexact', 'exact'], - } - - -class RaceViewSet(viewsets.ReadOnlyModelViewSet): - """ - list: API endpoint for returning a list of races. - retrieve: API endpoint for returning a particular race. - """ - queryset = models.Race.objects.all().order_by('pk') - serializer_class = serializers.RaceSerializer - filterset_class = RaceFilterSet diff --git a/api_v2/views/size.py b/api_v2/views/size.py index 54851214..da481071 100644 --- a/api_v2/views/size.py +++ b/api_v2/views/size.py @@ -1,9 +1,21 @@ 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. @@ -11,6 +23,7 @@ class SizeViewSet(viewsets.ReadOnlyModelViewSet): """ queryset = models.Size.objects.all().order_by('pk') serializer_class = serializers.SizeSerializer + filterset_class = SizeFilterSet diff --git a/api_v2/views/spell.py b/api_v2/views/spell.py index d5bb639f..19fdd584 100644 --- a/api_v2/views/spell.py +++ b/api_v2/views/spell.py @@ -6,6 +6,15 @@ from api_v2 import serializers +class SpellFilterSet(FilterSet): + class Meta: + model = models.Spell + fields = { + 'key': ['in', 'iexact', 'exact' ], + 'name': ['iexact', 'exact','contains'], + 'document__key': ['in','iexact','exact'], + } + class SpellViewSet(viewsets.ReadOnlyModelViewSet): """ list: API endpoint for returning a list of spells. @@ -13,4 +22,5 @@ class SpellViewSet(viewsets.ReadOnlyModelViewSet): """ queryset = models.Spell.objects.all().order_by('pk') serializer_class = serializers.SpellSerializer + filterset_class = SpellFilterSet