mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-28 03:26:45 +00:00
Cleanup old settings (#8709)
* Use LABEL_ENABLE and REPORT_ENABLE settings in PUI * Cleanup base.html - Should reduce db hits slightly * Remove defunct homepage settings * Cleanup old settings * Adjust unit test
This commit is contained in:
parent
1c9f56011c
commit
e37e72357a
@ -31,9 +31,7 @@ Configuration of basic server settings:
|
||||
{{ globalsetting("INVENTREE_DOWNLOAD_FROM_URL") }}
|
||||
{{ globalsetting("INVENTREE_DOWNLOAD_IMAGE_MAX_SIZE") }}
|
||||
{{ globalsetting("INVENTREE_DOWNLOAD_FROM_URL_USER_AGENT") }}
|
||||
{{ globalsetting("INVENTREE_REQUIRE_CONFIRM") }}
|
||||
{{ globalsetting("INVENTREE_STRICT_URLS") }}
|
||||
{{ globalsetting("INVENTREE_TREE_DEPTH") }}
|
||||
{{ globalsetting("INVENTREE_BACKUP_ENABLE") }}
|
||||
{{ globalsetting("INVENTREE_BACKUP_DAYS") }}
|
||||
{{ globalsetting("INVENTREE_DELETE_TASKS_DAYS") }}
|
||||
|
@ -253,20 +253,6 @@ SYSTEM_SETTINGS: dict[str, InvenTreeSettingsKeyType] = {
|
||||
'validator': bool,
|
||||
'default': True,
|
||||
},
|
||||
'INVENTREE_REQUIRE_CONFIRM': {
|
||||
'name': _('Require confirm'),
|
||||
'description': _('Require explicit user confirmation for certain action.'),
|
||||
'validator': bool,
|
||||
'default': True,
|
||||
},
|
||||
'INVENTREE_TREE_DEPTH': {
|
||||
'name': _('Tree Depth'),
|
||||
'description': _(
|
||||
'Default tree depth for treeview. Deeper levels can be lazy loaded as they are needed.'
|
||||
),
|
||||
'default': 1,
|
||||
'validator': [int, MinValueValidator(0)],
|
||||
},
|
||||
'INVENTREE_UPDATE_CHECK_INTERVAL': {
|
||||
'name': _('Update Check Interval'),
|
||||
'description': _('How often to check for updates (set to zero to disable)'),
|
||||
|
@ -19,120 +19,6 @@ def label_printer_options():
|
||||
|
||||
|
||||
USER_SETTINGS: dict[str, InvenTreeSettingsKeyType] = {
|
||||
'HOMEPAGE_HIDE_INACTIVE': {
|
||||
'name': _('Hide inactive parts'),
|
||||
'description': _('Hide inactive parts in results displayed on the homepage'),
|
||||
'default': True,
|
||||
'validator': bool,
|
||||
},
|
||||
'HOMEPAGE_PART_STARRED': {
|
||||
'name': _('Show subscribed parts'),
|
||||
'description': _('Show subscribed parts on the homepage'),
|
||||
'default': True,
|
||||
'validator': bool,
|
||||
},
|
||||
'HOMEPAGE_CATEGORY_STARRED': {
|
||||
'name': _('Show subscribed categories'),
|
||||
'description': _('Show subscribed part categories on the homepage'),
|
||||
'default': True,
|
||||
'validator': bool,
|
||||
},
|
||||
'HOMEPAGE_PART_LATEST': {
|
||||
'name': _('Show latest parts'),
|
||||
'description': _('Show latest parts on the homepage'),
|
||||
'default': True,
|
||||
'validator': bool,
|
||||
},
|
||||
'HOMEPAGE_BOM_REQUIRES_VALIDATION': {
|
||||
'name': _('Show invalid BOMs'),
|
||||
'description': _('Show BOMs that await validation on the homepage'),
|
||||
'default': False,
|
||||
'validator': bool,
|
||||
},
|
||||
'HOMEPAGE_STOCK_RECENT': {
|
||||
'name': _('Show recent stock changes'),
|
||||
'description': _('Show recently changed stock items on the homepage'),
|
||||
'default': True,
|
||||
'validator': bool,
|
||||
},
|
||||
'HOMEPAGE_STOCK_LOW': {
|
||||
'name': _('Show low stock'),
|
||||
'description': _('Show low stock items on the homepage'),
|
||||
'default': True,
|
||||
'validator': bool,
|
||||
},
|
||||
'HOMEPAGE_SHOW_STOCK_DEPLETED': {
|
||||
'name': _('Show depleted stock'),
|
||||
'description': _('Show depleted stock items on the homepage'),
|
||||
'default': False,
|
||||
'validator': bool,
|
||||
},
|
||||
'HOMEPAGE_BUILD_STOCK_NEEDED': {
|
||||
'name': _('Show needed stock'),
|
||||
'description': _('Show stock items needed for builds on the homepage'),
|
||||
'default': False,
|
||||
'validator': bool,
|
||||
},
|
||||
'HOMEPAGE_STOCK_EXPIRED': {
|
||||
'name': _('Show expired stock'),
|
||||
'description': _('Show expired stock items on the homepage'),
|
||||
'default': True,
|
||||
'validator': bool,
|
||||
},
|
||||
'HOMEPAGE_STOCK_STALE': {
|
||||
'name': _('Show stale stock'),
|
||||
'description': _('Show stale stock items on the homepage'),
|
||||
'default': True,
|
||||
'validator': bool,
|
||||
},
|
||||
'HOMEPAGE_BUILD_PENDING': {
|
||||
'name': _('Show pending builds'),
|
||||
'description': _('Show pending builds on the homepage'),
|
||||
'default': True,
|
||||
'validator': bool,
|
||||
},
|
||||
'HOMEPAGE_BUILD_OVERDUE': {
|
||||
'name': _('Show overdue builds'),
|
||||
'description': _('Show overdue builds on the homepage'),
|
||||
'default': True,
|
||||
'validator': bool,
|
||||
},
|
||||
'HOMEPAGE_PO_OUTSTANDING': {
|
||||
'name': _('Show outstanding POs'),
|
||||
'description': _('Show outstanding POs on the homepage'),
|
||||
'default': True,
|
||||
'validator': bool,
|
||||
},
|
||||
'HOMEPAGE_PO_OVERDUE': {
|
||||
'name': _('Show overdue POs'),
|
||||
'description': _('Show overdue POs on the homepage'),
|
||||
'default': True,
|
||||
'validator': bool,
|
||||
},
|
||||
'HOMEPAGE_SO_OUTSTANDING': {
|
||||
'name': _('Show outstanding SOs'),
|
||||
'description': _('Show outstanding SOs on the homepage'),
|
||||
'default': True,
|
||||
'validator': bool,
|
||||
},
|
||||
'HOMEPAGE_SO_OVERDUE': {
|
||||
'name': _('Show overdue SOs'),
|
||||
'description': _('Show overdue SOs on the homepage'),
|
||||
'default': True,
|
||||
'validator': bool,
|
||||
},
|
||||
'HOMEPAGE_SO_SHIPMENTS_PENDING': {
|
||||
'name': _('Show pending SO shipments'),
|
||||
'description': _('Show pending SO shipments on the homepage'),
|
||||
'default': True,
|
||||
'validator': bool,
|
||||
},
|
||||
'HOMEPAGE_NEWS': {
|
||||
'name': _('Show News'),
|
||||
'description': _('Show news on the homepage'),
|
||||
'default': False,
|
||||
'validator': bool,
|
||||
},
|
||||
'LABEL_INLINE': {
|
||||
'name': _('Inline label display'),
|
||||
'description': _(
|
||||
|
@ -628,7 +628,7 @@ class UserSettingsApiTest(InvenTreeAPITestCase):
|
||||
|
||||
def test_user_setting_init(self):
|
||||
"""Test we can retrieve a setting which has not yet been initialized."""
|
||||
key = 'HOMEPAGE_PART_LATEST'
|
||||
key = 'LABEL_INLINE'
|
||||
|
||||
# Ensure it does not actually exist in the database
|
||||
self.assertFalse(InvenTreeUserSetting.objects.filter(key=key).exists())
|
||||
|
@ -2,14 +2,8 @@
|
||||
{% load i18n %}
|
||||
{% load inventree_extras %}
|
||||
|
||||
{% plugins_enabled as plugins_enabled %}
|
||||
{% settings_value 'BARCODE_ENABLE' as barcodes %}
|
||||
{% settings_value 'RETURNORDER_ENABLED' as return_order_enabled %}
|
||||
{% settings_value "REPORT_ENABLE" as report_enabled %}
|
||||
{% settings_value "SERVER_RESTART_REQUIRED" as server_restart_required %}
|
||||
{% settings_value "_PENDING_MIGRATIONS" as pending_migrations %}
|
||||
{% settings_value "LABEL_ENABLE" as labels_enabled %}
|
||||
{% inventree_show_about user as show_about %}
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
@ -11,7 +11,10 @@ import { extractAvailableFields } from '../../functions/forms';
|
||||
import { generateUrl } from '../../functions/urls';
|
||||
import { useCreateApiFormModal } from '../../hooks/UseForm';
|
||||
import { apiUrl } from '../../states/ApiState';
|
||||
import { useUserSettingsState } from '../../states/SettingsState';
|
||||
import {
|
||||
useGlobalSettingsState,
|
||||
useUserSettingsState
|
||||
} from '../../states/SettingsState';
|
||||
import type { ApiFormFieldSet } from '../forms/fields/ApiFormField';
|
||||
import { ActionDropdown } from '../items/ActionDropdown';
|
||||
|
||||
@ -29,14 +32,23 @@ export function PrintingActions({
|
||||
modelType?: ModelType;
|
||||
}) {
|
||||
const userSettings = useUserSettingsState();
|
||||
const globalSettings = useGlobalSettingsState();
|
||||
|
||||
const enabled = useMemo(() => items.length > 0, [items]);
|
||||
|
||||
const [pluginKey, setPluginKey] = useState<string>('');
|
||||
|
||||
const labelPrintingEnabled = useMemo(() => {
|
||||
return enableLabels && globalSettings.isSet('LABEL_ENABLE');
|
||||
}, [enableLabels, globalSettings]);
|
||||
|
||||
const reportPrintingEnabled = useMemo(() => {
|
||||
return enableReports && globalSettings.isSet('REPORT_ENABLE');
|
||||
}, [enableReports, globalSettings]);
|
||||
|
||||
// Fetch available printing fields via OPTIONS request
|
||||
const printingFields = useQuery({
|
||||
enabled: enableLabels,
|
||||
enabled: labelPrintingEnabled,
|
||||
queryKey: ['printingFields', modelType, pluginKey],
|
||||
gcTime: 500,
|
||||
queryFn: () =>
|
||||
@ -162,7 +174,7 @@ export function PrintingActions({
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!enableLabels && !enableReports) {
|
||||
if (!labelPrintingEnabled && !reportPrintingEnabled) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -180,13 +192,13 @@ export function PrintingActions({
|
||||
name: t`Print Labels`,
|
||||
icon: <IconTags />,
|
||||
onClick: () => labelModal.open(),
|
||||
hidden: !enableLabels
|
||||
hidden: !labelPrintingEnabled
|
||||
},
|
||||
{
|
||||
name: t`Print Reports`,
|
||||
icon: <IconReport />,
|
||||
onClick: () => reportModal.open(),
|
||||
hidden: !enableReports
|
||||
hidden: !reportPrintingEnabled
|
||||
}
|
||||
]}
|
||||
/>
|
||||
|
@ -50,9 +50,7 @@ export default function SystemSettings() {
|
||||
'INVENTREE_DOWNLOAD_FROM_URL',
|
||||
'INVENTREE_DOWNLOAD_IMAGE_MAX_SIZE',
|
||||
'INVENTREE_DOWNLOAD_FROM_URL_USER_AGENT',
|
||||
'INVENTREE_REQUIRE_CONFIRM',
|
||||
'INVENTREE_STRICT_URLS',
|
||||
'INVENTREE_TREE_DEPTH',
|
||||
'INVENTREE_BACKUP_ENABLE',
|
||||
'INVENTREE_BACKUP_DAYS',
|
||||
'INVENTREE_DELETE_TASKS_DAYS',
|
||||
|
@ -3,7 +3,6 @@ import { Skeleton, Stack } from '@mantine/core';
|
||||
import {
|
||||
IconBellCog,
|
||||
IconDeviceDesktop,
|
||||
IconDeviceDesktopAnalytics,
|
||||
IconFileAnalytics,
|
||||
IconLock,
|
||||
IconSearch,
|
||||
@ -43,38 +42,6 @@ export default function UserSettings() {
|
||||
icon: <IconLock />,
|
||||
content: <SecurityContent />
|
||||
},
|
||||
{
|
||||
name: 'dashboard',
|
||||
label: t`Dashboard`,
|
||||
icon: <IconDeviceDesktopAnalytics />,
|
||||
content: (
|
||||
<UserSettingList
|
||||
keys={[
|
||||
// TODO: These will be replaced with "dashboard" settings,
|
||||
// once the new dashboard is implemented
|
||||
'HOMEPAGE_HIDE_INACTIVE',
|
||||
'HOMEPAGE_PART_STARRED',
|
||||
'HOMEPAGE_CATEGORY_STARRED',
|
||||
'HOMEPAGE_PART_LATEST',
|
||||
'HOMEPAGE_BOM_REQUIRES_VALIDATION',
|
||||
'HOMEPAGE_STOCK_RECENT',
|
||||
'HOMEPAGE_STOCK_LOW',
|
||||
'HOMEPAGE_SHOW_STOCK_DEPLETED',
|
||||
'HOMEPAGE_BUILD_STOCK_NEEDED',
|
||||
'HOMEPAGE_STOCK_EXPIRED',
|
||||
'HOMEPAGE_STOCK_STALE',
|
||||
'HOMEPAGE_BUILD_PENDING',
|
||||
'HOMEPAGE_BUILD_OVERDUE',
|
||||
'HOMEPAGE_PO_OUTSTANDING',
|
||||
'HOMEPAGE_PO_OVERDUE',
|
||||
'HOMEPAGE_SO_OUTSTANDING',
|
||||
'HOMEPAGE_SO_OVERDUE',
|
||||
'HOMEPAGE_SO_SHIPMENTS_PENDING',
|
||||
'HOMEPAGE_NEWS'
|
||||
]}
|
||||
/>
|
||||
)
|
||||
},
|
||||
{
|
||||
name: 'display',
|
||||
label: t`Display Options`,
|
||||
|
Loading…
x
Reference in New Issue
Block a user