From ba4c829b10137ca1a37cf7d1dde0b73ce8d0cb57 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 6 Oct 2020 00:20:45 +1100 Subject: [PATCH] Add permission requirements in various part templates --- InvenTree/part/templates/part/bom.html | 2 ++ InvenTree/part/templates/part/build.html | 7 +++++-- InvenTree/part/templates/part/category.html | 6 +++--- InvenTree/part/templates/part/notes.html | 2 ++ InvenTree/part/templates/part/params.html | 8 +++++++ InvenTree/part/templates/part/part_base.html | 22 ++++++++++++++++---- InvenTree/part/templates/part/tabs.html | 9 +++++--- InvenTree/templates/slide.html | 2 +- InvenTree/templates/stock_table.html | 8 +++++++ 9 files changed, 53 insertions(+), 13 deletions(-) diff --git a/InvenTree/part/templates/part/bom.html b/InvenTree/part/templates/part/bom.html index 2653a42575..610e60847a 100644 --- a/InvenTree/part/templates/part/bom.html +++ b/InvenTree/part/templates/part/bom.html @@ -39,10 +39,12 @@ {% elif part.active %} + {% if perms.part.change_part %} {% if part.is_bom_valid == False %} {% endif %} + {% endif %} {% endif %} diff --git a/InvenTree/part/templates/part/build.html b/InvenTree/part/templates/part/build.html index 442693ddeb..ad51d33ab2 100644 --- a/InvenTree/part/templates/part/build.html +++ b/InvenTree/part/templates/part/build.html @@ -1,15 +1,18 @@ {% extends "part/part_base.html" %} {% load static %} +{% load i18n %} {% block details %} {% include 'part/tabs.html' with tab='build' %} -

Part Builds

+

{% trans "Part Builds" %}

{% if part.active %} - + {% if perms.build.add_build %} + + {% endif %} {% endif %}
diff --git a/InvenTree/part/templates/part/category.html b/InvenTree/part/templates/part/category.html index 44c8cd7df9..25417a1d9b 100644 --- a/InvenTree/part/templates/part/category.html +++ b/InvenTree/part/templates/part/category.html @@ -20,7 +20,7 @@ {% endif %}

- {% if perms.part.create_partcategory %} + {% if perms.part.add_partcategory %} @@ -110,7 +110,7 @@
- {% if perms.part.create_part %} + {% if perms.part.add_part %} {% endif %}
@@ -190,7 +190,7 @@ location.href = url; }); - {% if perms.part.create_part %} + {% if perms.part.add_part %} $("#part-create").click(function() { launchModalForm( "{% url 'part-create' %}", diff --git a/InvenTree/part/templates/part/notes.html b/InvenTree/part/templates/part/notes.html index afa215600d..68711c881e 100644 --- a/InvenTree/part/templates/part/notes.html +++ b/InvenTree/part/templates/part/notes.html @@ -29,7 +29,9 @@

{% trans "Part Notes" %}

+ {% if perms.part.change_part %} + {% endif %}

diff --git a/InvenTree/part/templates/part/params.html b/InvenTree/part/templates/part/params.html index 8ad4f61252..9984830242 100644 --- a/InvenTree/part/templates/part/params.html +++ b/InvenTree/part/templates/part/params.html @@ -10,7 +10,9 @@
+ {% if perms.part.add_partparameter %} + {% endif %}
@@ -30,8 +32,12 @@ {{ param.template.units }}
+ {% if perms.part.change_partparameter %} + {% endif %} + {% if perms.part.delete_partparameter %} + {% endif %}
@@ -48,6 +54,7 @@ $('#param-table').inventreeTable({ }); + {% if perms.part.add_partparameter %} $('#param-create').click(function() { launchModalForm("{% url 'part-param-create' %}?part={{ part.id }}", { reload: true, @@ -59,6 +66,7 @@ }], }); }); + {% endif %} $('.param-edit').click(function() { var button = $(this); diff --git a/InvenTree/part/templates/part/part_base.html b/InvenTree/part/templates/part/part_base.html index 1de4976740..6103cb5369 100644 --- a/InvenTree/part/templates/part/part_base.html +++ b/InvenTree/part/templates/part/part_base.html @@ -56,26 +56,36 @@ - + {% endif %} {% if part.purchaseable %} - {% endif %} {% endif %} + {% endif %} + {% if perms.part.add_part or perms.part.change_part or perms.part.delete_part %}
+ {% endif %}
@@ -274,6 +284,7 @@ }); }); + {% if perms.part.change_part %} $("#part-edit").click(function() { launchModalForm( "{% url 'part-edit' part.id %}", @@ -282,6 +293,7 @@ } ); }); + {% endif %} $("#part-order").click(function() { launchModalForm("{% url 'order-parts' %}", { @@ -292,6 +304,7 @@ }); }); + {% if perms.part.add_part %} $("#part-duplicate").click(function() { launchModalForm( "{% url 'part-duplicate' part.id %}", @@ -300,8 +313,9 @@ } ); }); + {% endif %} - {% if not part.active %} + {% if not part.active and perms.part.delete_part %} $("#part-delete").click(function() { launchModalForm( "{% url 'part-delete' part.id %}", diff --git a/InvenTree/part/templates/part/tabs.html b/InvenTree/part/templates/part/tabs.html index 1eab299ed5..02d8672979 100644 --- a/InvenTree/part/templates/part/tabs.html +++ b/InvenTree/part/templates/part/tabs.html @@ -26,14 +26,17 @@ {% if part.assembly %} {% trans "BOM" %}{{ part.bom_count }} + {% if perms.build.view_build %} - {% trans "Build Orders" %}{{ part.builds.count }} + {% trans "Build Orders" %}{{ part.builds.count }} + + {% endif %} {% endif %} {% if part.component or part.used_in_count > 0 %} {% trans "Used In" %} {% if part.used_in_count > 0 %}{{ part.used_in_count }}{% endif %} {% endif %} - {% if part.purchaseable %} + {% if part.purchaseable and perms.order.view_purchaseorder %} {% if part.is_template == False %} {% trans "Suppliers" %} @@ -45,7 +48,7 @@ {% trans "Purchase Orders" %} {{ part.purchase_orders|length }} {% endif %} - {% if part.salable %} + {% if part.salable and perms.order.view_salesorder %}
  • {% trans "Sale Price" %}
  • diff --git a/InvenTree/templates/slide.html b/InvenTree/templates/slide.html index e2fe2e932f..45535786c9 100644 --- a/InvenTree/templates/slide.html +++ b/InvenTree/templates/slide.html @@ -1,3 +1,3 @@
    - +
    \ No newline at end of file diff --git a/InvenTree/templates/stock_table.html b/InvenTree/templates/stock_table.html index c41d2181c9..be26b1a976 100644 --- a/InvenTree/templates/stock_table.html +++ b/InvenTree/templates/stock_table.html @@ -6,19 +6,27 @@ {% if read_only %} {% else %} + {% if perms.stock.add_stockitem %} + {% endif %} + {% if perms.stock.change_stockitem or perms.stock.delete_stockitem %}
    {% endif %} + {% endif %}