Delete stock tracking entries

This commit is contained in:
Oliver Walters 2019-07-22 10:46:42 +10:00
parent 118a6887bc
commit 8ca14efa53
4 changed files with 32 additions and 1 deletions

View File

@ -344,7 +344,7 @@ function loadStockTrackingTable(table, options) {
// Manually created entries can be edited or deleted
if (!row.system) {
var bEdit = "<button title='Edit tracking entry' class='btn btn-entry-edit btn-default btn-glyph' type='button' url='/stock/track/" + row.pk + "/edit/'><span class='glyphicon glyphicon-edit'/></button>";
var bDel = "<button title='Delete tracking entry' class='btn btn-entry-delete btn-default btn-glyph' type='button' pk='" + row.pk + "'><span class='glyphicon glyphicon-trash'/></button>";
var bDel = "<button title='Delete tracking entry' class='btn btn-entry-delete btn-default btn-glyph' type='button' url='/stock/track/" + row.pk + "/delete/'><span class='glyphicon glyphicon-trash'/></button>";
return "<div class='btn-group' role='group'>" + bEdit + bDel + "</div>";
} else {
@ -376,4 +376,12 @@ function loadStockTrackingTable(table, options) {
reload: true,
});
});
table.on('click', '.btn-entry-delete', function() {
var button = $(this);
launchModalForm(button.attr('url'), {
reload: true,
});
});
}

View File

@ -0,0 +1,9 @@
{% extends "modal_delete_form.html" %}
{% block pre_form_content %}
<div class='alert alert-danger alert-block'>
Are you sure you want to delete this stock tracking entry?
</div>
{% endblock %}

View File

@ -31,6 +31,9 @@ stock_tracking_urls = [
# edit
url(r'^(?P<pk>\d+)/edit/', views.StockItemTrackingEdit.as_view(), name='stock-tracking-edit'),
# delete
url(r'^(?P<pk>\d+)/delete', views.StockItemTrackingDelete.as_view(), name='stock-tracking-delete'),
# list
url('^.*$', views.StockTrackingIndex.as_view(), name='stock-tracking-list')
]

View File

@ -582,6 +582,17 @@ class StockItemDelete(AjaxDeleteView):
ajax_form_title = 'Delete Stock Item'
class StockItemTrackingDelete(AjaxDeleteView):
"""
View to delete a StockItemTracking object
Presents a deletion confirmation form to the user
"""
model = StockItemTracking
ajax_template_name = 'stock/tracking_delete.html'
ajax_form_title = 'Delete Stock Tracking Entry'
class StockTrackingIndex(ListView):
"""
StockTrackingIndex provides a page to display StockItemTracking objects