mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Refactor delete view for PartAttachment and StockItemAttachment
This commit is contained in:
parent
4e23dbd0af
commit
8f47035a7b
@ -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,
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -17,10 +17,6 @@ part_related_urls = [
|
||||
url(r'^(?P<pk>\d+)/delete/?', views.PartRelatedDelete.as_view(), name='part-related-delete'),
|
||||
]
|
||||
|
||||
part_attachment_urls = [
|
||||
url(r'^(?P<pk>\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<pk>\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)),
|
||||
|
||||
|
@ -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 """
|
||||
|
||||
|
@ -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,
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -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<pk>\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'),
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user