Performed some general linting. More is needed along with cleanup
Some checks failed
Lint / Lint (push) Failing after 22s

This commit is contained in:
2024-05-13 12:53:57 +03:00
parent 18812423c5
commit 4e2b0ec0c6
5 changed files with 394 additions and 262 deletions

View File

@@ -1,15 +1,7 @@
"""
Generic views that provide commonly needed behaviour.
"""
from django.core.exceptions import ValidationError
from django.db.models.query import QuerySet
from django.http import Http404
from django.shortcuts import get_object_or_404 as _get_object_or_404
from rest_framework import views
from rest_framework.generics import GenericAPIView
from rest_framework.settings import api_settings
from starfields_drf_generics import mixins
@@ -18,26 +10,32 @@ from starfields_drf_generics import mixins
# Single item CRUD
class CachedCreateAPIView(mixins.CachedCreateModelMixin,GenericAPIView):
class CachedCreateAPIView(mixins.CachedCreateModelMixin,
GenericAPIView):
"""
Concrete view for creating a model instance.
"""
def post(self, request, *args, **kwargs):
return self.create(request, *args, **kwargs)
class CachedRetrieveAPIView(mixins.CachedRetrieveModelMixin,GenericAPIView):
class CachedRetrieveAPIView(mixins.CachedRetrieveModelMixin,
GenericAPIView):
"""
Concrete view for retrieving a model instance.
"""
def get(self, request, *args, **kwargs):
return self.retrieve(request, *args, **kwargs)
class CachedUpdateAPIView(mixins.CachedUpdateModelMixin,GenericAPIView):
class CachedUpdateAPIView(mixins.CachedUpdateModelMixin,
GenericAPIView):
"""
Concrete view for updating a model instance.
"""
def put(self, request, *args, **kwargs):
return self.update(request, *args, **kwargs)
@@ -45,18 +43,23 @@ class CachedUpdateAPIView(mixins.CachedUpdateModelMixin,GenericAPIView):
return self.partial_update(request, *args, **kwargs)
class CachedDestroyAPIView(mixins.CachedDestroyModelMixin,GenericAPIView):
class CachedDestroyAPIView(mixins.CachedDestroyModelMixin,
GenericAPIView):
"""
Concrete view for deleting a model instance.
"""
def delete(self, request, *args, **kwargs):
return self.destroy(request, *args, **kwargs)
class CachedRetrieveUpdateAPIView(mixins.CachedRetrieveModelMixin,mixins.CachedUpdateModelMixin,GenericAPIView):
class CachedRetrieveUpdateAPIView(mixins.CachedRetrieveModelMixin,
mixins.CachedUpdateModelMixin,
GenericAPIView):
"""
Concrete view for retrieving, updating a model instance.
"""
def get(self, request, *args, **kwargs):
return self.retrieve(request, *args, **kwargs)
@@ -67,10 +70,13 @@ class CachedRetrieveUpdateAPIView(mixins.CachedRetrieveModelMixin,mixins.CachedU
return self.partial_update(request, *args, **kwargs)
class CachedRetrieveDestroyAPIView(mixins.CachedRetrieveModelMixin,mixins.CachedDestroyModelMixin,GenericAPIView):
class CachedRetrieveDestroyAPIView(mixins.CachedRetrieveModelMixin,
mixins.CachedDestroyModelMixin,
GenericAPIView):
"""
Concrete view for retrieving or deleting a model instance.
"""
def get(self, request, *args, **kwargs):
return self.retrieve(request, *args, **kwargs)
@@ -78,10 +84,14 @@ class CachedRetrieveDestroyAPIView(mixins.CachedRetrieveModelMixin,mixins.Cached
return self.destroy(request, *args, **kwargs)
class CachedRetrieveUpdateDestroyAPIView(mixins.CachedRetrieveModelMixin,mixins.CachedUpdateModelMixin,mixins.CachedDestroyModelMixin,GenericAPIView):
class CachedRetrieveUpdateDestroyAPIView(mixins.CachedRetrieveModelMixin,
mixins.CachedUpdateModelMixin,
mixins.CachedDestroyModelMixin,
GenericAPIView):
"""
Concrete view for retrieving, updating or deleting a model instance.
"""
def get(self, request, *args, **kwargs):
return self.retrieve(request, *args, **kwargs)
@@ -95,10 +105,16 @@ class CachedRetrieveUpdateDestroyAPIView(mixins.CachedRetrieveModelMixin,mixins.
return self.destroy(request, *args, **kwargs)
class CachedCreateRetrieveUpdateDestroyAPIView(mixins.CachedCreateModelMixin,mixins.CachedRetrieveModelMixin,mixins.CachedUpdateModelMixin,mixins.CachedDestroyModelMixin,GenericAPIView):
class CachedCreateRetrieveUpdateDestroyAPIView(mixins.CachedCreateModelMixin,
mixins.CachedRetrieveModelMixin,
mixins.CachedUpdateModelMixin,
mixins.CachedDestroyModelMixin,
GenericAPIView):
"""
Concrete view for creating, retrieving, updating or deleting a model instance.
Concrete view for creating, retrieving, updating or deleting a model
instance.
"""
def get(self, request, *args, **kwargs):
return self.retrieve(request, *args, **kwargs)
@@ -117,26 +133,32 @@ class CachedCreateRetrieveUpdateDestroyAPIView(mixins.CachedCreateModelMixin,mix
# List based CRUD
class CachedListRetrieveAPIView(mixins.CachedListRetrieveModelMixin,GenericAPIView):
class CachedListRetrieveAPIView(mixins.CachedListRetrieveModelMixin,
GenericAPIView):
"""
Concrete view for listing a queryset.
"""
def get(self, request, *args, **kwargs):
return self.list(request, *args, **kwargs)
class CachedListCreateAPIView(mixins.CachedListCreateModelMixin,GenericAPIView):
class CachedListCreateAPIView(mixins.CachedListCreateModelMixin,
GenericAPIView):
"""
Concrete view for creating multiple instances.
"""
def post(self, request, *args, **kwargs):
return self.list_create(request, *args, **kwargs)
class CachedListUpdateAPIView(mixins.CachedListUpdateModelMixin,GenericAPIView):
class CachedListUpdateAPIView(mixins.CachedListUpdateModelMixin,
GenericAPIView):
"""
Concrete view for updating multiple instances.
"""
def put(self, request, *args, **kwargs):
return self.list_update(request, *args, **kwargs)
@@ -144,18 +166,23 @@ class CachedListUpdateAPIView(mixins.CachedListUpdateModelMixin,GenericAPIView):
return self.list_partial_update(request, *args, **kwargs)
class CachedListDestroyAPIView(mixins.CachedListDestroyModelMixin,GenericAPIView):
class CachedListDestroyAPIView(mixins.CachedListDestroyModelMixin,
GenericAPIView):
"""
Concrete view for deleting multiple instances.
"""
def delete(self, request, *args, **kwargs):
return self.list_destroy(request, *args, **kwargs)
class CachedListRetrieveCreateAPIView(mixins.CachedListRetrieveModelMixin,mixins.CachedListCreateModelMixin,GenericAPIView):
class CachedListRetrieveCreateAPIView(mixins.CachedListRetrieveModelMixin,
mixins.CachedListCreateModelMixin,
GenericAPIView):
"""
Concrete view for listing a queryset or creating a model instance.
"""
def get(self, request, *args, **kwargs):
return self.list(request, *args, **kwargs)
@@ -163,10 +190,15 @@ class CachedListRetrieveCreateAPIView(mixins.CachedListRetrieveModelMixin,mixins
return self.create(request, *args, **kwargs)
class CachedListCreateRetrieveDestroyAPIView(mixins.CachedListCreateModelMixin,mixins.CachedListRetrieveModelMixin,mixins.CachedListDestroyModelMixin,GenericAPIView):
class CachedListCreateRetrieveDestroyAPIView(
mixins.CachedListCreateModelMixin,
mixins.CachedListRetrieveModelMixin,
mixins.CachedListDestroyModelMixin,
GenericAPIView):
"""
Concrete view for creating, retrieving or deleting a model instance.
"""
def get(self, request, *args, **kwargs):
return self.list(request, *args, **kwargs)
@@ -177,10 +209,16 @@ class CachedListCreateRetrieveDestroyAPIView(mixins.CachedListCreateModelMixin,m
return self.list_destroy(request, *args, **kwargs)
class CachedListCreateRetrieveUpdateAPIView(mixins.CachedListCreateModelMixin,mixins.CachedListRetrieveModelMixin,mixins.CachedListUpdateModelMixin,GenericAPIView):
class CachedListCreateRetrieveUpdateAPIView(
mixins.CachedListCreateModelMixin,
mixins.CachedListRetrieveModelMixin,
mixins.CachedListUpdateModelMixin,
GenericAPIView):
"""
Concrete view for creating, retrieving, updating or deleting a model instance.
Concrete view for creating, retrieving, updating or deleting a model
instance.
"""
def get(self, request, *args, **kwargs):
return self.list(request, *args, **kwargs)
@@ -194,10 +232,17 @@ class CachedListCreateRetrieveUpdateAPIView(mixins.CachedListCreateModelMixin,mi
return self.list_partial_update(request, *args, **kwargs)
class CachedListCreateRetrieveUpdateDestroyAPIView(mixins.CachedListCreateModelMixin,mixins.CachedListRetrieveModelMixin,mixins.CachedListUpdateModelMixin,mixins.CachedListDestroyModelMixin,GenericAPIView):
class CachedListCreateRetrieveUpdateDestroyAPIView(
mixins.CachedListCreateModelMixin,
mixins.CachedListRetrieveModelMixin,
mixins.CachedListUpdateModelMixin,
mixins.CachedListDestroyModelMixin,
GenericAPIView):
"""
Concrete view for creating, retrieving, updating or deleting a model instance.
Concrete view for creating, retrieving, updating or deleting a model
instance.
"""
def get(self, request, *args, **kwargs):
return self.list(request, *args, **kwargs)