From 3c02c918b236ca9872b969272e8ef0a6d9a73711 Mon Sep 17 00:00:00 2001 From: Matthias Date: Fri, 21 Jan 2022 01:12:11 +0100 Subject: [PATCH 01/94] reduce code in wizard templates --- .../order/order_wizard/po_upload.html | 53 ++----------------- .../part/import_wizard/part_upload.html | 49 ++--------------- .../templates/patterns/wizard/upload.html | 45 ++++++++++++++++ 3 files changed, 54 insertions(+), 93 deletions(-) create mode 100644 InvenTree/templates/patterns/wizard/upload.html diff --git a/InvenTree/order/templates/order/order_wizard/po_upload.html b/InvenTree/order/templates/order/order_wizard/po_upload.html index 5c680e509c..3b20f356f3 100644 --- a/InvenTree/order/templates/order/order_wizard/po_upload.html +++ b/InvenTree/order/templates/order/order_wizard/po_upload.html @@ -10,54 +10,11 @@ {% endblock %} {% block page_content %} - -
-
- {% block heading %} -

{% trans "Upload File for Purchase Order" %}

- {{ wizard.form.media }} - {% endblock %} -
-
- {% block details %} - {% if order.status == PurchaseOrderStatus.PENDING and roles.purchase_order.change %} - -

{% blocktrans with step=wizard.steps.step1 count=wizard.steps.count %}Step {{step}} of {{count}}{% endblocktrans %} - {% if description %}- {{ description }}{% endif %}

- - {% block form_alert %} - {% endblock form_alert %} - -
- {% csrf_token %} - {% load crispy_forms_tags %} - - {% block form_buttons_top %} - {% endblock form_buttons_top %} - - - {{ wizard.management_form }} - {% block form_content %} - {% crispy wizard.form %} - {% endblock form_content %} -
- - {% block form_buttons_bottom %} - {% if wizard.steps.prev %} - - {% endif %} - -
- {% endblock form_buttons_bottom %} - - {% else %} - - {% endif %} - {% endblock details %} -
- + {% trans "Upload File for Purchase Order" as header_text %} + {% order.status == PurchaseOrderStatus.PENDING and roles.purchase_order.change as upload_go_ahead %} + {% trans "Order is already processed. Files cannot be uploaded." as error_text %} + {% 'panel-upload-file' as panel_id %} + {% include "patterns/wizard/upload.html" with header_text=header_text upload_go_ahead=upload_go_ahead error_text=error_text panel_id=panel_id %} {% endblock %} {% block js_ready %} diff --git a/InvenTree/part/templates/part/import_wizard/part_upload.html b/InvenTree/part/templates/part/import_wizard/part_upload.html index 666afad1cb..4fef625d1d 100644 --- a/InvenTree/part/templates/part/import_wizard/part_upload.html +++ b/InvenTree/part/templates/part/import_wizard/part_upload.html @@ -10,51 +10,10 @@ {% endblock %} {% block content %} -
-
-

- {% trans "Import Parts from File" %} - {{ wizard.form.media }} -

-
-
- {% if roles.part.change %} - -

{% blocktrans with step=wizard.steps.step1 count=wizard.steps.count %}Step {{step}} of {{count}}{% endblocktrans %} - {% if description %}- {{ description }}{% endif %}

- - {% block form_alert %} - {% endblock form_alert %} - -
- {% csrf_token %} - {% load crispy_forms_tags %} - - {% block form_buttons_top %} - {% endblock form_buttons_top %} - - - {{ wizard.management_form }} - {% block form_content %} - {% crispy wizard.form %} - {% endblock form_content %} -
- - {% block form_buttons_bottom %} - {% if wizard.steps.prev %} - - {% endif %} - -
- {% endblock form_buttons_bottom %} - - {% else %} - - {% endif %} -
-
+ {% trans "Import Parts from File" as header_text %} + {% roles.part.change as upload_go_ahead %} + {% trans "Unsuffitient privileges." as error_text %} + {% include "patterns/wizard/upload.html" with header_text=header_text upload_go_ahead=upload_go_ahead error_text=error_text %} {% endblock %} {% block js_ready %} diff --git a/InvenTree/templates/patterns/wizard/upload.html b/InvenTree/templates/patterns/wizard/upload.html new file mode 100644 index 0000000000..1688e538bf --- /dev/null +++ b/InvenTree/templates/patterns/wizard/upload.html @@ -0,0 +1,45 @@ +
+
+

