def db_create(): "Will create the database." with application.app_context(): mosp.models.db_create( db, application.config["DB_CONFIG_DICT"], application.config["DATABASE_NAME"], )
from mosp.bootstrap import application from mosp import commands def register_commands(app): """Register Click commands.""" app.cli.add_command(commands.uml_graph) app.cli.add_command(commands.db_empty) app.cli.add_command(commands.db_create) app.cli.add_command(commands.db_init) app.cli.add_command(commands.import_licenses_from_spdx) app.cli.add_command(commands.create_admin) app.cli.add_command(commands.create_user) with application.app_context(): from mosp.web import views application.register_blueprint(views.schema_bp) application.register_blueprint(views.schemas_bp) application.register_blueprint(views.object_bp) application.register_blueprint(views.objects_bp) application.register_blueprint(views.admin_bp) application.register_blueprint(views.user_bp) application.register_blueprint(views.organization_bp) application.register_blueprint(views.organizations_bp) application.register_blueprint(views.stats_bp) # API v1
def create_admin(login, email, password): "Initializes an admin user" print(f"Creation of the admin user {login} ...") with application.app_context(): mosp.scripts.create_user(login, email, password, True, True)
def import_licenses_from_spdx(): "Import licenses from spdx.org." print("Importing licenses from spdx.org...") with application.app_context(): mosp.scripts.import_licenses_from_spdx()
def db_init(): "Will create the database from conf parameters." with application.app_context(): mosp.models.db_init(db)
def db_empty(): "Will drop every datas stocked in db." with application.app_context(): mosp.models.db_empty(db)
def uml_graph(): "UML graph from the models." with application.app_context(): mosp.models.uml_graph(db)
def create_admin(login, password): "Initializes an admin user" print("Creation of the admin user {} ...".format(login)) with application.app_context(): mosp.scripts.create_user(login, password, True)
def create_user(login, email, password): "Initializes a user" print("Creation of the user {} ...".format(login)) with application.app_context(): mosp.scripts.create_user(login, email, password, False)