Add own subclass of generic view set.
parent
d296387651
commit
48d6d0cf28
|
@ -48,14 +48,6 @@ class ListModelMixin(mixins.ListModelMixin):
|
|||
return super().list(*args, **kwargs)
|
||||
|
||||
|
||||
class NeighborsApiMixin:
|
||||
def filter_queryset(self, queryset, force=False):
|
||||
for backend in self.get_filter_backends():
|
||||
if force or self.action != "retrieve" or backend not in self.retrieve_exclude_filters:
|
||||
queryset = backend().filter_queryset(self.request, queryset, self)
|
||||
return queryset
|
||||
|
||||
|
||||
class DestroyModelMixin(mixins.DestroyModelMixin):
|
||||
"""
|
||||
Self version of DestroyModelMixin with
|
||||
|
@ -73,6 +65,16 @@ class DestroyModelMixin(mixins.DestroyModelMixin):
|
|||
return Response(status=status.HTTP_204_NO_CONTENT)
|
||||
|
||||
|
||||
# Other mixins (what they are doing here?)
|
||||
|
||||
class NeighborsApiMixin(object):
|
||||
def filter_queryset(self, queryset, force=False):
|
||||
for backend in self.get_filter_backends():
|
||||
if force or self.action != "retrieve" or backend not in self.retrieve_exclude_filters:
|
||||
queryset = backend().filter_queryset(self.request, queryset, self)
|
||||
return queryset
|
||||
|
||||
|
||||
class PreconditionMixin(object):
|
||||
def pre_conditions_on_save(self, obj):
|
||||
pass
|
||||
|
@ -189,6 +191,8 @@ class ReversionMixin(object):
|
|||
|
||||
|
||||
|
||||
# Own subclasses of django rest framework viewsets
|
||||
|
||||
class ModelCrudViewSet(DetailAndListSerializersMixin,
|
||||
ReversionMixin,
|
||||
PreconditionMixin,
|
||||
|
@ -212,3 +216,7 @@ class ModelListViewSet(DetailAndListSerializersMixin,
|
|||
ListModelMixin,
|
||||
viewsets.GenericViewSet):
|
||||
pass
|
||||
|
||||
|
||||
class GenericViewSet(viewsets.GenericViewSet):
|
||||
pass
|
||||
|
|
Loading…
Reference in New Issue