+ {{ header_text }} + {{ wizard.form.media }} +

+
+
+ {% if upload_go_ahead %} + +

{% blocktrans with step=wizard.steps.step1 count=wizard.steps.count %}Step {{step}} of {{count}}{% endblocktrans %} + {% if description %}- {{ description }}{% endif %}

+ + {% block form_alert %} + {% endblock form_alert %} + +
+ {% csrf_token %} + {% load crispy_forms_tags %} + + {% block form_buttons_top %} + {% endblock form_buttons_top %} + + + {{ wizard.management_form }} + {% block form_content %} + {% crispy wizard.form %} + {% endblock form_content %} +
+ + {% block form_buttons_bottom %} + {% if wizard.steps.prev %} + + {% endif %} + +
+ {% endblock form_buttons_bottom %} + + {% else %} + + {% endif %} +
+
\ No newline at end of file From 2e0198e7cd177ffc833b6d0157c57d47c458554b Mon Sep 17 00:00:00 2001 From: Matthias Date: Fri, 21 Jan 2022 01:20:32 +0100 Subject: [PATCH 02/94] refactor field matching --- .../order/order_wizard/match_fields.html | 99 +------------------ .../part/bom_upload/match_fields.html | 99 +------------------ .../part/import_wizard/match_fields.html | 99 +------------------ .../patterns/wizard/match_fields.html | 98 ++++++++++++++++++ 4 files changed, 101 insertions(+), 294 deletions(-) create mode 100644 InvenTree/templates/patterns/wizard/match_fields.html diff --git a/InvenTree/order/templates/order/order_wizard/match_fields.html b/InvenTree/order/templates/order/order_wizard/match_fields.html index c7a9b02fd2..d4c91efeb3 100644 --- a/InvenTree/order/templates/order/order_wizard/match_fields.html +++ b/InvenTree/order/templates/order/order_wizard/match_fields.html @@ -1,99 +1,2 @@ {% extends "order/order_wizard/po_upload.html" %} -{% load inventree_extras %} -{% load i18n %} -{% load static %} - -{% block form_alert %} -{% if missing_columns and missing_columns|length > 0 %} - -{% endif %} -{% if duplicates and duplicates|length > 0 %} - -{% endif %} -{% endblock form_alert %} - -{% block form_buttons_top %} - {% if wizard.steps.prev %} - - {% endif %} - -{% endblock form_buttons_top %} - -{% block form_content %} - - - {% trans "File Fields" %} - - {% for col in form %} - -
- - {{ col.name }} - -
- - {% endfor %} - - - - - {% trans "Match Fields" %} - - {% for col in form %} - - {{ col }} - {% for duplicate in duplicates %} - {% if duplicate == col.value %} - - {% endif %} - {% endfor %} - - {% endfor %} - - {% for row in rows %} - {% with forloop.counter as row_index %} - - - - - {{ row_index }} - {% for item in row.data %} - - - {{ item }} - - {% endfor %} - - {% endwith %} - {% endfor %} - -{% endblock form_content %} - -{% block form_buttons_bottom %} -{% endblock form_buttons_bottom %} - -{% block js_ready %} -{{ block.super }} - -$('.fieldselect').select2({ - width: '100%', - matcher: partialMatcher, -}); - -{% endblock %} \ No newline at end of file +{% include "patterns/wizard/match_fields.html" %} \ No newline at end of file diff --git a/InvenTree/part/templates/part/bom_upload/match_fields.html b/InvenTree/part/templates/part/bom_upload/match_fields.html index b09260cf46..1336bfc9eb 100644 --- a/InvenTree/part/templates/part/bom_upload/match_fields.html +++ b/InvenTree/part/templates/part/bom_upload/match_fields.html @@ -1,99 +1,2 @@ {% extends "part/bom_upload/upload_file.html" %} -{% load inventree_extras %} -{% load i18n %} -{% load static %} - -{% block form_alert %} -{% if missing_columns and missing_columns|length > 0 %} - -{% endif %} -{% if duplicates and duplicates|length > 0 %} - -{% endif %} -{% endblock form_alert %} - -{% block form_buttons_top %} - {% if wizard.steps.prev %} - - {% endif %} - -{% endblock form_buttons_top %} - -{% block form_content %} - - - {% trans "File Fields" %} - - {% for col in form %} - -
- - {{ col.name }} - -
- - {% endfor %} - - - - - {% trans "Match Fields" %} - - {% for col in form %} - - {{ col }} - {% for duplicate in duplicates %} - {% if duplicate == col.value %} - - {% endif %} - {% endfor %} - - {% endfor %} - - {% for row in rows %} - {% with forloop.counter as row_index %} - - - - - {{ row_index }} - {% for item in row.data %} - - - {{ item }} - - {% endfor %} - - {% endwith %} - {% endfor %} - -{% endblock form_content %} - -{% block form_buttons_bottom %} -{% endblock form_buttons_bottom %} - -{% block js_ready %} -{{ block.super }} - -$('.fieldselect').select2({ - width: '100%', - matcher: partialMatcher, -}); - -{% endblock %} \ No newline at end of file +{% include "patterns/wizard/match_fields.html" %} \ No newline at end of file diff --git a/InvenTree/part/templates/part/import_wizard/match_fields.html b/InvenTree/part/templates/part/import_wizard/match_fields.html index 9c33717772..8bde89a175 100644 --- a/InvenTree/part/templates/part/import_wizard/match_fields.html +++ b/InvenTree/part/templates/part/import_wizard/match_fields.html @@ -1,99 +1,2 @@ {% extends "part/import_wizard/part_upload.html" %} -{% load inventree_extras %} -{% load i18n %} -{% load static %} - -{% block form_alert %} -{% if missing_columns and missing_columns|length > 0 %} - -{% endif %} -{% if duplicates and duplicates|length > 0 %} - -{% endif %} -{% endblock form_alert %} - -{% block form_buttons_top %} - {% if wizard.steps.prev %} - - {% endif %} - -{% endblock form_buttons_top %} - -{% block form_content %} - - - {% trans "File Fields" %} - - {% for col in form %} - -
- - {{ col.name }} - -
- - {% endfor %} - - - - - {% trans "Match Fields" %} - - {% for col in form %} - - {{ col }} - {% for duplicate in duplicates %} - {% if duplicate == col.value %} - - {% endif %} - {% endfor %} - - {% endfor %} - - {% for row in rows %} - {% with forloop.counter as row_index %} - - - - - {{ row_index }} - {% for item in row.data %} - - - {{ item }} - - {% endfor %} - - {% endwith %} - {% endfor %} - -{% endblock form_content %} - -{% block form_buttons_bottom %} -{% endblock form_buttons_bottom %} - -{% block js_ready %} -{{ block.super }} - -$('.fieldselect').select2({ - width: '100%', - matcher: partialMatcher, -}); - -{% endblock %} \ No newline at end of file +{% include "patterns/wizard/match_fields.html" %} \ No newline at end of file diff --git a/InvenTree/templates/patterns/wizard/match_fields.html b/InvenTree/templates/patterns/wizard/match_fields.html new file mode 100644 index 0000000000..bb119d39a5 --- /dev/null +++ b/InvenTree/templates/patterns/wizard/match_fields.html @@ -0,0 +1,98 @@ +{% load inventree_extras %} +{% load i18n %} +{% load static %} + +{% block form_alert %} +{% if missing_columns and missing_columns|length > 0 %} + +{% endif %} +{% if duplicates and duplicates|length > 0 %} + +{% endif %} +{% endblock form_alert %} + +{% block form_buttons_top %} + {% if wizard.steps.prev %} + + {% endif %} + +{% endblock form_buttons_top %} + +{% block form_content %} + + + {% trans "File Fields" %} + + {% for col in form %} + +
+ + {{ col.name }} + +
+ + {% endfor %} + + + + + {% trans "Match Fields" %} + + {% for col in form %} + + {{ col }} + {% for duplicate in duplicates %} + {% if duplicate == col.value %} + + {% endif %} + {% endfor %} + + {% endfor %} + + {% for row in rows %} + {% with forloop.counter as row_index %} + + + + + {{ row_index }} + {% for item in row.data %} + + + {{ item }} + + {% endfor %} + + {% endwith %} + {% endfor %} + +{% endblock form_content %} + +{% block form_buttons_bottom %} +{% endblock form_buttons_bottom %} + +{% block js_ready %} +{{ block.super }} + +$('.fieldselect').select2({ + width: '100%', + matcher: partialMatcher, +}); + +{% endblock %} From f04de517d108a194e8ac21d27c687db58791b8fc Mon Sep 17 00:00:00 2001 From: Matthias Date: Fri, 21 Jan 2022 02:11:34 +0100 Subject: [PATCH 03/94] fix tags --- InvenTree/part/templates/part/part_app_base.html | 2 +- InvenTree/stock/templates/stock/item_base.html | 2 +- InvenTree/stock/templates/stock/stock_app_base.html | 2 +- InvenTree/templates/InvenTree/settings/plugin.html | 2 +- InvenTree/templates/InvenTree/settings/user.html | 2 +- InvenTree/templates/base.html | 2 +- InvenTree/templates/sidebar_header.html | 2 +- InvenTree/templates/sidebar_item.html | 2 +- InvenTree/templates/sidebar_link.html | 2 +- InvenTree/templates/sidebar_toggle.html | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/InvenTree/part/templates/part/part_app_base.html b/InvenTree/part/templates/part/part_app_base.html index 0b578aaadd..c7b38f9cc2 100644 --- a/InvenTree/part/templates/part/part_app_base.html +++ b/InvenTree/part/templates/part/part_app_base.html @@ -14,7 +14,7 @@ {% endblock %} {% block breadcrumbs %} - + {% if part %} {% include "part/cat_link.html" with category=part.category part=part %} {% else %} diff --git a/InvenTree/stock/templates/stock/item_base.html b/InvenTree/stock/templates/stock/item_base.html index af558ced12..cb4ecc3059 100644 --- a/InvenTree/stock/templates/stock/item_base.html +++ b/InvenTree/stock/templates/stock/item_base.html @@ -10,7 +10,7 @@ {% endblock %} {% block breadcrumbs %} - + {% include 'stock/loc_link.html' with location=item.location %} {% endblock %} diff --git a/InvenTree/stock/templates/stock/stock_app_base.html b/InvenTree/stock/templates/stock/stock_app_base.html index 93994ebd21..cf30a3221a 100644 --- a/InvenTree/stock/templates/stock/stock_app_base.html +++ b/InvenTree/stock/templates/stock/stock_app_base.html @@ -18,7 +18,7 @@ {% endblock %} {% block breadcrumbs %} - + {% if item %} {% include 'stock/loc_link.html' with location=item.location %} {% else %} diff --git a/InvenTree/templates/InvenTree/settings/plugin.html b/InvenTree/templates/InvenTree/settings/plugin.html index 7b428e161f..caee7c92bf 100644 --- a/InvenTree/templates/InvenTree/settings/plugin.html +++ b/InvenTree/templates/InvenTree/settings/plugin.html @@ -77,7 +77,7 @@ {% endif %} {% if plugin.website %} - + {% endif %} {{ plugin.author }} diff --git a/InvenTree/templates/InvenTree/settings/user.html b/InvenTree/templates/InvenTree/settings/user.html index 9bd0dba26e..32bc4d43e7 100644 --- a/InvenTree/templates/InvenTree/settings/user.html +++ b/InvenTree/templates/InvenTree/settings/user.html @@ -65,7 +65,7 @@ {% if emailaddress.primary %} - {{ emailaddress.email }} + {{ emailaddress.email }} {% else %} {{ emailaddress.email }} {% endif %} diff --git a/InvenTree/templates/base.html b/InvenTree/templates/base.html index fd3e496f80..05d0712e6a 100644 --- a/InvenTree/templates/base.html +++ b/InvenTree/templates/base.html @@ -94,7 +94,7 @@ {% if server_restart_required and not demo_mode %}