Ejemplo n.º 1
0
def login():
    # If there are no users, send them to the registration page
    if User.select().count() == 0:
        flash("No admins found, please register the first administrator.",
              "info")
        return redirect(url_for(".register"))
    return render_template("admin/login.html")
Ejemplo n.º 2
0
def register_post():
    # Only allow access if logged in or no users are registered
    if current_user.is_anonymous() and User.select().count() > 0:
        return current_app.login_manager.unauthorized()

    name = get_post_value("name")
    email = get_post_value("email")
    password = get_post_value("password")

    errors = register_user(name, email, password)
    if len(errors) > 0:  # This means that an error has occured
        for e in errors:
            flash(e, 'danger')
        return render_template("admin/register.html", name=name, email=email)
    else:
        flash("User registered successfully.", "success")
        return redirect(url_for('.register'))
Ejemplo n.º 3
0
def register_post():
    # Only allow access if logged in or no users are registered
    if current_user.is_anonymous() and User.select().count() > 0:
        return current_app.login_manager.unauthorized()

    name = get_post_value("name")
    email = get_post_value("email")
    password = get_post_value("password")

    errors = register_user(name, email, password)
    if len(errors) > 0:  # This means that an error has occured
        for e in errors:
            flash(e, 'danger')
        return render_template("admin/register.html", name=name, email=email)
    else:
        flash("User registered successfully.", "success")
        return redirect(url_for('.register'))
Ejemplo n.º 4
0
def register():
    # Only allow access if logged in or no users are registered
    if current_user.is_anonymous() and User.select().count() > 0:
        return current_app.login_manager.unauthorized()

    return render_template("admin/register.html")
Ejemplo n.º 5
0
def login():
    # If there are no users, send them to the registration page
    if User.select().count() == 0:
        flash("No admins found, please register the first administrator.", "info")
        return redirect(url_for(".register"))
    return render_template("admin/login.html")
Ejemplo n.º 6
0
app.config.from_object('settings')

database = SqliteDatabase(app.config['DATABASE'], threadlocals=True)

from mhvdb2.admin import admin  # noqa
app.register_blueprint(admin, url_prefix='/admin')


@app.before_request
def before_request():
    g.db = database
    g.db.connect()


@app.after_request
def after_request(response):
    g.db.close()
    return response

import mhvdb2.routes   # noqa

from mhvdb2.models import Entity, User  # noqa

database.connect()
if not Entity.table_exists():
    Entity.create_table()
if not User.table_exists():
    User.create_table()
database.close()
Ejemplo n.º 7
0
database = SqliteDatabase(app.config['DATABASE'], threadlocals=True)

from mhvdb2.admin import admin  # noqa

app.register_blueprint(admin, url_prefix='/admin')


@app.before_request
def before_request():
    g.db = database
    g.db.connect()


@app.after_request
def after_request(response):
    g.db.close()
    return response


import mhvdb2.routes  # noqa

from mhvdb2.models import Entity, User  # noqa

database.connect()
if not Entity.table_exists():
    Entity.create_table()
if not User.table_exists():
    User.create_table()
database.close()
Ejemplo n.º 8
0
def register():
    # Only allow access if logged in or no users are registered
    if current_user.is_anonymous() and User.select().count() > 0:
        return current_app.login_manager.unauthorized()

    return render_template("admin/register.html")