Add support for registering bootstrapped models from registry
This commit is contained in:
@@ -8,9 +8,9 @@ from django.utils.importlib import import_module
|
|||||||
|
|
||||||
from .models import App
|
from .models import App
|
||||||
|
|
||||||
###app.set_backup([ModelBackup()])
|
|
||||||
|
|
||||||
for app_name in settings.INSTALLED_APPS:
|
def register_apps():
|
||||||
|
for app_name in settings.INSTALLED_APPS:
|
||||||
App.register(app_name)
|
App.register(app_name)
|
||||||
try:
|
try:
|
||||||
post_init = import_module('%s.post_init' % app_name)
|
post_init = import_module('%s.post_init' % app_name)
|
||||||
@@ -21,3 +21,6 @@ for app_name in settings.INSTALLED_APPS:
|
|||||||
for name, value in inspect.getmembers(post_init):
|
for name, value in inspect.getmembers(post_init):
|
||||||
if hasattr(value, '__call__') and name.startswith('init'):
|
if hasattr(value, '__call__') and name.startswith('init'):
|
||||||
value()
|
value()
|
||||||
|
|
||||||
|
|
||||||
|
register_apps()
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ from project_setup.api import register_setup
|
|||||||
from project_tools.api import register_tool
|
from project_tools.api import register_tool
|
||||||
from statistics.api import register_statistics
|
from statistics.api import register_statistics
|
||||||
from navigation.api import register_top_menu
|
from navigation.api import register_top_menu
|
||||||
from bootstrap.classes import Cleanup
|
from bootstrap.classes import Cleanup, BootstrapModel
|
||||||
|
|
||||||
#from .classes import AppBackup, StorageModuleBase, Setting
|
#from .classes import AppBackup, StorageModuleBase, Setting
|
||||||
|
|
||||||
@@ -103,6 +103,10 @@ class App(TranslatableLabelMixin, LiveObjectMixin, models.Model):
|
|||||||
logger.debug('cleanup_function: %s' % cleanup_function)
|
logger.debug('cleanup_function: %s' % cleanup_function)
|
||||||
Cleanup(cleanup_function)
|
Cleanup(cleanup_function)
|
||||||
|
|
||||||
|
for bootstrap_model in getattr(registration, 'bootstrap_models', []):
|
||||||
|
logger.debug('bootstrap_model: %s' % bootstrap_model)
|
||||||
|
BootstrapModel(model_name=bootstrap_model, app_name=app_name)
|
||||||
|
|
||||||
|
|
||||||
#def set_backup(self, *args, **kwargs):
|
#def set_backup(self, *args, **kwargs):
|
||||||
# return AppBackup(self, *args, **kwargs)
|
# return AppBackup(self, *args, **kwargs)
|
||||||
|
|||||||
Reference in New Issue
Block a user