diff --git a/InvenTree/common/admin.py b/InvenTree/common/admin.py index cb643deca4..da12852d83 100644 --- a/InvenTree/common/admin.py +++ b/InvenTree/common/admin.py @@ -14,7 +14,7 @@ class CurrencyAdmin(ImportExportModelAdmin): class SettingsAdmin(ImportExportModelAdmin): - list_display = ('key', 'value', 'description') + list_display = ('key', 'value') admin.site.register(Currency, CurrencyAdmin) diff --git a/InvenTree/common/apps.py b/InvenTree/common/apps.py index 4661c69370..83b299ecdf 100644 --- a/InvenTree/common/apps.py +++ b/InvenTree/common/apps.py @@ -1,10 +1,6 @@ from django.apps import AppConfig from django.db.utils import OperationalError, ProgrammingError -import os -import uuid -import yaml - class CommonConfig(AppConfig): name = 'common' @@ -12,46 +8,8 @@ class CommonConfig(AppConfig): def ready(self): """ Will be called when the Common app is first loaded """ - self.populate_default_settings() self.add_instance_name() - def populate_default_settings(self): - """ Populate the default values for InvenTree key:value pairs. - If a setting does not exist, it will be created. - """ - - # Import this here, rather than at the global-level, - # otherwise it is called all the time, and we don't want that, - # as the InvenTreeSetting model may have not been instantiated yet. - from .models import InvenTreeSetting - - here = os.path.dirname(os.path.abspath(__file__)) - settings_file = os.path.join(here, 'kvp.yaml') - - with open(settings_file) as kvp: - values = yaml.safe_load(kvp) - - for value in values: - key = value['key'] - default = value['default'] - description = value['description'] - - try: - # If a particular setting does not exist in the database, create it now - if not InvenTreeSetting.objects.filter(key=key).exists(): - setting = InvenTreeSetting( - key=key, - value=default, - description=description - ) - - setting.save() - - print("Creating new key: '{k}' = '{v}'".format(k=key, v=default)) - except (OperationalError, ProgrammingError): - # Migrations have not yet been applied - table does not exist - break - def add_instance_name(self): """ Check if an InstanceName has been defined for this database. @@ -64,14 +22,9 @@ class CommonConfig(AppConfig): try: if not InvenTreeSetting.objects.filter(key='InstanceName').exists(): - val = uuid.uuid4().hex - - print("No 'InstanceName' found - generating random name '{n}'".format(n=val)) - name = InvenTreeSetting( key="InstanceName", - value=val, - description="Instance name for this InvenTree database installation." + value="InvenTree Server" ) name.save() diff --git a/InvenTree/common/kvp.yaml b/InvenTree/common/kvp.yaml deleted file mode 100644 index d0f7249dff..0000000000 --- a/InvenTree/common/kvp.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# This file contains the default values for the key:value settings available in InvenTree -# This file should not be edited locally. - -# Note: The description strings provided here will be translatable, -# so ensure that any translations are provided as appropriate. - -# TODO: Update the formatting here to include logical separators e.g. double-underscore -# TODO: This is so when there are enough options, we will be able to display them as a tree - -- key: 'part_ipn_regex' - default: '' - description: 'Format string for internal part number' - -- key: part_deep_copy - default: True - description: 'Parts are deep-copied by default' \ No newline at end of file diff --git a/InvenTree/common/migrations/0008_remove_inventreesetting_description.py b/InvenTree/common/migrations/0008_remove_inventreesetting_description.py new file mode 100644 index 0000000000..d7889ced17 --- /dev/null +++ b/InvenTree/common/migrations/0008_remove_inventreesetting_description.py @@ -0,0 +1,17 @@ +# Generated by Django 3.0.7 on 2020-10-19 13:02 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('common', '0007_colortheme'), + ] + + operations = [ + migrations.RemoveField( + model_name='inventreesetting', + name='description', + ), + ] diff --git a/InvenTree/common/models.py b/InvenTree/common/models.py index b0a836118d..1a76183e59 100644 --- a/InvenTree/common/models.py +++ b/InvenTree/common/models.py @@ -76,8 +76,6 @@ class InvenTreeSetting(models.Model): value = models.CharField(max_length=200, blank=True, unique=False, help_text=_('Settings value')) - description = models.CharField(max_length=200, blank=True, unique=False, help_text=_('Settings description')) - def validate_unique(self, exclude=None): """ Ensure that the key:value pair is unique. In addition to the base validators, this ensures that the 'key'