Exemple #1
0
def login():
    # retrieves the next field that may be used latter
    # to re-direct the user back to the original place
    next = quorum.get_field("next")

    # retrieves the username and the password fields
    # and uses them to run the login logic raising an
    # error in case an invalid authentication occurs
    username = quorum.get_field("username")
    password = quorum.get_field("password")
    try: account = models.Account.login(username, password)
    except quorum.OperationalError as error:
        return flask.render_template(
            "signin.html.tpl",
            username = username,
            next = next,
            error = error.message
        )

    # updates the current user (name) in session with
    # the username that has just be accepted in the login
    flask.session["username"] = account.username
    flask.session["tokens"] = account.tokens

    # makes the current session permanent this will allow
    # the session to persist along multiple browser initialization
    flask.session.permanent = True

    return flask.redirect(
        next or flask.url_for("index")
    )
Exemple #2
0
def import_do():
    # retrieves the import file values (reference to the
    # uploaded file) and then validates if it has been
    # defined, in case it fails prints the template with
    # the appropriate error variable set
    import_file = quorum.get_field("import_file", None)
    if import_file == None or not import_file.filename:
        return flask.render_template(
            "settings/import.html.tpl",
            link = "settings",
            sub_link = "import",
            error = "No file defined"
        )

    # creates a temporary file path for the storage of the file
    # and then saves it into that directory
    fd, file_path = tempfile.mkstemp()
    import_file.save(file_path)

    # retrieves the database and creates a new export manager for
    # the currently defined entities then imports the data defined
    # in the current temporary path
    adapter = quorum.get_adapter()
    manager = quorum.export.ExportManager(
        adapter,
        multiple = quorum.resolve()
    )
    try: manager.import_data(file_path)
    finally: os.close(fd); os.remove(file_path)
    return flask.redirect(
        flask.url_for(
            "import_a",
            message = "Database file imported with success"
        )
    )
Exemple #3
0
def logout():
    next = quorum.get_field("next")

    if "username" in flask.session: del flask.session["username"]
    if "tokens" in flask.session: del flask.session["tokens"]

    return flask.redirect(
        flask.url_for("signin", next = next)
    )
Exemple #4
0
def do_video_event():
    url = quorum.get_field("url")

    pusher = quorum.get_pusher()
    pusher.trigger("global", "video.open", {
        "url" : url
    })

    return flask.redirect(
        flask.url_for("base_events")
    )
Exemple #5
0
def video():
    url = quorum.get_field("url")

    pusher = quorum.get_pusher()
    pusher.trigger("global", "video.open", {
        "url" : url
    })

    return flask.redirect(
        flask.url_for("index")
    )
Exemple #6
0
def github_oauth():
    code = quorum.get_field("code")
    next = quorum.get_field("state")
    error = quorum.get_field("error")
    error_description = quorum.get_field("error_description")
    if error:
        return flask.render_template(
            "error.html.tpl",
            error = error,
            description = error_description
        )

    api = models.GithubConfig.get_api()
    access_token = api.oauth_access(code)
    user = api.self_user()
    config = models.GithubConfig.singleton()
    config.access_token = access_token
    config.username = user["login"]
    config.save()
    flask.session["gh.access_token"] = access_token
    return flask.redirect(
        next or flask.url_for("index")
    )
Exemple #7
0
def github_authorize():
    next = quorum.get_field("next")
    api = models.GithubConfig.get_api()
    return flask.redirect(
        api.oauth_authorize(state = next)
    )
Exemple #8
0
def omni_callback():
    push = quorum.get_field("push") or "default"

    models.Log.notify(push, type="info", owner_extra="omni")

    return dict(success=True)
Exemple #9
0
def signin():
    next = quorum.get_field("next")
    return flask.render_template(
        "signin.html.tpl",
        next = next
    )
Exemple #10
0
def board():
    variant = quorum.get_field("variant", "sales")
    return flask.render_template(
        "board.html.tpl",
        variant = variant
    )