2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-28 11:36:44 +00:00

Enhance creation of default settings (#9028) (#9029)

- Remove cache requirement
- Replaces https://github.com/inventree/InvenTree/pull/9021

(cherry picked from commit 445fa45394ff843c638ebab474618735a564714f)

Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
This commit is contained in:
github-actions[bot] 2025-02-04 23:04:01 +11:00 committed by GitHub
parent 0f9bddbcd2
commit 1b42c00747
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -165,15 +165,6 @@ class BaseInvenTreeSetting(models.Model):
If a particular setting is not present, create it with the default value If a particular setting is not present, create it with the default value
""" """
cache_key = f'BUILD_DEFAULT_VALUES:{cls.__name__!s}'
try:
if InvenTree.helpers.str2bool(cache.get(cache_key, False)):
# Already built default values
return
except Exception:
pass
try: try:
existing_keys = cls.objects.filter(**kwargs).values_list('key', flat=True) existing_keys = cls.objects.filter(**kwargs).values_list('key', flat=True)
settings_keys = cls.SETTINGS.keys() settings_keys = cls.SETTINGS.keys()
@ -194,11 +185,6 @@ class BaseInvenTreeSetting(models.Model):
'Failed to build default values for %s (%s)', str(cls), str(type(exc)) 'Failed to build default values for %s (%s)', str(cls), str(type(exc))
) )
try:
cache.set(cache_key, True, timeout=3600)
except Exception:
pass
def _call_settings_function(self, reference: str, args, kwargs): def _call_settings_function(self, reference: str, args, kwargs):
"""Call a function associated with a particular setting. """Call a function associated with a particular setting.