From e382f2a57ec1a459086c51ce4faa9b690e7330b9 Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 13 May 2021 15:46:27 +0200 Subject: [PATCH 1/5] fixing bug from refactor --- InvenTree/InvenTree/static/script/inventree/inventree.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/InvenTree/InvenTree/static/script/inventree/inventree.js b/InvenTree/InvenTree/static/script/inventree/inventree.js index 4b43b342af..1a6fdec47a 100644 --- a/InvenTree/InvenTree/static/script/inventree/inventree.js +++ b/InvenTree/InvenTree/static/script/inventree/inventree.js @@ -12,7 +12,7 @@ function attachClipboard(selector, containerselector, textElement) { return document.getElementById(textElement).textContent; } } else { - text = function() { + text = function(trigger) { var content = trigger.parentElement.parentElement.textContent;return content.trim(); } } @@ -22,7 +22,6 @@ function attachClipboard(selector, containerselector, textElement) { text: text, container: containerselector }); - console.log(cis); } @@ -81,7 +80,6 @@ function inventreeDocReady() { attachClipboard('.clip-btn'); attachClipboard('.clip-btn', 'modal-about'); // modals attachClipboard('.clip-btn-version', 'modal-about', 'about-copy-text'); // version-text - } function isFileTransfer(transfer) { From 22249206d24206c5073e7d7ba33f9c0ba0d25fd5 Mon Sep 17 00:00:00 2001 From: eeintech Date: Thu, 13 May 2021 16:06:57 -0400 Subject: [PATCH 2/5] Fixed duplicate check --- InvenTree/common/views.py | 5 +++-- .../order/templates/order/order_wizard/match_fields.html | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/InvenTree/common/views.py b/InvenTree/common/views.py index fa605c2b80..99862f5c08 100644 --- a/InvenTree/common/views.py +++ b/InvenTree/common/views.py @@ -209,6 +209,7 @@ class FileManagementFormView(MultiStepFormView): context.update({'columns': self.columns}) # Load extra context data + print(self.extra_context_data) for key, items in self.extra_context_data.items(): context.update({key: items}) @@ -449,8 +450,8 @@ class FileManagementFormView(MultiStepFormView): if guess: n = list(self.column_selections.values()).count(self.column_selections[col]) - if n > 1: - duplicates.append(col) + if n > 1 and self.column_selections[col] not in duplicates: + duplicates.append(self.column_selections[col]) # Store extra context data self.extra_context_data = { diff --git a/InvenTree/order/templates/order/order_wizard/match_fields.html b/InvenTree/order/templates/order/order_wizard/match_fields.html index 4ff7b6a963..cd81142341 100644 --- a/InvenTree/order/templates/order/order_wizard/match_fields.html +++ b/InvenTree/order/templates/order/order_wizard/match_fields.html @@ -55,7 +55,7 @@ {{ col }} {% for duplicate in duplicates %} - {% if duplicate == col.name %} + {% if duplicate == col.value %} From a64ab5956b2a1daec62fc8789ce600250882d78f Mon Sep 17 00:00:00 2001 From: eeintech Date: Thu, 13 May 2021 16:07:57 -0400 Subject: [PATCH 3/5] Removed leftover print --- InvenTree/common/views.py | 1 - 1 file changed, 1 deletion(-) diff --git a/InvenTree/common/views.py b/InvenTree/common/views.py index 99862f5c08..857b6b2c51 100644 --- a/InvenTree/common/views.py +++ b/InvenTree/common/views.py @@ -209,7 +209,6 @@ class FileManagementFormView(MultiStepFormView): context.update({'columns': self.columns}) # Load extra context data - print(self.extra_context_data) for key, items in self.extra_context_data.items(): context.update({key: items}) From f76bc5a7b8661a371669c21959f65e44b252cb45 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Fri, 14 May 2021 12:38:38 +1000 Subject: [PATCH 4/5] Add debug mode and database backend as info to the "stats" dialog --- .../part/templatetags/inventree_extras.py | 24 +++++++++++++++++++ InvenTree/templates/stats.html | 13 ++++++++++ 2 files changed, 37 insertions(+) diff --git a/InvenTree/part/templatetags/inventree_extras.py b/InvenTree/part/templatetags/inventree_extras.py index 2c588a81e5..799ad8788b 100644 --- a/InvenTree/part/templatetags/inventree_extras.py +++ b/InvenTree/part/templatetags/inventree_extras.py @@ -1,7 +1,14 @@ +# -*- coding: utf-8 -*- + """ This module provides template tags for extra functionality over and above the built-in Django tags. """ + import os +import django + +from django.utils.translation import ugettext_lazy as _ +from django.conf import settings as djangosettings from django import template from django.urls import reverse @@ -67,6 +74,23 @@ def part_allocation_count(build, part, *args, **kwargs): return InvenTree.helpers.decimal2string(build.getAllocatedQuantity(part)) +@register.simple_tag() +def inventree_in_debug_mode(*args, **kwargs): + """ Return True if the server is running in DEBUG mode """ + + return djangosettings.DEBUG + +@register.simple_tag() +def inventree_db_engine(*args, **kwargs): + """ Return the InvenTree database backend e.g. 'postgresql' """ + + db = djangosettings.DATABASES['default'] + + engine = db.get('ENGINE', _('Unknown database')) + + engine = engine.replace('django.db.backends.', '') + + return engine @register.simple_tag() def inventree_instance_name(*args, **kwargs): diff --git a/InvenTree/templates/stats.html b/InvenTree/templates/stats.html index eff9c4504f..1598d45d26 100644 --- a/InvenTree/templates/stats.html +++ b/InvenTree/templates/stats.html @@ -13,6 +13,19 @@ {% trans "Instance Name" %} {% inventree_instance_name %} + + + {% trans "Database" %} + {% inventree_db_engine %} + + {% inventree_in_debug_mode as debug_mode %} + {% if debug_mode %} + + + {% trans "Debug Mode" %} + {% trans "Server is running in debug mode" %} + + {% endif %} {% if user.is_staff %} From 7deea1ec00303d9943bc4185d6ad0a0e1e04dd25 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Fri, 14 May 2021 12:40:42 +1000 Subject: [PATCH 5/5] Style fixes --- InvenTree/part/templatetags/inventree_extras.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/InvenTree/part/templatetags/inventree_extras.py b/InvenTree/part/templatetags/inventree_extras.py index 799ad8788b..e8743028a0 100644 --- a/InvenTree/part/templatetags/inventree_extras.py +++ b/InvenTree/part/templatetags/inventree_extras.py @@ -5,7 +5,6 @@ over and above the built-in Django tags. """ import os -import django from django.utils.translation import ugettext_lazy as _ from django.conf import settings as djangosettings @@ -74,12 +73,14 @@ def part_allocation_count(build, part, *args, **kwargs): return InvenTree.helpers.decimal2string(build.getAllocatedQuantity(part)) + @register.simple_tag() def inventree_in_debug_mode(*args, **kwargs): """ Return True if the server is running in DEBUG mode """ return djangosettings.DEBUG + @register.simple_tag() def inventree_db_engine(*args, **kwargs): """ Return the InvenTree database backend e.g. 'postgresql' """ @@ -92,6 +93,7 @@ def inventree_db_engine(*args, **kwargs): return engine + @register.simple_tag() def inventree_instance_name(*args, **kwargs): """ Return the InstanceName associated with the current database """