def initflaskbb(username=None, password=None, email=None): """Initializes FlaskBB with all necessary data""" app.logger.info("Creating default groups...") try: create_default_groups() except IntegrityError: app.logger.error("Couldn't create the default groups because they are\ already exist!") if prompt_bool("Do you want to recreate the database? (y/n)"): db.session.rollback() db.drop_all() db.create_all() create_default_groups() else: sys.exit(0) except OperationalError: app.logger.error("No database found.") if prompt_bool("Do you want to create the database? (y/n)"): db.session.rollback() db.create_all() create_default_groups() else: sys.exit(0) app.logger.info("Creating admin user...") if username and password and email: create_admin_user(username=username, password=password, email=email) else: create_admin() app.logger.info("Creating welcome forum...") create_welcome_forum() app.logger.info("Congratulations! FlaskBB has been successfully installed")
def install(welcome, force, username, email, password): """Installs flaskbb. If no arguments are used, an interactive setup will be run. """ click.secho("[+] Installing FlaskBB...", fg="cyan") if database_exists(db.engine.url): if force or click.confirm( click.style( "Existing database found. Do you want to delete the old one and " "create a new one?", fg="magenta")): db.drop_all() else: sys.exit(0) # creating database from scratch and 'stamping it' create_latest_db() click.secho("[+] Creating default settings...", fg="cyan") create_default_groups() create_default_settings() click.secho("[+] Creating admin user...", fg="cyan") prompt_save_user(username, email, password, "admin") if welcome: click.secho("[+] Creating welcome forum...", fg="cyan") create_welcome_forum() click.secho("[+] Compiling translations...", fg="cyan") compile_translations() click.secho("[+] FlaskBB has been successfully installed!", fg="green", bold=True)
def install(welcome, force, username, email, password, group): """Installs flaskbb. If no arguments are used, an interactive setup will be run. """ click.secho("[+] Installing FlaskBB...", fg="cyan") if database_exists(db.engine.url): if force or click.confirm(click.style( "Existing database found. Do you want to delete the old one and " "create a new one?", fg="magenta") ): drop_database(db.engine.url) else: sys.exit(0) create_database(db.engine.url) upgrade_database() click.secho("[+] Creating default settings...", fg="cyan") create_default_groups() create_default_settings() click.secho("[+] Creating admin user...", fg="cyan") prompt_save_user(username, email, password, group) if welcome: click.secho("[+] Creating welcome forum...", fg="cyan") create_welcome_forum() click.secho("[+] Compiling translations...", fg="cyan") compile_translations() click.secho("[+] FlaskBB has been successfully installed!", fg="green", bold=True)
def create_default_data(): """ This should be created by every flaskbb installation """ db.create_all() create_default_groups() create_welcome_forum()
def test_create_welcome_forum(default_groups): assert not create_welcome_forum() create_user(username="******", password="******", email="*****@*****.**", groupname="admin") assert create_welcome_forum()
def install(welcome, force, username, email, password, no_plugins): """Installs flaskbb. If no arguments are used, an interactive setup will be run. """ if not current_app.config["CONFIG_PATH"]: click.secho( "[!] No 'flaskbb.cfg' config found. " "You can generate a configuration file with 'flaskbb makeconfig'.", fg="red", ) sys.exit(1) click.secho("[+] Installing FlaskBB...", fg="cyan") if database_exists(db.engine.url): if force or click.confirm( click.style( "Existing database found. Do you want to delete the old one and " "create a new one?", fg="magenta", )): db.drop_all() else: sys.exit(0) # creating database from scratch and 'stamping it' create_latest_db() click.secho("[+] Creating default settings...", fg="cyan") create_default_groups() create_default_settings() click.secho("[+] Creating admin user...", fg="cyan") prompt_save_user(username, email, password, "admin") if welcome: click.secho("[+] Creating welcome forum...", fg="cyan") create_welcome_forum() if not no_plugins: click.secho("[+] Installing default plugins...", fg="cyan") run_plugin_migrations() click.secho("[+] Compiling translations...", fg="cyan") compile_translations() click.secho("[+] FlaskBB has been successfully installed!", fg="green", bold=True)
def install(username=None, password=None, email=None): """Installs FlaskBB with all necessary data.""" print("Creating default data...") try: create_default_groups() create_default_settings() except IntegrityError: print("Couldn't create the default data because it already exist!") if prompt_bool("Found an existing database." "Do you want to recreate the database? (y/n)"): db.session.rollback() db.drop_all() upgrade() create_default_groups() create_default_settings() else: sys.exit(0) except OperationalError: print("No database found.") if prompt_bool("Do you want to create the database now? (y/n)"): db.session.rollback() upgrade() create_default_groups() create_default_settings() else: sys.exit(0) print("Creating admin user...") if username and password and email: create_admin_user(username=username, password=password, email=email) else: create_admin() print("Creating welcome forum...") create_welcome_forum() print("Compiling translations...") compile_translations() if prompt_bool("Do you want to use Emojis? (y/n)"): print("Downloading emojis. This can take a few minutes.") download_emoji() print("Congratulations! FlaskBB has been successfully installed")