def bootstrap_db_data(db, mark=True): # import after session to delay loading of BaseOps from assembl.models import (Permission, Role, IdentityProvider, Locale, LandingPageModuleType, LocaleLabel, ExtractNatureVocabulary, ExtractActionVocabulary, User) from assembl.lib.database_functions import ensure_functions with locked_transaction(db, 1236) as session: for cls in (Permission, Role, IdentityProvider, Locale, LocaleLabel, LandingPageModuleType, ExtractNatureVocabulary, ExtractActionVocabulary, User): cls.populate_db(session) ensure_functions(session) admin_users = config.get('admin_users', None) if admin_users: from assembl.auth.util import add_user from pyramid.exceptions import ConfigurationError try: admin_users = json.loads(admin_users) for user in admin_users: name = user.pop('name', None) email = user.pop('email', None) if not (name and email): continue try: add_user(name, email, **user) except AssertionError as e: print(e) except ConfigurationError: pass # no application. It can be done later. # if mark: mark_changed(session)
def bootstrap_db_data(db, mark=True): # import after session to delay loading of BaseOps from assembl.models import (Permission, Role, IdentityProvider, Locale) from assembl.lib.database_functions import ensure_functions session = db() for cls in (Permission, Role, IdentityProvider, Locale): cls.populate_db(session) ensure_functions(session) if mark: mark_changed(session)
def bootstrap_db_data(db): # import after session to delay loading of BaseOps from assembl.models.langstrings import populate_default_locales populate_default_locales(db()) from assembl.models.auth import ( populate_default_permissions, populate_default_roles) from assembl.lib.database_functions import ensure_functions populate_default_permissions(db()) populate_default_roles(db()) ensure_functions(db()) mark_changed(db())
def bootstrap_db_data(db, mark=True): # import after session to delay loading of BaseOps from assembl.models import ( Permission, Role, IdentityProvider, Locale) from assembl.lib.database_functions import ensure_functions session = db() for cls in (Permission, Role, IdentityProvider, Locale): cls.populate_db(session) ensure_functions(session) if mark: mark_changed(session)
def bootstrap_db_data(db, mark=True): # import after session to delay loading of BaseOps from assembl.models import ( Permission, Role, IdentityProvider, Locale, LandingPageModuleType, LocaleLabel, ExtractNatureVocabulary, ExtractActionVocabulary) from assembl.lib.database_functions import ensure_functions session = db() for cls in (Permission, Role, IdentityProvider, Locale, LocaleLabel, LandingPageModuleType, ExtractNatureVocabulary, ExtractActionVocabulary): cls.populate_db(session) ensure_functions(session) if mark: mark_changed(session)
def bootstrap_db_data(db, mark=True): from assembl.lib.config import get if get('in_alembic'): return # import after session to delay loading of BaseOps from assembl.models import ( Permission, Role, IdentityProvider, LocaleLabel, URIRefDb) from assembl.lib.database_functions import ensure_functions session = db() for cls in (Permission, Role, IdentityProvider, LocaleLabel, URIRefDb): cls.populate_db(session) ensure_functions(session) mark |= update_indices(session) if mark: mark_changed(session)
def bootstrap_db_data(db, mark=True): # import after session to delay loading of BaseOps from assembl.models import ( Permission, Role, IdentityProvider, Locale, LandingPageModuleType, LocaleLabel, ExtractNatureVocabulary, ExtractActionVocabulary, User) from assembl.lib.database_functions import ensure_functions session = db() for cls in (Permission, Role, IdentityProvider, Locale, LocaleLabel, LandingPageModuleType, ExtractNatureVocabulary, ExtractActionVocabulary, User): cls.populate_db(session) ensure_functions(session) if mark: mark_changed(session) session.flush()