mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 20:16:44 +00:00
Merge pull request #2598 from SchrodingersGat/loaddata-skip-steps
Skips some specific steps when importing data
This commit is contained in:
commit
0c1971bfbb
@ -6,10 +6,16 @@ def isInTestMode():
|
|||||||
Returns True if the database is in testing mode
|
Returns True if the database is in testing mode
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if 'test' in sys.argv:
|
return 'test' in sys.argv
|
||||||
return True
|
|
||||||
|
|
||||||
return False
|
|
||||||
|
def isImportingData():
|
||||||
|
"""
|
||||||
|
Returns True if the database is currently importing data,
|
||||||
|
e.g. 'loaddata' command is performed
|
||||||
|
"""
|
||||||
|
|
||||||
|
return 'loaddata' in sys.argv
|
||||||
|
|
||||||
|
|
||||||
def canAppAccessDatabase(allow_test=False):
|
def canAppAccessDatabase(allow_test=False):
|
||||||
|
@ -12,6 +12,8 @@ from allauth.account.models import EmailAddress
|
|||||||
import build.models
|
import build.models
|
||||||
import InvenTree.helpers
|
import InvenTree.helpers
|
||||||
import InvenTree.tasks
|
import InvenTree.tasks
|
||||||
|
from InvenTree.ready import isImportingData
|
||||||
|
|
||||||
import part.models as part_models
|
import part.models as part_models
|
||||||
|
|
||||||
|
|
||||||
@ -24,6 +26,10 @@ def check_build_stock(build: build.models.Build):
|
|||||||
and send an email out to any subscribed users if stock is low.
|
and send an email out to any subscribed users if stock is low.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# Do not notify if we are importing data
|
||||||
|
if isImportingData():
|
||||||
|
return
|
||||||
|
|
||||||
# Iterate through each of the parts required for this build
|
# Iterate through each of the parts required for this build
|
||||||
|
|
||||||
lines = []
|
lines = []
|
||||||
|
@ -13,6 +13,7 @@ from common.models import NotificationEntry
|
|||||||
|
|
||||||
import InvenTree.helpers
|
import InvenTree.helpers
|
||||||
import InvenTree.tasks
|
import InvenTree.tasks
|
||||||
|
from InvenTree.ready import isImportingData
|
||||||
|
|
||||||
import part.models
|
import part.models
|
||||||
|
|
||||||
@ -24,6 +25,10 @@ def notify_low_stock(part: part.models.Part):
|
|||||||
Notify users who have starred a part when its stock quantity falls below the minimum threshold
|
Notify users who have starred a part when its stock quantity falls below the minimum threshold
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# Do not notify if we are importing data
|
||||||
|
if isImportingData():
|
||||||
|
return
|
||||||
|
|
||||||
# Check if we have notified recently...
|
# Check if we have notified recently...
|
||||||
delta = timedelta(days=1)
|
delta = timedelta(days=1)
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ from django.conf import settings
|
|||||||
|
|
||||||
from maintenance_mode.core import set_maintenance_mode
|
from maintenance_mode.core import set_maintenance_mode
|
||||||
|
|
||||||
|
from InvenTree.ready import isImportingData
|
||||||
from plugin import registry
|
from plugin import registry
|
||||||
|
|
||||||
|
|
||||||
@ -19,6 +20,10 @@ class PluginAppConfig(AppConfig):
|
|||||||
|
|
||||||
def ready(self):
|
def ready(self):
|
||||||
if settings.PLUGINS_ENABLED:
|
if settings.PLUGINS_ENABLED:
|
||||||
|
|
||||||
|
if isImportingData():
|
||||||
|
logger.info('Skipping plugin loading for data import')
|
||||||
|
else:
|
||||||
logger.info('Loading InvenTree plugins')
|
logger.info('Loading InvenTree plugins')
|
||||||
|
|
||||||
if not registry.is_loading:
|
if not registry.is_loading:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user