mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-11-04 07:05:41 +00:00 
			
		
		
		
	Refactorin'
This commit is contained in:
		@@ -5,20 +5,34 @@ def canAppAccessDatabase():
 | 
			
		||||
    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
 | 
			
		||||
    to touch the database:
 | 
			
		||||
 | 
			
		||||
    - "flush" command
 | 
			
		||||
    - "loaddata" command
 | 
			
		||||
    - "migrate" command
 | 
			
		||||
    to touch the database
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    if 'flush' in sys.argv:
 | 
			
		||||
        return False
 | 
			
		||||
    # If any of the following management commands are being executed,
 | 
			
		||||
    # 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:
 | 
			
		||||
        return False
 | 
			
		||||
 | 
			
		||||
    if 'migrate' in sys.argv:
 | 
			
		||||
    for cmd in excluded_commands:
 | 
			
		||||
        if cmd in sys.argv:
 | 
			
		||||
            return False
 | 
			
		||||
 | 
			
		||||
    return True
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user