added setting to disable tree fix
This commit is contained in:
parent
85f7740e9b
commit
d488559e42
@ -17,23 +17,24 @@ class CookbookConfig(AppConfig):
|
|||||||
'django.db.backends.postgresql']:
|
'django.db.backends.postgresql']:
|
||||||
import cookbook.signals # noqa
|
import cookbook.signals # noqa
|
||||||
|
|
||||||
# when starting up run fix_tree to:
|
if not settings.DISABLE_TREE_FIX_STARTUP:
|
||||||
# a) make sure that nodes are sorted when switching between sort modes
|
# when starting up run fix_tree to:
|
||||||
# b) fix problems, if any, with tree consistency
|
# a) make sure that nodes are sorted when switching between sort modes
|
||||||
with scopes_disabled():
|
# b) fix problems, if any, with tree consistency
|
||||||
try:
|
with scopes_disabled():
|
||||||
from cookbook.models import Keyword, Food
|
try:
|
||||||
Keyword.fix_tree(fix_paths=True)
|
from cookbook.models import Keyword, Food
|
||||||
Food.fix_tree(fix_paths=True)
|
Keyword.fix_tree(fix_paths=True)
|
||||||
except OperationalError:
|
Food.fix_tree(fix_paths=True)
|
||||||
if DEBUG:
|
except OperationalError:
|
||||||
traceback.print_exc()
|
if DEBUG:
|
||||||
pass # if model does not exist there is no need to fix it
|
traceback.print_exc()
|
||||||
except ProgrammingError:
|
pass # if model does not exist there is no need to fix it
|
||||||
if DEBUG:
|
except ProgrammingError:
|
||||||
traceback.print_exc()
|
if DEBUG:
|
||||||
pass # if migration has not been run database cannot be fixed yet
|
traceback.print_exc()
|
||||||
except Exception:
|
pass # if migration has not been run database cannot be fixed yet
|
||||||
if DEBUG:
|
except Exception:
|
||||||
traceback.print_exc()
|
if DEBUG:
|
||||||
pass # dont break startup just because fix could not run, need to investigate cases when this happens
|
traceback.print_exc()
|
||||||
|
pass # dont break startup just because fix could not run, need to investigate cases when this happens
|
||||||
|
@ -151,6 +151,7 @@ MIDDLEWARE = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
SORT_TREE_BY_NAME = bool(int(os.getenv('SORT_TREE_BY_NAME', False)))
|
SORT_TREE_BY_NAME = bool(int(os.getenv('SORT_TREE_BY_NAME', False)))
|
||||||
|
DISABLE_TREE_FIX_STARTUP = bool(int(os.getenv('DISABLE_TREE_FIX_STARTUP', False)))
|
||||||
|
|
||||||
if bool(int(os.getenv('SQL_DEBUG', False))):
|
if bool(int(os.getenv('SQL_DEBUG', False))):
|
||||||
MIDDLEWARE += ('recipes.middleware.SqlPrintingMiddleware',)
|
MIDDLEWARE += ('recipes.middleware.SqlPrintingMiddleware',)
|
||||||
|
Loading…
Reference in New Issue
Block a user