From 46d5a6f00bb234f0fa3e083fb6cec5b47e14d01f Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 27 Jul 2021 14:53:32 +1000 Subject: [PATCH] - Convert "PART_RECENT_COUNT" to user setting - Convert "STOCK_RECENT_COUNT" to user setting --- InvenTree/common/models.py | 27 +++++++++---------- InvenTree/templates/InvenTree/index.html | 4 +-- .../templates/InvenTree/settings/part.html | 1 - .../templates/InvenTree/settings/stock.html | 1 - .../InvenTree/settings/user_homepage.html | 12 +++++---- 5 files changed, 22 insertions(+), 23 deletions(-) diff --git a/InvenTree/common/models.py b/InvenTree/common/models.py index b471fee3fc..5aee7b0fec 100644 --- a/InvenTree/common/models.py +++ b/InvenTree/common/models.py @@ -538,13 +538,6 @@ class InvenTreeSetting(BaseInvenTreeSetting): 'validator': bool }, - 'PART_RECENT_COUNT': { - 'name': _('Recent Part Count'), - 'description': _('Number of recent parts to display on index page'), - 'default': 10, - 'validator': [int, MinValueValidator(1)] - }, - 'PART_TEMPLATE': { 'name': _('Template'), 'description': _('Parts are templates by default'), @@ -711,13 +704,6 @@ class InvenTreeSetting(BaseInvenTreeSetting): 'validator': bool, }, - 'STOCK_RECENT_COUNT': { - 'name': _('Recent Stock Count'), - 'description': _('Number of recent stock items to display on index page'), - 'default': 10, - 'validator': [int, MinValueValidator(1)] - }, - 'BUILDORDER_REFERENCE_PREFIX': { 'name': _('Build Order Reference Prefix'), 'description': _('Prefix value for build order reference'), @@ -772,6 +758,13 @@ class InvenTreeUserSetting(BaseInvenTreeSetting): 'default': True, 'validator': bool, }, + 'PART_RECENT_COUNT': { + 'name': _('Recent Part Count'), + 'description': _('Number of recent parts to display on index page'), + 'default': 10, + 'validator': [int, MinValueValidator(1)] + }, + 'HOMEPAGE_BOM_VALIDATION': { 'name': _('Show unvalidated BOMs'), 'description': _('Show BOMs that await validation on the homepage'), @@ -784,6 +777,12 @@ class InvenTreeUserSetting(BaseInvenTreeSetting): 'default': True, 'validator': bool, }, + 'STOCK_RECENT_COUNT': { + 'name': _('Recent Stock Count'), + 'description': _('Number of recent stock items to display on index page'), + 'default': 10, + 'validator': [int, MinValueValidator(1)] + }, 'HOMEPAGE_STOCK_LOW': { 'name': _('Show low stock'), 'description': _('Show low stock items on the homepage'), diff --git a/InvenTree/templates/InvenTree/index.html b/InvenTree/templates/InvenTree/index.html index ee08777502..51f8d2ed45 100644 --- a/InvenTree/templates/InvenTree/index.html +++ b/InvenTree/templates/InvenTree/index.html @@ -116,7 +116,7 @@ addHeaderAction('latest-parts', '{% trans "Latest Parts" %}', 'fa-newspaper'); loadSimplePartTable("#table-latest-parts", "{% url 'api-part-list' %}", { params: { ordering: "-creation_date", - max_results: {% settings_value "PART_RECENT_COUNT" %}, + max_results: {% settings_value "PART_RECENT_COUNT" user=request.user %}, }, name: 'latest_parts', }); @@ -155,7 +155,7 @@ loadStockTable($('#table-recently-updated-stock'), { params: { part_detail: true, ordering: "-updated", - max_results: {% settings_value "STOCK_RECENT_COUNT" %}, + max_results: {% settings_value "STOCK_RECENT_COUNT" user=request.user %}, }, name: 'recently-updated-stock', grouping: false, diff --git a/InvenTree/templates/InvenTree/settings/part.html b/InvenTree/templates/InvenTree/settings/part.html index 7acb116616..3fa20820b1 100644 --- a/InvenTree/templates/InvenTree/settings/part.html +++ b/InvenTree/templates/InvenTree/settings/part.html @@ -20,7 +20,6 @@ {% include "InvenTree/settings/setting.html" with key="PART_SHOW_QUANTITY_IN_FORMS" icon="fa-hashtag" %} {% include "InvenTree/settings/setting.html" with key="PART_SHOW_PRICE_IN_FORMS" icon="fa-dollar-sign" %} {% include "InvenTree/settings/setting.html" with key="PART_SHOW_RELATED" icon="fa-random" %} - {% include "InvenTree/settings/setting.html" with key="PART_RECENT_COUNT" icon="fa-clock" %} {% include "InvenTree/settings/setting.html" with key="PART_CREATE_INITIAL" icon="fa-boxes" %} {% include "InvenTree/settings/setting.html" with key="PART_TEMPLATE" icon="fa-clone" %} diff --git a/InvenTree/templates/InvenTree/settings/stock.html b/InvenTree/templates/InvenTree/settings/stock.html index feb072815a..e05def09a6 100644 --- a/InvenTree/templates/InvenTree/settings/stock.html +++ b/InvenTree/templates/InvenTree/settings/stock.html @@ -13,7 +13,6 @@ {% include "InvenTree/settings/header.html" %} {% include "InvenTree/settings/setting.html" with key="STOCK_GROUP_BY_PART" icon="fa-layer-group" %} - {% include "InvenTree/settings/setting.html" with key="STOCK_RECENT_COUNT" icon="fa-clock" %} {% include "InvenTree/settings/setting.html" with key="STOCK_ENABLE_EXPIRY" icon="fa-stopwatch" %} {% include "InvenTree/settings/setting.html" with key="STOCK_STALE_DAYS" icon="fa-calendar" %} {% include "InvenTree/settings/setting.html" with key="STOCK_ALLOW_EXPIRED_SALE" icon="fa-truck" %} diff --git a/InvenTree/templates/InvenTree/settings/user_homepage.html b/InvenTree/templates/InvenTree/settings/user_homepage.html index 7bb2bbda42..ccaae6fa8a 100644 --- a/InvenTree/templates/InvenTree/settings/user_homepage.html +++ b/InvenTree/templates/InvenTree/settings/user_homepage.html @@ -15,16 +15,18 @@ {% include "InvenTree/settings/header.html" %} - {% include "InvenTree/settings/setting.html" with key="HOMEPAGE_PART_STARRED" user_setting=True %} - {% include "InvenTree/settings/setting.html" with key="HOMEPAGE_PART_LATEST" user_setting=True %} + {% include "InvenTree/settings/setting.html" with key="HOMEPAGE_PART_STARRED" icon='fa-star' user_setting=True %} + {% include "InvenTree/settings/setting.html" with key="HOMEPAGE_PART_LATEST" icon='fa-history' user_setting=True %} + {% include "InvenTree/settings/setting.html" with key="PART_RECENT_COUNT" icon="fa-clock" user_setting=True %} {% include "InvenTree/settings/setting.html" with key="HOMEPAGE_BOM_VALIDATION" user_setting=True %} - {% include "InvenTree/settings/setting.html" with key="HOMEPAGE_STOCK_RECENT" user_setting=True %} + {% include "InvenTree/settings/setting.html" with key="HOMEPAGE_STOCK_RECENT" icon='fa-history' user_setting=True %} + {% include "InvenTree/settings/setting.html" with key="STOCK_RECENT_COUNT" icon="fa-clock" user_setting=True %} {% include "InvenTree/settings/setting.html" with key="HOMEPAGE_STOCK_LOW" user_setting=True %} {% include "InvenTree/settings/setting.html" with key="HOMEPAGE_STOCK_DEPLETED" user_setting=True %} {% include "InvenTree/settings/setting.html" with key="HOMEPAGE_STOCK_NEEDED" user_setting=True %} - {% include "InvenTree/settings/setting.html" with key="HOMEPAGE_STOCK_EXPIRED" user_setting=True %} - {% include "InvenTree/settings/setting.html" with key="HOMEPAGE_STOCK_STALE" user_setting=True %} + {% include "InvenTree/settings/setting.html" with key="HOMEPAGE_STOCK_EXPIRED" icon='fa-calendar-alt' user_setting=True %} + {% include "InvenTree/settings/setting.html" with key="HOMEPAGE_STOCK_STALE" icon='fa-calendar-alt' user_setting=True %} {% include "InvenTree/settings/setting.html" with key="HOMEPAGE_BUILD_PENDING" user_setting=True %} {% include "InvenTree/settings/setting.html" with key="HOMEPAGE_BUILD_OVERDUE" user_setting=True %}