From f87b15e4eadb5ca04b005059e757ca85832436f2 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 16 Feb 2021 20:14:13 +1100 Subject: [PATCH] Refactoring --- InvenTree/report/api.py | 35 +++++++------------------------- InvenTree/templates/js/report.js | 6 +++--- 2 files changed, 10 insertions(+), 31 deletions(-) diff --git a/InvenTree/report/api.py b/InvenTree/report/api.py index ede938af8b..dd937f0aba 100644 --- a/InvenTree/report/api.py +++ b/InvenTree/report/api.py @@ -62,13 +62,7 @@ class StockItemReportMixin: params = self.request.query_params - if 'items[]' in params: - items = params.getlist('items[]', []) - elif 'item' in params: - items = [params.get('item', None)] - - if type(items) not in [list, tuple]: - item = [items] + items = params.getlist('item', []) valid_ids = [] @@ -98,13 +92,7 @@ class BuildReportMixin: params = self.request.query_params - if 'builds[]' in params: - builds = params.getlist('builds[]', []) - elif 'build' in params: - builds = [params.get('build', None)] - - if type(builds) not in [list, tuple]: - builds = [builds] + builds = params.getlist('build', []) valid_ids = [] @@ -131,13 +119,7 @@ class PartReportMixin: params = self.request.query_params - if 'parts[]' in params: - parts = params.getlist('parts[]', []) - elif 'part' in params: - parts = [params.get('part', None)] - - if type(parts) not in [list, tuple]: - parts = [parts] + parts = params.getlist('part', []) valid_ids = [] @@ -216,7 +198,7 @@ class ReportPrintMixin: return InvenTree.helpers.DownloadFile( pdf, - 'test_report.pdf', + 'inventree_report.pdf', content_type='application/pdf' ) @@ -228,8 +210,7 @@ class StockItemTestReportList(ReportListView, StockItemReportMixin): Filterable by: - enabled: Filter by enabled / disabled status - - item: Filter by single stock item - - items: Filter by list of stock items + - item: Filter by stock item(s) """ @@ -320,8 +301,7 @@ class BOMReportList(ReportListView, PartReportMixin): Filterably by: - enabled: Filter by enabled / disabled status - - part: Filter by single part - - parts: Filter by list of parts + - part: Filter by part(s) """ queryset = BillOfMaterialsReport.objects.all() @@ -410,8 +390,7 @@ class BuildReportList(ReportListView, BuildReportMixin): Can be filtered by: - enabled: Filter by enabled / disabled status - - build: Filter by a single build - - builds[]: Filter by a list of builds + - build: Filter by Build object """ queryset = BuildReport.objects.all() diff --git a/InvenTree/templates/js/report.js b/InvenTree/templates/js/report.js index bb8068681a..6b6ce39db9 100644 --- a/InvenTree/templates/js/report.js +++ b/InvenTree/templates/js/report.js @@ -129,7 +129,7 @@ function printTestReports(items, options={}) { var href = `/api/report/test/${pk}/print/?`; items.forEach(function(item) { - href += `items[]=${item}&`; + href += `item=${item}&`; }); window.location.href = href; @@ -182,7 +182,7 @@ function printBuildReports(builds, options={}) { var href = `/api/report/build/${pk}/print/?`; builds.forEach(function(build) { - href += `builds[]=${build}&`; + href += `build=${build}&`; }); window.location.href = href; @@ -236,7 +236,7 @@ function printBomReports(parts, options={}) { var href = `/api/report/bom/${pk}/print/?`; parts.forEach(function(part) { - href += `parts[]=${part}&`; + href += `part=${part}&`; }); window.location.href = href;