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() {
|
$("#attachment-table").on('click', '.attachment-delete-button', function() {
|
||||||
var button = $(this);
|
var button = $(this);
|
||||||
|
var pk = button.attr('pk');
|
||||||
|
var url = `/api/part/attachment/${pk}/`;
|
||||||
|
|
||||||
var url = `/part/attachment/${button.attr('pk')}/delete/`;
|
constructForm(url, {
|
||||||
|
method: 'DELETE',
|
||||||
launchModalForm(url, {
|
confirmMessage: '{% trans "Confirm Delete Operation" %}',
|
||||||
success: function() {
|
title: '{% trans "Delete Attachment" %}',
|
||||||
location.reload();
|
reload: true,
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -17,10 +17,6 @@ part_related_urls = [
|
|||||||
url(r'^(?P<pk>\d+)/delete/?', views.PartRelatedDelete.as_view(), name='part-related-delete'),
|
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 = [
|
sale_price_break_urls = [
|
||||||
url(r'^new/', views.PartSalePriceBreakCreate.as_view(), name='sale-price-break-create'),
|
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'),
|
url(r'^(?P<pk>\d+)/edit/', views.PartSalePriceBreakEdit.as_view(), name='sale-price-break-edit'),
|
||||||
@ -146,9 +142,6 @@ part_urls = [
|
|||||||
# Part related
|
# Part related
|
||||||
url(r'^related-parts/', include(part_related_urls)),
|
url(r'^related-parts/', include(part_related_urls)),
|
||||||
|
|
||||||
# Part attachments
|
|
||||||
url(r'^attachment/', include(part_attachment_urls)),
|
|
||||||
|
|
||||||
# Part price breaks
|
# Part price breaks
|
||||||
url(r'^sale-price/', include(sale_price_break_urls)),
|
url(r'^sale-price/', include(sale_price_break_urls)),
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ import io
|
|||||||
from rapidfuzz import fuzz
|
from rapidfuzz import fuzz
|
||||||
from decimal import Decimal, InvalidOperation
|
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 PartParameterTemplate, PartParameter
|
||||||
from .models import PartCategoryParameterTemplate
|
from .models import PartCategoryParameterTemplate
|
||||||
from .models import BomItem
|
from .models import BomItem
|
||||||
@ -154,22 +154,6 @@ class PartRelatedDelete(AjaxDeleteView):
|
|||||||
role_required = 'part.change'
|
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):
|
class PartTestTemplateCreate(AjaxCreateView):
|
||||||
""" View for creating a PartTestTemplate """
|
""" 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() {
|
$("#attachment-table").on('click', '.attachment-delete-button', function() {
|
||||||
var button = $(this);
|
var button = $(this);
|
||||||
|
|
||||||
var url = `/stock/item/attachment/${button.attr('pk')}/delete/`;
|
var pk = button.attr('pk');
|
||||||
|
|
||||||
launchModalForm(url, {
|
var url = `/api/stock/attachment/${pk}/`;
|
||||||
success: function() {
|
|
||||||
location.reload();
|
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'),
|
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
|
# URLs for StockItem tests
|
||||||
url(r'^item/test/', include([
|
url(r'^item/test/', include([
|
||||||
url(r'^new/', views.StockItemTestResultCreate.as_view(), name='stock-item-test-create'),
|
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 company.models import Company, SupplierPart
|
||||||
from part.models import Part
|
from part.models import Part
|
||||||
from .models import StockItem, StockLocation, StockItemTracking, StockItemAttachment, StockItemTestResult
|
from .models import StockItem, StockLocation, StockItemTracking, StockItemTestResult
|
||||||
|
|
||||||
import common.settings
|
import common.settings
|
||||||
from common.models import InvenTreeSetting
|
from common.models import InvenTreeSetting
|
||||||
@ -255,22 +255,6 @@ class StockLocationQRCode(QRCodeView):
|
|||||||
return None
|
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):
|
class StockItemAssignToCustomer(AjaxUpdateView):
|
||||||
"""
|
"""
|
||||||
View for manually assigning a StockItem to a Customer
|
View for manually assigning a StockItem to a Customer
|
||||||
|
Loading…
Reference in New Issue
Block a user