mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Refactoring
This commit is contained in:
parent
b09e9c0781
commit
f87b15e4ea
@ -62,13 +62,7 @@ class StockItemReportMixin:
|
|||||||
|
|
||||||
params = self.request.query_params
|
params = self.request.query_params
|
||||||
|
|
||||||
if 'items[]' in params:
|
items = params.getlist('item', [])
|
||||||
items = params.getlist('items[]', [])
|
|
||||||
elif 'item' in params:
|
|
||||||
items = [params.get('item', None)]
|
|
||||||
|
|
||||||
if type(items) not in [list, tuple]:
|
|
||||||
item = [items]
|
|
||||||
|
|
||||||
valid_ids = []
|
valid_ids = []
|
||||||
|
|
||||||
@ -98,13 +92,7 @@ class BuildReportMixin:
|
|||||||
|
|
||||||
params = self.request.query_params
|
params = self.request.query_params
|
||||||
|
|
||||||
if 'builds[]' in params:
|
builds = params.getlist('build', [])
|
||||||
builds = params.getlist('builds[]', [])
|
|
||||||
elif 'build' in params:
|
|
||||||
builds = [params.get('build', None)]
|
|
||||||
|
|
||||||
if type(builds) not in [list, tuple]:
|
|
||||||
builds = [builds]
|
|
||||||
|
|
||||||
valid_ids = []
|
valid_ids = []
|
||||||
|
|
||||||
@ -131,13 +119,7 @@ class PartReportMixin:
|
|||||||
|
|
||||||
params = self.request.query_params
|
params = self.request.query_params
|
||||||
|
|
||||||
if 'parts[]' in params:
|
parts = params.getlist('part', [])
|
||||||
parts = params.getlist('parts[]', [])
|
|
||||||
elif 'part' in params:
|
|
||||||
parts = [params.get('part', None)]
|
|
||||||
|
|
||||||
if type(parts) not in [list, tuple]:
|
|
||||||
parts = [parts]
|
|
||||||
|
|
||||||
valid_ids = []
|
valid_ids = []
|
||||||
|
|
||||||
@ -216,7 +198,7 @@ class ReportPrintMixin:
|
|||||||
|
|
||||||
return InvenTree.helpers.DownloadFile(
|
return InvenTree.helpers.DownloadFile(
|
||||||
pdf,
|
pdf,
|
||||||
'test_report.pdf',
|
'inventree_report.pdf',
|
||||||
content_type='application/pdf'
|
content_type='application/pdf'
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -228,8 +210,7 @@ class StockItemTestReportList(ReportListView, StockItemReportMixin):
|
|||||||
Filterable by:
|
Filterable by:
|
||||||
|
|
||||||
- enabled: Filter by enabled / disabled status
|
- enabled: Filter by enabled / disabled status
|
||||||
- item: Filter by single stock item
|
- item: Filter by stock item(s)
|
||||||
- items: Filter by list of stock items
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -320,8 +301,7 @@ class BOMReportList(ReportListView, PartReportMixin):
|
|||||||
Filterably by:
|
Filterably by:
|
||||||
|
|
||||||
- enabled: Filter by enabled / disabled status
|
- enabled: Filter by enabled / disabled status
|
||||||
- part: Filter by single part
|
- part: Filter by part(s)
|
||||||
- parts: Filter by list of parts
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
queryset = BillOfMaterialsReport.objects.all()
|
queryset = BillOfMaterialsReport.objects.all()
|
||||||
@ -410,8 +390,7 @@ class BuildReportList(ReportListView, BuildReportMixin):
|
|||||||
Can be filtered by:
|
Can be filtered by:
|
||||||
|
|
||||||
- enabled: Filter by enabled / disabled status
|
- enabled: Filter by enabled / disabled status
|
||||||
- build: Filter by a single build
|
- build: Filter by Build object
|
||||||
- builds[]: Filter by a list of builds
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
queryset = BuildReport.objects.all()
|
queryset = BuildReport.objects.all()
|
||||||
|
@ -129,7 +129,7 @@ function printTestReports(items, options={}) {
|
|||||||
var href = `/api/report/test/${pk}/print/?`;
|
var href = `/api/report/test/${pk}/print/?`;
|
||||||
|
|
||||||
items.forEach(function(item) {
|
items.forEach(function(item) {
|
||||||
href += `items[]=${item}&`;
|
href += `item=${item}&`;
|
||||||
});
|
});
|
||||||
|
|
||||||
window.location.href = href;
|
window.location.href = href;
|
||||||
@ -182,7 +182,7 @@ function printBuildReports(builds, options={}) {
|
|||||||
var href = `/api/report/build/${pk}/print/?`;
|
var href = `/api/report/build/${pk}/print/?`;
|
||||||
|
|
||||||
builds.forEach(function(build) {
|
builds.forEach(function(build) {
|
||||||
href += `builds[]=${build}&`;
|
href += `build=${build}&`;
|
||||||
});
|
});
|
||||||
|
|
||||||
window.location.href = href;
|
window.location.href = href;
|
||||||
@ -236,7 +236,7 @@ function printBomReports(parts, options={}) {
|
|||||||
var href = `/api/report/bom/${pk}/print/?`;
|
var href = `/api/report/bom/${pk}/print/?`;
|
||||||
|
|
||||||
parts.forEach(function(part) {
|
parts.forEach(function(part) {
|
||||||
href += `parts[]=${part}&`;
|
href += `part=${part}&`;
|
||||||
});
|
});
|
||||||
|
|
||||||
window.location.href = href;
|
window.location.href = href;
|
||||||
|
Loading…
Reference in New Issue
Block a user