mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Can now successfully edit or delete a purchase-order attachment
This commit is contained in:
parent
5af2fae120
commit
4a259dc146
@ -33,10 +33,10 @@
|
||||
<td>{{ attachment.comment }}</td>
|
||||
<td>
|
||||
<div class='btn-group' style='float: right;'>
|
||||
<button type='button' class='btn btn-default btn-glyph attachment-edit-button' url="{% url 'part-attachment-edit' attachment.id %}" data-toggle='tooltip' title='{% trans "Edit attachment" %}'>
|
||||
<button type='button' class='btn btn-default btn-glyph attachment-edit-button' url="{% url 'po-attachment-edit' attachment.id %}" data-toggle='tooltip' title='{% trans "Edit attachment" %}'>
|
||||
<span class='glyphicon glyphicon-edit'/>
|
||||
</button>
|
||||
<button type='button' class='btn btn-default btn-glyph attachment-delete-button' url="{% url 'part-attachment-delete' attachment.id %}" data-toggle='tooltip' title='{% trans "Delete attachment" %}'>
|
||||
<button type='button' class='btn btn-default btn-glyph attachment-delete-button' url="{% url 'po-attachment-delete' attachment.id %}" data-toggle='tooltip' title='{% trans "Delete attachment" %}'>
|
||||
<span class='glyphicon glyphicon-trash'/>
|
||||
</button>
|
||||
</div>
|
||||
@ -62,13 +62,17 @@ $("#new-attachment").click(function() {
|
||||
$("#attachment-table").on('click', '.attachment-edit-button', function() {
|
||||
var button = $(this);
|
||||
|
||||
// TODO
|
||||
launchModalForm(button.attr('url'), {
|
||||
reload: true,
|
||||
});
|
||||
});
|
||||
|
||||
$("#attachment-table").on('click', '.attachment-delete-button', function() {
|
||||
var button = $(this);
|
||||
|
||||
// TODO
|
||||
launchModalForm(button.attr('url'), {
|
||||
reload: true,
|
||||
});
|
||||
});
|
||||
|
||||
$("#attachment-table").inventreeTable({
|
||||
|
7
InvenTree/order/templates/order/po_delete.html
Normal file
7
InvenTree/order/templates/order/po_delete.html
Normal file
@ -0,0 +1,7 @@
|
||||
{% extends "modal_delete_form.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block pre_form_content %}
|
||||
{% trans "Are you sure you want to delete this attachment?" %}
|
||||
<br>
|
||||
{% endblock %}
|
@ -11,7 +11,8 @@ from . import views
|
||||
|
||||
purchase_order_attachment_urls = [
|
||||
url(r'^new/', views.PurchaseOrderAttachmentCreate.as_view(), name='po-attachment-create'),
|
||||
#url(r'^(?P<pk>\d+)/edit/', views.PurchaseOrderAttachmentEdit.as_view(), name='po-attachment-edit'),
|
||||
url(r'^(?P<pk>\d+)/edit/', views.PurchaseOrderAttachmentEdit.as_view(), name='po-attachment-edit'),
|
||||
url(r'^(?P<pk>\d+)/delete/', views.PurchaseOrderAttachmentDelete.as_view(), name='po-attachment-delete'),
|
||||
]
|
||||
|
||||
purchase_order_detail_urls = [
|
||||
|
@ -113,6 +113,41 @@ class PurchaseOrderAttachmentCreate(AjaxCreateView):
|
||||
return form
|
||||
|
||||
|
||||
class PurchaseOrderAttachmentEdit(AjaxUpdateView):
|
||||
""" View for editing a PurchaseOrderAttachment object """
|
||||
|
||||
model = PurchaseOrderAttachment
|
||||
form_class = order_forms.EditPurchaseOrderAttachmentForm
|
||||
ajax_form_title = _("Edit Attachment")
|
||||
|
||||
def get_data(self):
|
||||
return {
|
||||
'success': _('Attachment updated')
|
||||
}
|
||||
|
||||
def get_form(self):
|
||||
form = super(AjaxUpdateView, self).get_form()
|
||||
|
||||
# Hide the 'order' field
|
||||
form.fields['order'].widget = HiddenInput()
|
||||
|
||||
return form
|
||||
|
||||
|
||||
class PurchaseOrderAttachmentDelete(AjaxDeleteView):
|
||||
""" View for deleting a PurchaseOrderAttachment """
|
||||
|
||||
model = PurchaseOrderAttachment
|
||||
ajax_form_title = _("Delete Attachment")
|
||||
ajax_template_name = "order/po_delete.html"
|
||||
context_object_name = "attachment"
|
||||
|
||||
def get_data(self):
|
||||
return {
|
||||
"danger": _("Deleted attachment")
|
||||
}
|
||||
|
||||
|
||||
class PurchaseOrderNotes(UpdateView):
|
||||
""" View for updating the 'notes' field of a PurchaseOrder """
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
{% extends "modal_delete_form.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block pre_form_content %}
|
||||
Are you sure you wish to delete this attachment?
|
||||
{% trans "Are you sure you want to delete this attachment?" %}
|
||||
<br>
|
||||
This will remove the file '{{ attachment.basename }}'.
|
||||
{% endblock %}
|
@ -112,6 +112,7 @@ class PartAttachmentCreate(AjaxCreateView):
|
||||
|
||||
class PartAttachmentEdit(AjaxUpdateView):
|
||||
""" View for editing a PartAttachment object """
|
||||
|
||||
model = PartAttachment
|
||||
form_class = part_forms.EditPartAttachmentForm
|
||||
ajax_template_name = 'modal_form.html'
|
||||
|
Loading…
Reference in New Issue
Block a user