2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-18 21:15:41 +00:00
* Update "isRunningMigrations" method

* Update other apps.py files
This commit is contained in:
Oliver
2024-01-11 00:35:25 +11:00
committed by GitHub
parent e1b670ba57
commit 445551e6f3
7 changed files with 46 additions and 26 deletions

View File

@ -12,8 +12,7 @@ from django.conf import settings
from django.core.exceptions import AppRegistryNotReady
from django.db.utils import IntegrityError, OperationalError, ProgrammingError
from InvenTree.ready import (canAppAccessDatabase, isImportingData,
isInMainThread, isPluginRegistryLoaded)
import InvenTree.ready
logger = logging.getLogger("inventree")
@ -37,10 +36,13 @@ class LabelConfig(AppConfig):
def ready(self):
"""This function is called whenever the label app is loaded."""
# skip loading if plugin registry is not loaded or we run in a background thread
if not isPluginRegistryLoaded() or not isInMainThread():
if not InvenTree.ready.isPluginRegistryLoaded() or not InvenTree.ready.isInMainThread():
return
if canAppAccessDatabase(allow_test=False) and not isImportingData():
if InvenTree.ready.isRunningMigrations():
return
if InvenTree.ready.canAppAccessDatabase(allow_test=False) and not InvenTree.ready.isImportingData():
try:
self.create_labels() # pragma: no cover
except (AppRegistryNotReady, IntegrityError, OperationalError, ProgrammingError):