mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-14 02:55:41 +00:00
Caching timeout fix for label printing
This commit is contained in:
@ -4,6 +4,8 @@ from django.conf import settings
|
|||||||
from django.core.exceptions import FieldError, ValidationError
|
from django.core.exceptions import FieldError, ValidationError
|
||||||
from django.http import HttpResponse, JsonResponse
|
from django.http import HttpResponse, JsonResponse
|
||||||
from django.urls import include, re_path
|
from django.urls import include, re_path
|
||||||
|
from django.utils.decorators import method_decorator
|
||||||
|
from django.views.decorators.cache import cache_page, never_cache
|
||||||
|
|
||||||
from django_filters.rest_framework import DjangoFilterBackend
|
from django_filters.rest_framework import DjangoFilterBackend
|
||||||
from rest_framework import filters
|
from rest_framework import filters
|
||||||
@ -134,9 +136,15 @@ class LabelListView(LabelFilterMixin, ListAPI):
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@method_decorator(cache_page(5), name='dispatch')
|
||||||
class LabelPrintMixin(LabelFilterMixin):
|
class LabelPrintMixin(LabelFilterMixin):
|
||||||
"""Mixin for printing labels."""
|
"""Mixin for printing labels."""
|
||||||
|
|
||||||
|
@method_decorator(never_cache)
|
||||||
|
def dispatch(self, *args, **kwargs):
|
||||||
|
"""Prevent caching when printing report templates"""
|
||||||
|
return super().dispatch(*args, **kwargs)
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
"""Perform a GET request against this endpoint to print labels"""
|
"""Perform a GET request against this endpoint to print labels"""
|
||||||
return self.print(request, self.get_items())
|
return self.print(request, self.get_items())
|
||||||
|
Reference in New Issue
Block a user