diff --git a/InvenTree/part/templates/part/attachments.html b/InvenTree/part/templates/part/attachments.html index cff6f25892..5fca535098 100644 --- a/InvenTree/part/templates/part/attachments.html +++ b/InvenTree/part/templates/part/attachments.html @@ -72,13 +72,14 @@ $("#attachment-table").on('click', '.attachment-delete-button', function() { var button = $(this); + var pk = button.attr('pk'); + var url = `/api/part/attachment/${pk}/`; - var url = `/part/attachment/${button.attr('pk')}/delete/`; - - launchModalForm(url, { - success: function() { - location.reload(); - } + constructForm(url, { + method: 'DELETE', + confirmMessage: '{% trans "Confirm Delete Operation" %}', + title: '{% trans "Delete Attachment" %}', + reload: true, }); }); diff --git a/InvenTree/part/urls.py b/InvenTree/part/urls.py index eeb1a08be4..489df6c116 100644 --- a/InvenTree/part/urls.py +++ b/InvenTree/part/urls.py @@ -17,10 +17,6 @@ part_related_urls = [ url(r'^(?P\d+)/delete/?', views.PartRelatedDelete.as_view(), name='part-related-delete'), ] -part_attachment_urls = [ - url(r'^(?P\d+)/delete/?', views.PartAttachmentDelete.as_view(), name='part-attachment-delete'), -] - sale_price_break_urls = [ url(r'^new/', views.PartSalePriceBreakCreate.as_view(), name='sale-price-break-create'), url(r'^(?P\d+)/edit/', views.PartSalePriceBreakEdit.as_view(), name='sale-price-break-edit'), @@ -146,9 +142,6 @@ part_urls = [ # Part related url(r'^related-parts/', include(part_related_urls)), - # Part attachments - url(r'^attachment/', include(part_attachment_urls)), - # Part price breaks url(r'^sale-price/', include(sale_price_break_urls)), diff --git a/InvenTree/part/views.py b/InvenTree/part/views.py index b2d12a72ab..0f0ccd8ba0 100644 --- a/InvenTree/part/views.py +++ b/InvenTree/part/views.py @@ -31,7 +31,7 @@ import io from rapidfuzz import fuzz from decimal import Decimal, InvalidOperation -from .models import PartCategory, Part, PartAttachment, PartRelated +from .models import PartCategory, Part, PartRelated from .models import PartParameterTemplate, PartParameter from .models import PartCategoryParameterTemplate from .models import BomItem @@ -154,22 +154,6 @@ class PartRelatedDelete(AjaxDeleteView): role_required = 'part.change' -class PartAttachmentDelete(AjaxDeleteView): - """ View for deleting a PartAttachment """ - - model = PartAttachment - ajax_form_title = _("Delete Part Attachment") - ajax_template_name = "attachment_delete.html" - context_object_name = "attachment" - - role_required = 'part.change' - - def get_data(self): - return { - 'danger': _('Deleted part attachment') - } - - class PartTestTemplateCreate(AjaxCreateView): """ View for creating a PartTestTemplate """ diff --git a/InvenTree/stock/templates/stock/item_attachments.html b/InvenTree/stock/templates/stock/item_attachments.html index 13e886d8a5..f58d5db063 100644 --- a/InvenTree/stock/templates/stock/item_attachments.html +++ b/InvenTree/stock/templates/stock/item_attachments.html @@ -73,12 +73,15 @@ $("#attachment-table").on('click', '.attachment-edit-button', function() { $("#attachment-table").on('click', '.attachment-delete-button', function() { var button = $(this); - var url = `/stock/item/attachment/${button.attr('pk')}/delete/`; + var pk = button.attr('pk'); - launchModalForm(url, { - success: function() { - location.reload(); - } + var url = `/api/stock/attachment/${pk}/`; + + constructForm(url, { + method: 'DELETE', + confirmMessage: '{% trans "Confirm Delete Operation" %}', + title: '{% trans "Delete Attachment" %}', + reload: true, }); }); diff --git a/InvenTree/stock/urls.py b/InvenTree/stock/urls.py index eb0acbbef2..3e38d48f0e 100644 --- a/InvenTree/stock/urls.py +++ b/InvenTree/stock/urls.py @@ -62,11 +62,6 @@ stock_urls = [ url(r'^item/uninstall/', views.StockItemUninstall.as_view(), name='stock-item-uninstall'), - # URLs for StockItem attachments - url(r'^item/attachment/', include([ - url(r'^(?P\d+)/delete/', views.StockItemAttachmentDelete.as_view(), name='stock-item-attachment-delete'), - ])), - # URLs for StockItem tests url(r'^item/test/', include([ url(r'^new/', views.StockItemTestResultCreate.as_view(), name='stock-item-test-create'), diff --git a/InvenTree/stock/views.py b/InvenTree/stock/views.py index 5b41bfe1b2..e8a3b8614c 100644 --- a/InvenTree/stock/views.py +++ b/InvenTree/stock/views.py @@ -32,7 +32,7 @@ from datetime import datetime, timedelta from company.models import Company, SupplierPart from part.models import Part -from .models import StockItem, StockLocation, StockItemTracking, StockItemAttachment, StockItemTestResult +from .models import StockItem, StockLocation, StockItemTracking, StockItemTestResult import common.settings from common.models import InvenTreeSetting @@ -255,22 +255,6 @@ class StockLocationQRCode(QRCodeView): return None -class StockItemAttachmentDelete(AjaxDeleteView): - """ - View for deleting a StockItemAttachment object. - """ - - model = StockItemAttachment - ajax_form_title = _("Delete Stock Item Attachment") - ajax_template_name = "attachment_delete.html" - context_object_name = "attachment" - - def get_data(self): - return { - 'danger': _("Deleted attachment"), - } - - class StockItemAssignToCustomer(AjaxUpdateView): """ View for manually assigning a StockItem to a Customer