mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-16 12:05:53 +00:00
Reduce caching of report printing template
- Cache for 5 seconds - Ensures that uploaded templates are made available quickly
This commit is contained in:
@ -5,7 +5,9 @@ from django.core.files.base import ContentFile
|
|||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django.template.exceptions import TemplateDoesNotExist
|
from django.template.exceptions import TemplateDoesNotExist
|
||||||
from django.urls import include, path, re_path
|
from django.urls import include, path, re_path
|
||||||
|
from django.utils.decorators import method_decorator
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
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
|
||||||
@ -138,9 +140,15 @@ class ReportFilterMixin:
|
|||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
|
|
||||||
|
@method_decorator(cache_page(5), name='dispatch')
|
||||||
class ReportPrintMixin:
|
class ReportPrintMixin:
|
||||||
"""Mixin for printing reports."""
|
"""Mixin for printing reports."""
|
||||||
|
|
||||||
|
@method_decorator(never_cache)
|
||||||
|
def dispatch(self, *args, **kwargs):
|
||||||
|
"""Prevent caching when printing report templates"""
|
||||||
|
return super().dispatch(*args, **kwargs)
|
||||||
|
|
||||||
def report_callback(self, object, report, request):
|
def report_callback(self, object, report, request):
|
||||||
"""Callback function for each object/report combination.
|
"""Callback function for each object/report combination.
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user