1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Cleanup from earlier work on caching

This commit is contained in:
Jeremy Stretch
2019-04-22 14:49:31 -04:00
parent 1be5cf8184
commit c2d0e8fd95
10 changed files with 1 additions and 30 deletions

View File

@@ -6,8 +6,6 @@ from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import FieldError, MultipleObjectsReturned, ObjectDoesNotExist
from django.db.models import ManyToManyField
from django.http import Http404
from django.utils.decorators import method_decorator
from django.views.decorators.cache import cache_page
from rest_framework.exceptions import APIException
from rest_framework.permissions import BasePermission
from rest_framework.relations import PrimaryKeyRelatedField, RelatedField
@@ -276,14 +274,12 @@ class ModelViewSet(_ModelViewSet):
# Fall back to the hard-coded serializer class
return self.serializer_class
@method_decorator(cache_page(settings.CACHE_TIMEOUT))
def list(self, *args, **kwargs):
"""
Call to super to allow for caching
"""
return super().list(*args, **kwargs)
@method_decorator(cache_page(settings.CACHE_TIMEOUT))
def retrieve(self, *args, **kwargs):
"""
Call to super to allow for caching
@@ -326,11 +322,9 @@ class FieldChoicesViewSet(ViewSet):
})
self._fields[key] = choices
@method_decorator(cache_page(settings.CACHE_TIMEOUT))
def list(self, request):
return Response(self._fields)
@method_decorator(cache_page(settings.CACHE_TIMEOUT))
def retrieve(self, request, pk):
if pk not in self._fields:
raise Http404

View File

@@ -17,8 +17,6 @@ from django.urls import reverse
from django.utils.html import escape
from django.utils.http import is_safe_url
from django.utils.safestring import mark_safe
from django.utils.decorators import method_decorator
from django.views.decorators.cache import cache_page
from django.views.decorators.csrf import requires_csrf_token
from django.views.defaults import ERROR_500_TEMPLATE_NAME
from django.views.generic import View