diff --git a/InvenTree/order/templates/order/po_attachments.html b/InvenTree/order/templates/order/po_attachments.html
index 79a0105a61..a08b618fca 100644
--- a/InvenTree/order/templates/order/po_attachments.html
+++ b/InvenTree/order/templates/order/po_attachments.html
@@ -12,44 +12,8 @@
-
+{% include "attachment_table.html" with attachments=order.attachments.all %}
-
-
-
- {% trans "File" %} |
- {% trans "Comment" %} |
- {% trans "Uploaded" %} |
- |
-
-
-
- {% for attachment in order.attachments.all %}
-
- {{ attachment.basename }} |
- {{ attachment.comment }} |
-
- {% if attachment.upload_date %}{{ attachment.upload_date }}{% endif %}
- {% if attachment.user %}{{ attachment.user.username }}{% endif %}
- |
-
-
-
-
-
- |
-
- {% endfor %}
-
-
{% endblock %}
@@ -66,8 +30,10 @@ $("#new-attachment").click(function() {
$("#attachment-table").on('click', '.attachment-edit-button', function() {
var button = $(this);
+
+ var url = `/order/purchase-order/attachment/${button.attr('pk')}/edit/`;
- launchModalForm(button.attr('url'), {
+ launchModalForm(url, {
reload: true,
});
});
@@ -75,7 +41,11 @@ $("#attachment-table").on('click', '.attachment-edit-button', function() {
$("#attachment-table").on('click', '.attachment-delete-button', function() {
var button = $(this);
- launchModalForm(button.attr('url'), {
+ var url = `/order/purchase-order/attachment/${button.attr('pk')}/delete/`;
+
+ console.log("url: " + url);
+
+ launchModalForm(url, {
reload: true,
});
});
diff --git a/InvenTree/order/templates/order/so_attachments.html b/InvenTree/order/templates/order/so_attachments.html
index 228d42c445..aff62213e5 100644
--- a/InvenTree/order/templates/order/so_attachments.html
+++ b/InvenTree/order/templates/order/so_attachments.html
@@ -12,44 +12,7 @@
-
-
-
-
-
- {% trans "File" %} |
- {% trans "Comment" %} |
- {% trans "Uploaded" %} |
- |
-
-
-
- {% for attachment in order.attachments.all %}
-
- {{ attachment.basename }} |
- {{ attachment.comment }} |
-
- {% if attachment.upload_date %}{{ attachment.upload_date }}{% endif %}
- {% if attachment.user %}{{ attachment.user.username }}{% endif %}
- |
-
-
-
-
-
- |
-
- {% endfor %}
-
-
+{% include "attachment_table.html" with attachments=order.attachments.all %}
{% endblock %}
@@ -67,7 +30,9 @@ $("#new-attachment").click(function() {
$("#attachment-table").on('click', '.attachment-edit-button', function() {
var button = $(this);
- launchModalForm(button.attr('url'), {
+ var url = `/order/sales-order/attachment/${button.attr('pk')}/edit/`;
+
+ launchModalForm(url, {
reload: true,
});
});
@@ -75,7 +40,9 @@ $("#attachment-table").on('click', '.attachment-edit-button', function() {
$("#attachment-table").on('click', '.attachment-delete-button', function() {
var button = $(this);
- launchModalForm(button.attr('url'), {
+ var url = `/order/sales-order/attachment/${button.attr('pk')}/delete/`;
+
+ launchModalForm(url, {
reload: true,
});
});
diff --git a/InvenTree/order/urls.py b/InvenTree/order/urls.py
index daa83eb5ab..22104df5c7 100644
--- a/InvenTree/order/urls.py
+++ b/InvenTree/order/urls.py
@@ -42,7 +42,7 @@ purchase_order_urls = [
])),
])),
- url(r'^attachments/', include([
+ url(r'^attachment/', include([
url(r'^new/', views.PurchaseOrderAttachmentCreate.as_view(), name='po-attachment-create'),
url(r'^(?P\d+)/edit/', views.PurchaseOrderAttachmentEdit.as_view(), name='po-attachment-edit'),
url(r'^(?P\d+)/delete/', views.PurchaseOrderAttachmentDelete.as_view(), name='po-attachment-delete'),
@@ -86,7 +86,7 @@ sales_order_urls = [
])),
])),
- url(r'^attachments/', include([
+ url(r'^attachment/', include([
url(r'^new/', views.SalesOrderAttachmentCreate.as_view(), name='so-attachment-create'),
url(r'^(?P\d+)/edit/', views.SalesOrderAttachmentEdit.as_view(), name='so-attachment-edit'),
url(r'^(?P\d+)/delete/', views.SalesOrderAttachmentDelete.as_view(), name='so-attachment-delete'),
diff --git a/InvenTree/part/templates/part/attachments.html b/InvenTree/part/templates/part/attachments.html
index f569ae207a..965645b748 100644
--- a/InvenTree/part/templates/part/attachments.html
+++ b/InvenTree/part/templates/part/attachments.html
@@ -9,59 +9,7 @@
-
-
-
-
-
-
- {% trans "File" %} |
- {% trans "Comment" %} |
- {% trans "Uploaded" %} |
- |
-
-
-
- {% for attachment in part.attachments.all %}
-
- {{ attachment.basename }} |
- {{ attachment.comment }} |
-
- {% if attachment.upload_date %}{{ attachment.upload_date }}{% endif %}
- {% if attachment.user %}{{ attachment.user.username }}{% endif %}
- |
-
-
-
-
-
- |
-
- {% endfor %}
-
-{% if part.variant_of and part.variant_of.attachments.count > 0 %}
-
-
- Attachments for template part {{ part.variant_of.full_name }}
- |
-
-{% for attachment in part.variant_of.attachments.all %}
-
- {{ attachment.basename }} |
- {{ attachment.comment }} |
- |
-
-{% endfor %}
-{% endif %}
-
+{% include "attachment_table.html" with attachments=part.attachments.all %}
{% endblock %}
@@ -78,7 +26,9 @@
$("#attachment-table").on('click', '.attachment-edit-button', function() {
var button = $(this);
- launchModalForm(button.attr('url'),
+ var url = `/part/attachment/${button.attr('pk')}/edit/`;
+
+ launchModalForm(url,
{
reload: true,
});
@@ -87,7 +37,9 @@
$("#attachment-table").on('click', '.attachment-delete-button', function() {
var button = $(this);
- launchModalForm(button.attr('url'), {
+ var url = `/part/attachment/${button.attr('pk')}/delete/`;
+
+ launchModalForm(url, {
success: function() {
location.reload();
}
diff --git a/InvenTree/stock/templates/stock/item_attachments.html b/InvenTree/stock/templates/stock/item_attachments.html
index 34eaa61703..2d056afbcf 100644
--- a/InvenTree/stock/templates/stock/item_attachments.html
+++ b/InvenTree/stock/templates/stock/item_attachments.html
@@ -10,45 +10,7 @@
{% trans "Stock Item Attachments" %}
-
-
-
-
-
-
- {% trans "File" %} |
- {% trans "Comment" %} |
- {% trans "Uploaded" %} |
- |
-
-
-
- {% for attachment in item.attachments.all %}
-
- {{ attachment.basename }} |
- {{ attachment.comment }} |
-
- {% if attachment.upload_date %}{{ attachment.upload_date }}{% endif %}
- {% if attachment.user %}{{ attachment.user.username }}{% endif %}
- |
-
-
-
-
-
- |
-
- {% endfor %}
-
-
+{% include "attachment_table.html" with attachments=item.attachments.all %}
{% endblock %}
@@ -65,7 +27,9 @@ $("#new-attachment").click(function() {
$("#attachment-table").on('click', '.attachment-edit-button', function() {
var button = $(this);
- launchModalForm(button.attr('url'),
+ var url = `/stock/item/attachment/${button.attr('pk')}/edit/`;
+
+ launchModalForm(url,
{
reload: true,
});
@@ -74,7 +38,9 @@ $("#attachment-table").on('click', '.attachment-edit-button', function() {
$("#attachment-table").on('click', '.attachment-delete-button', function() {
var button = $(this);
- launchModalForm(button.attr('url'), {
+ var url = `/stock/item/attachment/${button.attr('pk')}/delete/`;
+
+ launchModalForm(url, {
success: function() {
location.reload();
}
diff --git a/InvenTree/templates/attachment_table.html b/InvenTree/templates/attachment_table.html
new file mode 100644
index 0000000000..090ae566f6
--- /dev/null
+++ b/InvenTree/templates/attachment_table.html
@@ -0,0 +1,40 @@
+{% load i18n %}
+
+
+
+
+
+
+ {% trans "File" %} |
+ {% trans "Comment" %} |
+ {% trans "Uploaded" %} |
+ |
+
+
+
+ {% for attachment in attachments %}
+
+ {{ attachment.basename }} |
+ {{ attachment.comment }} |
+
+ {% if attachment.upload_date %}{{ attachment.upload_date }}{% endif %}
+ {% if attachment.user %}{{ attachment.user.username }}{% endif %}
+ |
+
+
+
+
+
+ |
+
+ {% endfor %}
+
+
\ No newline at end of file