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

Skips some specific steps when importing data

- We need to prevent certain operations from running when we are importing data
- This is to prevent unique database constraints from being violated

- Do not register plugins during data import
- Do not launch notification events
This commit is contained in:
Oliver
2022-02-03 16:03:46 +11:00
parent eef15b13ec
commit 78b1c7a22b
4 changed files with 33 additions and 11 deletions

View File

@ -8,6 +8,7 @@ from django.conf import settings
from maintenance_mode.core import set_maintenance_mode
from InvenTree.ready import isImportingData
from plugin import registry
@ -19,13 +20,17 @@ class PluginAppConfig(AppConfig):
def ready(self):
if settings.PLUGINS_ENABLED:
logger.info('Loading InvenTree plugins')
if isImportingData():
logger.info('Skipping plugin loading for data import')
else:
logger.info('Loading InvenTree plugins')
if not registry.is_loading:
# this is the first startup
registry.collect_plugins()
registry.load_plugins()
if not registry.is_loading:
# this is the first startup
registry.collect_plugins()
registry.load_plugins()
# drop out of maintenance
# makes sure we did not have an error in reloading and maintenance is still active
set_maintenance_mode(False)
# drop out of maintenance
# makes sure we did not have an error in reloading and maintenance is still active
set_maintenance_mode(False)