예제 #1
0
파일: manage.py 프로젝트: xuemy/flaskbb
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")
예제 #2
0
def database():
    """database setup."""
    db.create_all()  # Maybe use migration instead?

    yield db

    db.drop_all()
예제 #3
0
파일: app.py 프로젝트: 0xsKu/flaskbb
def database():
    """database setup."""
    db.create_all()  # Maybe use migration instead?

    yield db

    db.drop_all()
예제 #4
0
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)
예제 #5
0
def populate(bulk_data, test_data, posts, topics, force, initdb):
    """Creates the necessary tables and groups for FlaskBB."""
    if force:
        click.secho("[+] Recreating database...", fg="cyan")
        db.drop_all()

        # do not initialize the db if -i is passed
        if not initdb:
            create_latest_db()

    if initdb:
        click.secho("[+] Initializing database...", fg="cyan")
        create_latest_db()

    if test_data:
        click.secho("[+] Adding some test data...", fg="cyan")
        create_test_data()

    if bulk_data:
        timer = time.time()
        topic_count, post_count = insert_bulk_data(int(topics), int(posts))
        elapsed = time.time() - timer
        click.secho(
            "[+] It took {} seconds to create {} topics and {} posts".format(
                elapsed, topic_count, post_count),
            fg="cyan")

    # this just makes the most sense for the command name; use -i to
    # init the db as well
    if not test_data:
        click.secho("[+] Populating the database with some defaults...",
                    fg="cyan")
        create_default_groups()
        create_default_settings()
예제 #6
0
def createall():
    """
    Creates the database with some example content.
    """

    # Just for testing purposes
    db.drop_all()

    db.create_all()
    create_test_data()
예제 #7
0
파일: manage.py 프로젝트: javaj0hn/flaskbb
def populate(dropdb=False, createdb=False):
    """Creates the database with some default data.
    To drop or create the databse use the '-d' or '-c' options.
    """
    if dropdb:
        print("Dropping database...")
        db.drop_all()

    if createdb:
        print("Creating database...")
        upgrade()

    print("Creating test data...")
    create_test_data()
예제 #8
0
def populate(dropdb=False, createdb=False):
    """Creates the database with some default data.
    To drop or create the databse use the '-d' or '-c' options.
    """
    if dropdb:
        print("Dropping database...")
        db.drop_all()

    if createdb:
        print("Creating database...")
        upgrade()

    print("Creating test data...")
    create_test_data()
예제 #9
0
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)
예제 #10
0
파일: manage.py 프로젝트: xuemy/flaskbb
def createall(dropdb=False, createdb=False):
    """Creates the database with some testing content.
    If you do not want to drop or create the db add
    '-c' (to not create the db) and '-d' (to not drop the db)
    """

    if not dropdb:
        app.logger.info("Dropping database...")
        db.drop_all()

    if not createdb:
        app.logger.info("Creating database...")
        db.create_all()

    app.logger.info("Creating test data...")
    create_test_data()
예제 #11
0
파일: manage.py 프로젝트: delida/flaskbb
def populate(dropdb=False, createdb=False):
    """Creates the database with some default data.
    If you do not want to drop or create the db add
    '-c' (to not create the db) and '-d' (to not drop the db)
    """

    if not dropdb:
        print("Dropping database...")
        db.drop_all()

    if not createdb:
        print("Creating database...")
        upgrade()

    app.logger.info("Creating test data...")
    create_test_data()
예제 #12
0
파일: manage.py 프로젝트: vlttnv/flaskbb
def populate(dropdb=False, createdb=False):
    """Creates the database with some default data.
    If you do not want to drop or create the db add
    '-c' (to not create the db) and '-d' (to not drop the db)
    """

    if dropdb:
        print("Dropping database...")
        db.drop_all()

    if createdb:
        print("Creating database...")
        upgrade()

    app.logger.info("Creating test data...")
    create_test_data()
예제 #13
0
파일: manage.py 프로젝트: javaj0hn/flaskbb
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")
예제 #14
0
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")
예제 #15
0
파일: main.py 프로젝트: eirnym/flaskbb
def install(welcome, force, username, email, password, no_plugins):
    """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()

    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)
예제 #16
0
파일: main.py 프로젝트: eirnym/flaskbb
def populate(bulk_data, test_data, posts, topics, force, initdb):
    """Creates the necessary tables and groups for FlaskBB."""
    if force:
        click.secho("[+] Recreating database...", fg="cyan")
        db.drop_all()

        # do not initialize the db if -i is passed
        if not initdb:
            create_latest_db()

    if initdb:
        click.secho("[+] Initializing database...", fg="cyan")
        create_latest_db()
        run_plugin_migrations()

    if test_data:
        click.secho("[+] Adding some test data...", fg="cyan")
        create_test_data()

    if bulk_data:
        click.secho("[+] Adding a lot of test data...", fg="cyan")
        timer = time.time()
        rv = insert_bulk_data(int(topics), int(posts))
        if not rv and not test_data:
            create_test_data()
            rv = insert_bulk_data(int(topics), int(posts))
        elapsed = time.time() - timer
        click.secho("[+] It took {:.2f} seconds to create {} topics and {} "
                    "posts.".format(elapsed, rv[0], rv[1]), fg="cyan")

    # this just makes the most sense for the command name; use -i to
    # init the db as well
    if not test_data and not bulk_data:
        click.secho("[+] Populating the database with some defaults...",
                    fg="cyan")
        create_default_groups()
        create_default_settings()
예제 #17
0
파일: manage.py 프로젝트: javaj0hn/flaskbb
def dropdb():
    """Deletes the database."""
    db.drop_all()
예제 #18
0
파일: manage.py 프로젝트: xuemy/flaskbb
def dropdb():
    """Deletes the database"""

    db.drop_all()