From a0d9bf692ed5e41fb03b22578e6acf0423e9dced Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 8 May 2021 20:53:26 +0200 Subject: [PATCH 1/5] simpler code - same function --- InvenTree/common/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/InvenTree/common/views.py b/InvenTree/common/views.py index 1e54663862..a7515c0529 100644 --- a/InvenTree/common/views.py +++ b/InvenTree/common/views.py @@ -195,7 +195,7 @@ class FileManagementFormView(MultiStepFormView): def get_context_data(self, form, **kwargs): context = super().get_context_data(form=form, **kwargs) - if self.steps.current == 'fields' or self.steps.current == 'items': + if self.steps.current in ('fields', 'items'): # Get columns and row data self.columns = self.file_manager.columns() @@ -435,7 +435,7 @@ class FileManagementFormView(MultiStepFormView): } # Data validation - valid = len(self.extra_context_data.get('missing_columns', [])) == 0 and not self.extra_context_data.get('duplicates', []) + valid = not missing_columns and not duplicates return valid From e6372fd6001ebaa3acb12664df54a6f9216d43ca Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 8 May 2021 20:54:23 +0200 Subject: [PATCH 2/5] added translations --- InvenTree/common/views.py | 2 +- InvenTree/order/templates/order/order_wizard/po_upload.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/InvenTree/common/views.py b/InvenTree/common/views.py index a7515c0529..c439b63c09 100644 --- a/InvenTree/common/views.py +++ b/InvenTree/common/views.py @@ -452,7 +452,7 @@ class FileManagementFormView(MultiStepFormView): valid = self.check_field_selection(form) if not valid: - form.add_error(None, 'Fields matching failed') + form.add_error(None, _('Fields matching failed')) elif step == 'items': pass diff --git a/InvenTree/order/templates/order/order_wizard/po_upload.html b/InvenTree/order/templates/order/order_wizard/po_upload.html index 129570417b..84a28cf0a3 100644 --- a/InvenTree/order/templates/order/order_wizard/po_upload.html +++ b/InvenTree/order/templates/order/order_wizard/po_upload.html @@ -14,7 +14,7 @@ {% block details %} -

{% trans "Step" %} {{ wizard.steps.step1 }} {% trans "of" %} {{ wizard.steps.count }} +

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

{% block form_alert %} From 562246820938880886d9cbfffb9ceda7456212ec Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 8 May 2021 20:55:01 +0200 Subject: [PATCH 3/5] better readable structure --- .../order/order_wizard/match_parts.html | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/InvenTree/order/templates/order/order_wizard/match_parts.html b/InvenTree/order/templates/order/order_wizard/match_parts.html index e6cb565a5b..aa9776085f 100644 --- a/InvenTree/order/templates/order/order_wizard/match_parts.html +++ b/InvenTree/order/templates/order/order_wizard/match_parts.html @@ -63,16 +63,16 @@ {% for item in row.data %} {% if item.column.guess == 'Quantity' %} - {% for field in form.visible_fields %} - {% if field.name == row.quantity_select %} - {{ field }} + {% for field in form.visible_fields %} + {% if field.name == row.quantity_select %} + {{ field }} + {% endif %} + {% endfor %} + {% if row.errors.quantity %} +

{{ row.errors.quantity }}

{% endif %} - {% endfor %} - {% if row.errors.quantity %} -

{{ row.errors.quantity }}

- {% endif %} {% else %} - {{ item.cell }} + {{ item.cell }} {% endif %} From 89e0856824e04d9fbe128ed18883fe04b51afa5a Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 8 May 2021 21:05:02 +0200 Subject: [PATCH 4/5] fix for deleting items in step 2 not working in step 3 --- InvenTree/common/views.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/InvenTree/common/views.py b/InvenTree/common/views.py index c439b63c09..5acd237311 100644 --- a/InvenTree/common/views.py +++ b/InvenTree/common/views.py @@ -333,20 +333,34 @@ class FileManagementFormView(MultiStepFormView): 'errors': {}, }) else: + if self.column_names: + rows_shown = [] + # Update the row data for row in self.rows: row_data = row['data'] data = [] + show_data = [] for idx, item in enumerate(row_data): - data.append({ + column_data ={ 'cell': item, 'idx': idx, 'column': self.columns[idx], - }) - + } + data.append(column_data) + if not self.column_names or self.columns[idx]['name'] in self.column_names: + show_data.append(column_data) + row['data'] = data + if self.column_names: + current_row = row + current_row['data'] = show_data + rows_shown.append(current_row) + + if self.column_names and self.get_step_index() == 3: + self.rows = rows_shown # In the item selection step: update row data to contain fields if form and self.steps.current == 'items': From f931ba405b7750353aedf668ce229b0330bce2c1 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 8 May 2021 21:08:12 +0200 Subject: [PATCH 5/5] style fixes --- InvenTree/common/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/InvenTree/common/views.py b/InvenTree/common/views.py index 5acd237311..6186732ff2 100644 --- a/InvenTree/common/views.py +++ b/InvenTree/common/views.py @@ -344,7 +344,7 @@ class FileManagementFormView(MultiStepFormView): show_data = [] for idx, item in enumerate(row_data): - column_data ={ + column_data = { 'cell': item, 'idx': idx, 'column': self.columns[idx],