Example #1
0
def set_env_app(id):
    # retrieves the app from the provided identifier
    # value (this map will be updated)
    app = util.get_app(id)

    # retrieves the key and value values from the
    # request to be used to set the new environment
    # variable for the app
    key = quorum.get_field("key")
    value = quorum.get_field("value")
    app["env"][key] = value

    # runs the validation process on new app created
    # structures (should meet the requirements)
    errors, app_v = quorum.validate(util.validate_app, object = app)
    if errors:
        return flask.render_template(
            "app/edit.html.tpl",
            link = "new_app",
            app = app_v,
            errors = errors
        )

    # saves the app back in the database to reflect
    # the changes that were made
    db = quorum.get_mongo_db()
    db.apps.save(app)

    return flask.redirect(
        flask.url_for("edit_app", id = id)
    )
Example #2
0
def set_alias_app(id):
    # retrieves the application from the provided identifier
    # and then retrieves its (main) domain value
    app = util.get_app(id)
    host = app.get("domain", None)

    # retrieves the alias sent by the post value
    # adds it as an alias in the app
    alias = quorum.get_field("alias", None)
    app["domains"].append(alias)

    # runs the validation process on new app created
    # structures (should meet the requirements)
    errors, app_v = quorum.validate(util.validate_app, object = app)
    if errors:
        return flask.render_template(
            "app/edit.html.tpl",
            link = "new_app",
            app = app_v,
            errors = errors
        )

    # saves the app back in the database to reflect
    # the changes that were made
    db = quorum.get_mongo_db()
    db.apps.save(app)

    # retrieves the current storage infra-structure
    # and sets the alias in it
    storage = quorum.get_redis()
    storage.set("alias:%s" % alias, host)

    return flask.redirect(
        flask.url_for("edit_app", id = id)
    )
Example #3
0
def set_description_app(id):
    # retrieves the app from the provided identifier
    # value (this map will be updated)
    app = util.get_app(id)

    # retrieves the description value from the
    # request to be used to set the new description
    # in the app structure
    name = quorum.get_field("description")
    app["description"] = name

    # runs the validation process on new app created
    # structures (should meet the requirements)
    errors, app_v = quorum.validate(util.validate_app, object = app)
    if errors:
        return flask.render_template(
            "app/edit.html.tpl",
            link = "new_app",
            app = app_v,
            errors = errors
        )

    # saves the app back in the database to reflect
    # the changes that were made
    db = quorum.get_mongo_db()
    db.apps.save(app)

    return flask.redirect(
        flask.url_for("edit_app", id = id)
    )
Example #4
0
def help_app(id):
    app = util.get_app(id)
    return flask.render_template(
        "app/help.html.tpl",
        link = "apps",
        sub_link = "help",
        app = app
    )
Example #5
0
def show_app(id):
    app = util.get_app(id)
    return flask.render_template(
        "app/show.html.tpl",
        link = "apps",
        sub_link = "info",
        app = app
    )
Example #6
0
def delete_app_c(id):
    app = util.get_app(id)
    return flask.render_template(
        "app/delete.html.tpl",
        link = "apps",
        sub_link = "delete",
        app = app,
        errors = {}
    )
Example #7
0
def edit_app(id):
    app = util.get_app(id)
    return flask.render_template(
        "app/edit.html.tpl",
        link = "apps",
        sub_link = "edit",
        app = app,
        errors = {}
    )
Example #8
0
def unset_alias_app(id, alias):
    # retrieves the application from the provided identifier
    # and then retrieves its (main) domain value
    app = util.get_app(id)

    # removes the alias from the app
    if alias in app["domains"]: app["domains"].remove(alias)

    # saves the app back in the database to reflect
    # the changes that were made
    db = quorum.get_mongo_db()
    db.apps.save(app)

    # retrieves the current storage infra-structure
    # and sets the alias in it
    storage = quorum.get_redis()
    storage.delete("alias:%s" % alias)

    return flask.redirect(
        flask.url_for("edit_app", id = id)
    )