mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-17 04:25:42 +00:00
Refactor "ready" state into a function
This commit is contained in:
@ -5,21 +5,25 @@ from django.db.utils import OperationalError, ProgrammingError
|
||||
|
||||
from django.apps import AppConfig
|
||||
|
||||
from InvenTree.ready import canAppAccessDatabase
|
||||
|
||||
|
||||
class UsersConfig(AppConfig):
|
||||
name = 'users'
|
||||
|
||||
def ready(self):
|
||||
|
||||
try:
|
||||
self.assign_permissions()
|
||||
except (OperationalError, ProgrammingError):
|
||||
pass
|
||||
if canAppAccessDatabase():
|
||||
|
||||
try:
|
||||
self.update_owners()
|
||||
except (OperationalError, ProgrammingError):
|
||||
pass
|
||||
try:
|
||||
self.assign_permissions()
|
||||
except (OperationalError, ProgrammingError):
|
||||
pass
|
||||
|
||||
try:
|
||||
self.update_owners()
|
||||
except (OperationalError, ProgrammingError):
|
||||
pass
|
||||
|
||||
def assign_permissions(self):
|
||||
|
||||
|
@ -13,7 +13,8 @@ from django.dispatch import receiver
|
||||
from django.db.models.signals import post_save, post_delete
|
||||
|
||||
import logging
|
||||
import sys
|
||||
|
||||
from InvenTree.ready import canAppAccessDatabase
|
||||
|
||||
|
||||
logger = logging.getLogger("inventree")
|
||||
@ -271,12 +272,7 @@ def update_group_roles(group, debug=False):
|
||||
|
||||
"""
|
||||
|
||||
if 'loaddata' in sys.argv:
|
||||
"""
|
||||
In the case that we are importing records,
|
||||
*do not* update group roles:
|
||||
This will cause conflicts in the database!
|
||||
"""
|
||||
if not canAppAccessDatabase():
|
||||
return
|
||||
|
||||
# List of permissions already associated with this group
|
||||
|
Reference in New Issue
Block a user