mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-03 04:00:57 +00:00
Bypass cache when displaying settings on "settings" page (#4499)
* Bypass cache when displaying settings on "settings" page
- Sometimes caching issues can cause "old" values to be stored (depends on the worker)
- Until we have a shared cache, this is a problem
- Force the settings to be re-loaded from the database when displaying
- Further improvement would be to render them via the API
* Bypass cache for report and label printing
* Update test
(cherry picked from commit 18c7c1d756
)
This commit is contained in:
@ -185,7 +185,7 @@ class ReportPrintMixin:
|
||||
outputs = []
|
||||
|
||||
# In debug mode, generate single HTML output, rather than PDF
|
||||
debug_mode = common.models.InvenTreeSetting.get_setting('REPORT_DEBUG_MODE')
|
||||
debug_mode = common.models.InvenTreeSetting.get_setting('REPORT_DEBUG_MODE', cache=False)
|
||||
|
||||
# Start with a default report name
|
||||
report_name = "report.pdf"
|
||||
@ -254,7 +254,7 @@ class ReportPrintMixin:
|
||||
status=400,
|
||||
)
|
||||
|
||||
inline = common.models.InvenTreeUserSetting.get_setting('REPORT_INLINE', user=request.user)
|
||||
inline = common.models.InvenTreeUserSetting.get_setting('REPORT_INLINE', user=request.user, cache=False)
|
||||
|
||||
return InvenTree.helpers.DownloadFile(
|
||||
pdf,
|
||||
@ -342,7 +342,7 @@ class StockItemTestReportPrint(RetrieveAPI, StockItemReportMixin, ReportPrintMix
|
||||
def report_callback(self, item, report, request):
|
||||
"""Callback to (optionally) save a copy of the generated report"""
|
||||
|
||||
if common.models.InvenTreeSetting.get_setting('REPORT_ATTACH_TEST_REPORT'):
|
||||
if common.models.InvenTreeSetting.get_setting('REPORT_ATTACH_TEST_REPORT', cache=False):
|
||||
|
||||
# Construct a PDF file object
|
||||
pdf = report.get_document().write_pdf()
|
||||
|
@ -375,7 +375,7 @@ class BuildReportTest(ReportTest):
|
||||
self.assertEqual(headers['Content-Disposition'], 'attachment; filename="report.pdf"')
|
||||
|
||||
# Now, set the download type to be "inline"
|
||||
inline = InvenTreeUserSetting.get_setting_object('REPORT_INLINE', user=self.user)
|
||||
inline = InvenTreeUserSetting.get_setting_object('REPORT_INLINE', cache=False, user=self.user)
|
||||
inline.value = True
|
||||
inline.save()
|
||||
|
||||
|
Reference in New Issue
Block a user