From 21d5440f9850a70285a4a6ea6b64accb6ce6b8a3 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 9 Jan 2021 21:55:05 +1100 Subject: [PATCH] Remove unused views --- InvenTree/label/models.py | 2 +- InvenTree/stock/urls.py | 2 - InvenTree/stock/views.py | 87 --------------------------------------- 3 files changed, 1 insertion(+), 90 deletions(-) diff --git a/InvenTree/label/models.py b/InvenTree/label/models.py index 6c220f2496..2242fe41e4 100644 --- a/InvenTree/label/models.py +++ b/InvenTree/label/models.py @@ -189,7 +189,7 @@ class StockLocationLabel(LabelTemplate): for loc in locations: records.append({ - 'location': location, + 'location': loc, }) return records diff --git a/InvenTree/stock/urls.py b/InvenTree/stock/urls.py index 7ad8bc4f7f..6aeb1f5b73 100644 --- a/InvenTree/stock/urls.py +++ b/InvenTree/stock/urls.py @@ -30,7 +30,6 @@ stock_item_detail_urls = [ url(r'^add_tracking/', views.StockItemTrackingCreate.as_view(), name='stock-tracking-create'), url(r'^test-report-select/', views.StockItemTestReportSelect.as_view(), name='stock-item-test-report-select'), - url(r'^label-select/', views.StockItemSelectLabels.as_view(), name='stock-item-label-select'), url(r'^test/', views.StockItemDetail.as_view(template_name='stock/item_tests.html'), name='stock-item-test-results'), url(r'^children/', views.StockItemDetail.as_view(template_name='stock/item_childs.html'), name='stock-item-children'), @@ -64,7 +63,6 @@ stock_urls = [ url(r'^item/uninstall/', views.StockItemUninstall.as_view(), name='stock-item-uninstall'), url(r'^item/test-report-download/', views.StockItemTestReportDownload.as_view(), name='stock-item-test-report-download'), - url(r'^item/print-stock-labels/', views.StockItemPrintLabels.as_view(), name='stock-item-print-labels'), # URLs for StockItem attachments url(r'^item/attachment/', include([ diff --git a/InvenTree/stock/views.py b/InvenTree/stock/views.py index ab6f64fb44..12463f303f 100644 --- a/InvenTree/stock/views.py +++ b/InvenTree/stock/views.py @@ -31,7 +31,6 @@ from datetime import datetime, timedelta from company.models import Company, SupplierPart from part.models import Part from report.models import TestReport -from label.models import StockItemLabel from .models import StockItem, StockLocation, StockItemTracking, StockItemAttachment, StockItemTestResult import common.settings @@ -304,92 +303,6 @@ class StockItemReturnToStock(AjaxUpdateView): } -class StockItemSelectLabels(AjaxView): - """ - View for selecting a template for printing labels for one (or more) StockItem objects - """ - - model = StockItem - ajax_form_title = _('Select Label Template') - role_required = 'stock.view' - - def get_form(self): - - item = StockItem.objects.get(pk=self.kwargs['pk']) - - labels = [] - - # Construct a list of StockItemLabel objects which are enabled, and the filters match the selected StockItem - for label in StockItemLabel.objects.filter(enabled=True): - if label.matches_stock_item(item): - labels.append(label) - - return StockForms.StockItemLabelSelectForm(labels) - - def post(self, request, *args, **kwargs): - - label = request.POST.get('label', None) - - try: - label = StockItemLabel.objects.get(pk=label) - except (ValueError, StockItemLabel.DoesNotExist): - raise ValidationError({'label': _("Select valid label")}) - - stock_item = StockItem.objects.get(pk=self.kwargs['pk']) - - url = reverse('stock-item-print-labels') - - url += '?label={pk}'.format(pk=label.pk) - url += '&items[]={pk}'.format(pk=stock_item.pk) - - data = { - 'form_valid': True, - 'url': url, - } - - return self.renderJsonResponse(request, self.get_form(), data=data) - - -class StockItemPrintLabels(AjaxView): - """ - View for printing labels and returning a PDF - - Requires the following arguments to be passed as URL params: - - items: List of valid StockItem pk values - label: Valid pk of a StockItemLabel template - """ - - role_required = 'stock.view' - - def get(self, request, *args, **kwargs): - - label = request.GET.get('label', None) - - try: - label = StockItemLabel.objects.get(pk=label) - except (ValueError, StockItemLabel.DoesNotExist): - raise ValidationError({'label': 'Invalid label ID'}) - - item_pks = request.GET.getlist('items[]') - - items = [] - - for pk in item_pks: - try: - item = StockItem.objects.get(pk=pk) - items.append(item) - except (ValueError, StockItem.DoesNotExist): - pass - - if len(items) == 0: - raise ValidationError({'items': 'Must provide valid stockitems'}) - - pdf = label.render(items).getbuffer() - - return DownloadFile(pdf, 'stock_labels.pdf', content_type='application/pdf') - - class StockItemDeleteTestData(AjaxUpdateView): """ View for deleting all test data