mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Refactor delete views for SalesOrderAttachment and PurchaseOrderAttachment
This commit is contained in:
parent
4d8e88c779
commit
4e23dbd0af
@ -76,17 +76,6 @@ $("#attachment-table").on('click', '.attachment-delete-button', function() {
|
||||
title: '{% trans "Delete Attachment" %}',
|
||||
reload: true,
|
||||
});
|
||||
|
||||
return;
|
||||
|
||||
var url = `/build/attachment/${pk}/delete/`;
|
||||
|
||||
launchModalForm(
|
||||
url,
|
||||
{
|
||||
reload: true,
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
$("#attachment-table").inventreeTable({});
|
||||
|
@ -12,7 +12,7 @@ from django.forms import HiddenInput
|
||||
from django.urls import reverse
|
||||
|
||||
from part.models import Part
|
||||
from .models import Build, BuildItem, BuildOrderAttachment
|
||||
from .models import Build, BuildItem
|
||||
from . import forms
|
||||
from stock.models import StockLocation, StockItem
|
||||
|
||||
|
@ -259,7 +259,7 @@ class SOAttachmentList(generics.ListCreateAPIView, AttachmentMixin):
|
||||
]
|
||||
|
||||
|
||||
class SOAttachmentDetail(generics.RetrieveUpdateAPIView, AttachmentMixin):
|
||||
class SOAttachmentDetail(generics.RetrieveUpdateDestroyAPIView, AttachmentMixin):
|
||||
"""
|
||||
Detail endpoint for SalesOrderAttachment
|
||||
"""
|
||||
|
@ -71,9 +71,12 @@ $("#attachment-table").on('click', '.attachment-edit-button', function() {
|
||||
$("#attachment-table").on('click', '.attachment-delete-button', function() {
|
||||
var button = $(this);
|
||||
|
||||
var url = `/order/purchase-order/attachment/${button.attr('pk')}/delete/`;
|
||||
var pk = button.attr('pk');
|
||||
|
||||
launchModalForm(url, {
|
||||
constructForm(`/api/order/po/attachment/${pk}/`, {
|
||||
method: 'DELETE',
|
||||
confirmMessage: '{% trans "Confirm Delete Operation" %}',
|
||||
title: '{% trans "Delete Attachment" %}',
|
||||
reload: true,
|
||||
});
|
||||
});
|
||||
|
@ -72,9 +72,12 @@ $("#attachment-table").on('click', '.attachment-edit-button', function() {
|
||||
$("#attachment-table").on('click', '.attachment-delete-button', function() {
|
||||
var button = $(this);
|
||||
|
||||
var url = `/order/sales-order/attachment/${button.attr('pk')}/delete/`;
|
||||
var pk = button.attr('pk');
|
||||
|
||||
launchModalForm(url, {
|
||||
constructForm(`/api/order/so/attachment/${pk}/`, {
|
||||
method: 'DELETE',
|
||||
confirmMessage: '{% trans "Confirm Delete Operation" %}',
|
||||
title: '{% trans "Delete Attachment" %}',
|
||||
reload: true,
|
||||
});
|
||||
});
|
||||
|
@ -45,10 +45,6 @@ purchase_order_urls = [
|
||||
])),
|
||||
])),
|
||||
|
||||
url(r'^attachment/', include([
|
||||
url(r'^(?P<pk>\d+)/delete/', views.PurchaseOrderAttachmentDelete.as_view(), name='po-attachment-delete'),
|
||||
])),
|
||||
|
||||
# Display complete list of purchase orders
|
||||
url(r'^.*$', views.PurchaseOrderIndex.as_view(), name='po-index'),
|
||||
]
|
||||
@ -88,10 +84,6 @@ sales_order_urls = [
|
||||
])),
|
||||
])),
|
||||
|
||||
url(r'^attachment/', include([
|
||||
url(r'^(?P<pk>\d+)/delete/', views.SalesOrderAttachmentDelete.as_view(), name='so-attachment-delete'),
|
||||
])),
|
||||
|
||||
# Display detail view for a single SalesOrder
|
||||
url(r'^(?P<pk>\d+)/', include(sales_order_detail_urls)),
|
||||
|
||||
|
@ -20,8 +20,8 @@ from django.forms import HiddenInput, IntegerField
|
||||
import logging
|
||||
from decimal import Decimal, InvalidOperation
|
||||
|
||||
from .models import PurchaseOrder, PurchaseOrderLineItem, PurchaseOrderAttachment
|
||||
from .models import SalesOrder, SalesOrderLineItem, SalesOrderAttachment
|
||||
from .models import PurchaseOrder, PurchaseOrderLineItem
|
||||
from .models import SalesOrder, SalesOrderLineItem
|
||||
from .models import SalesOrderAllocation
|
||||
from .admin import POLineItemResource
|
||||
from build.models import Build
|
||||
@ -96,34 +96,6 @@ class SalesOrderDetail(InvenTreeRoleMixin, DetailView):
|
||||
template_name = 'order/sales_order_detail.html'
|
||||
|
||||
|
||||
class PurchaseOrderAttachmentDelete(AjaxDeleteView):
|
||||
""" View for deleting a PurchaseOrderAttachment """
|
||||
|
||||
model = PurchaseOrderAttachment
|
||||
ajax_form_title = _("Delete Attachment")
|
||||
ajax_template_name = "order/delete_attachment.html"
|
||||
context_object_name = "attachment"
|
||||
|
||||
def get_data(self):
|
||||
return {
|
||||
"danger": _("Deleted attachment")
|
||||
}
|
||||
|
||||
|
||||
class SalesOrderAttachmentDelete(AjaxDeleteView):
|
||||
""" View for deleting a SalesOrderAttachment """
|
||||
|
||||
model = SalesOrderAttachment
|
||||
ajax_form_title = _("Delete Attachment")
|
||||
ajax_template_name = "order/delete_attachment.html"
|
||||
context_object_name = "attachment"
|
||||
|
||||
def get_data(self):
|
||||
return {
|
||||
"danger": _("Deleted attachment")
|
||||
}
|
||||
|
||||
|
||||
class PurchaseOrderNotes(InvenTreeRoleMixin, UpdateView):
|
||||
""" View for updating the 'notes' field of a PurchaseOrder """
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user