mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Refactorin'
This commit is contained in:
parent
368a5c3f63
commit
8ad16ceb9c
@ -5,20 +5,34 @@ def canAppAccessDatabase():
|
|||||||
Returns True if the apps.py file can access database records.
|
Returns True if the apps.py file can access database records.
|
||||||
|
|
||||||
There are some circumstances where we don't want the ready function in apps.py
|
There are some circumstances where we don't want the ready function in apps.py
|
||||||
to touch the database:
|
to touch the database
|
||||||
|
|
||||||
- "flush" command
|
|
||||||
- "loaddata" command
|
|
||||||
- "migrate" command
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if 'flush' in sys.argv:
|
# If any of the following management commands are being executed,
|
||||||
return False
|
# prevent custom "on load" code from running!
|
||||||
|
excluded_commands = [
|
||||||
|
'flush',
|
||||||
|
'loaddata',
|
||||||
|
'dumpdata',
|
||||||
|
'makemirations',
|
||||||
|
'migrate',
|
||||||
|
'check',
|
||||||
|
'dbbackup',
|
||||||
|
'mediabackup',
|
||||||
|
'dbrestore',
|
||||||
|
'mediarestore',
|
||||||
|
'shell',
|
||||||
|
'createsuperuser',
|
||||||
|
'wait_for_db',
|
||||||
|
'prerender',
|
||||||
|
'collectstatic',
|
||||||
|
'makemessages',
|
||||||
|
'compilemessages',
|
||||||
|
'test',
|
||||||
|
]
|
||||||
|
|
||||||
if 'loaddata' in sys.argv:
|
for cmd in excluded_commands:
|
||||||
return False
|
if cmd in sys.argv:
|
||||||
|
|
||||||
if 'migrate' in sys.argv:
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
Loading…
Reference in New Issue
Block a user