Ejemplo n.º 1
0
def login():
    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,
            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
    flask.session["instance_id"] = account.instance_id
    flask.session["nav_data"] = None

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

    return flask.redirect(
        flask.url_for("index")
    )
Ejemplo n.º 2
0
def login():
    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,
            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
    flask.session["instance_id"] = account.instance_id
    flask.session["nav_data"] = None

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

    return flask.redirect(
        flask.url_for("index")
    )
Ejemplo n.º 3
0
def show_contact(id):
    contact = models.Contact.get_i(id = id)
    return flask.render_template(
        "contact/show.html.tpl",
        link = "contacts",
        sub_link = "info",
        contact = contact
    )
Ejemplo n.º 4
0
def show_account(username):
    account = models.Account.get(username = username)
    return flask.render_template(
        "account/show.html.tpl",
        link = "accounts",
        sub_link = "info",
        account = account
    )
Ejemplo n.º 5
0
def new_account():
    return flask.render_template(
        "account/new.html.tpl",
        link = "accounts",
        sub_link = "create",
        account = {},
        errors = {}
    )
Ejemplo n.º 6
0
def list_log(name):
    server = models.Server.get_i(name = name)
    return flask.render_template(
        "server/log.html.tpl",
        link = "servers",
        sub_link = "log",
        server = server
    )
Ejemplo n.º 7
0
def list_log(name):
    server = models.Server.get_i(name = name)
    return flask.render_template(
        "server/log.html.tpl",
        link = "servers",
        sub_link = "log",
        server = server
    )
Ejemplo n.º 8
0
def new_server():
    return flask.render_template(
        "server/new.html.tpl",
        link = "servers",
        sub_link = "create",
        server = {},
        errors = {}
    )
Ejemplo n.º 9
0
def confirm(confirmation):
    # tries to set the account with the provided confirmation
    # code as enabled (only in case the confirmation code is valid)
    models.Account.confirmed(confirmation)

    return flask.render_template(
        "confirmed.html.tpl"
    )
Ejemplo n.º 10
0
def show_server(name):
    server = models.Server.get_i(name = name)
    return flask.render_template(
        "server/show.html.tpl",
        link = "servers",
        sub_link = "info",
        server = server
    )
Ejemplo n.º 11
0
def profile_server(name):
    server = models.Server.get(name = name)
    return flask.render_template(
        "site/server_profile.html.tpl",
        link = "servers",
        sub_link = "profile",
        server = server
    )
Ejemplo n.º 12
0
def list_servers():
    servers = models.Server.find_i()
    return flask.render_template(
        "server/list.html.tpl",
        link = "servers",
        sub_link = "list",
        servers = servers
    )
Ejemplo n.º 13
0
def profile_server(name):
    server = models.Server.get(name = name)
    return flask.render_template(
        "site/server_profile.html.tpl",
        link = "servers",
        sub_link = "profile",
        server = server
    )
Ejemplo n.º 14
0
def new_server():
    return flask.render_template(
        "server/new.html.tpl",
        link = "servers",
        sub_link = "create",
        server = {},
        errors = {}
    )
Ejemplo n.º 15
0
def list_contacts():
    contacts = models.Contact.find_i()
    return flask.render_template(
        "contact/list.html.tpl",
        link = "contacts",
        sub_link = "list",
        contacts = contacts
    )
Ejemplo n.º 16
0
def new_contact():
    return flask.render_template(
        "contact/new.html.tpl",
        link = "contacts",
        sub_link = "create",
        contact = {},
        errors = {}
    )
Ejemplo n.º 17
0
def new_account():
    return flask.render_template(
        "account/new.html.tpl",
        link = "accounts",
        sub_link = "create",
        account = {},
        errors = {}
    )
Ejemplo n.º 18
0
def show_server(name):
    server = models.Server.get_i(name = name)
    return flask.render_template(
        "server/show.html.tpl",
        link = "servers",
        sub_link = "info",
        server = server
    )
Ejemplo n.º 19
0
def show_account(username):
    account = models.Account.get(username = username)
    return flask.render_template(
        "account/show.html.tpl",
        link = "accounts",
        sub_link = "info",
        account = account
    )
Ejemplo n.º 20
0
def confirm(confirmation):
    # tries to set the account with the provided confirmation
    # code as enabled (only in case the confirmation code is valid)
    models.Account.confirmed(confirmation)

    return flask.render_template(
        "confirmed.html.tpl"
    )
Ejemplo n.º 21
0
def list_servers():
    servers = models.Server.find_i()
    return flask.render_template(
        "server/list.html.tpl",
        link = "servers",
        sub_link = "list",
        servers = servers
    )
Ejemplo n.º 22
0
def edit_account(username):
    account = models.Account.get(username = username)
    return flask.render_template(
        "account/edit.html.tpl",
        link = "accounts",
        sub_link = "edit",
        account = account,
        errors = {}
    )
Ejemplo n.º 23
0
def edit_contact(id):
    contact = models.Contact.get_i(id = id)
    return flask.render_template(
        "contact/edit.html.tpl",
        link = "contacts",
        sub_link = "edit",
        contact = contact,
        errors = {}
    )
Ejemplo n.º 24
0
def edit_server(name):
    server = models.Server.get_i(name = name)
    return flask.render_template(
        "server/edit.html.tpl",
        link = "servers",
        sub_link = "edit",
        server = server,
        errors = {}
    )
Ejemplo n.º 25
0
def edit_account(username):
    account = models.Account.get(username = username)
    return flask.render_template(
        "account/edit.html.tpl",
        link = "accounts",
        sub_link = "edit",
        account = account,
        errors = {}
    )
Ejemplo n.º 26
0
def edit_server(name):
    server = models.Server.get_i(name = name)
    return flask.render_template(
        "server/edit.html.tpl",
        link = "servers",
        sub_link = "edit",
        server = server,
        errors = {}
    )
Ejemplo n.º 27
0
def resend(username):
    # starts the confirmation process for the account this should
    # start sending the email to the created account
    account = models.Account.get(username = username, build = False)
    account.confirm()

    return flask.render_template(
        "pending.html.tpl",
        account = account
    )
Ejemplo n.º 28
0
def resend(username):
    # starts the confirmation process for the account this should
    # start sending the email to the created account
    account = models.Account.get(username = username, build = False)
    account.confirm()

    return flask.render_template(
        "pending.html.tpl",
        account = account
    )
Ejemplo n.º 29
0
def create_server():
    # creates the new server, using the provided arguments and
    # then saves it into the data source, all the validations
    # should be ran upon the save operation
    server = models.Server.new()
    try: server.save()
    except quorum.ValidationError as error:
        return flask.render_template(
            "server/new.html.tpl",
            link = "servers",
            sub_link = "create",
            server = error.model,
            errors = error.errors
        )

    # redirects the user to the show page of the server that
    # was just created
    return flask.redirect(
        flask.url_for("show_server", name = server.name)
    )
Ejemplo n.º 30
0
def create_contact():
    # creates the new contact, using the provided arguments and
    # then saves it into the data source, all the validations
    # should be ran upon the save operation
    contact = models.Contact.new()
    try: contact.save()
    except quorum.ValidationError as error:
        return flask.render_template(
            "contact/new.html.tpl",
            link = "contacts",
            sub_link = "create",
            contact = error.model,
            errors = error.errors
        )

    # redirects the user to the show page of the contact that
    # was just created
    return flask.redirect(
        flask.url_for("show_contact", id = contact.id)
    )
Ejemplo n.º 31
0
def create_server():
    # creates the new server, using the provided arguments and
    # then saves it into the data source, all the validations
    # should be ran upon the save operation
    server = models.Server.new()
    try: server.save()
    except quorum.ValidationError as error:
        return flask.render_template(
            "server/new.html.tpl",
            link = "servers",
            sub_link = "create",
            server = error.model,
            errors = error.errors
        )

    # redirects the user to the show page of the server that
    # was just created
    return flask.redirect(
        flask.url_for("show_server", name = server.name)
    )
Ejemplo n.º 32
0
def update_server(name):
    # finds the current server and applies the provided
    # arguments and then saves it into the data source,
    # all the validations should be ran upon the save operation
    server = models.Server.get_i(name = name)
    server.apply()
    try: server.save()
    except quorum.ValidationError as error:
        return flask.render_template(
            "server/edit.html.tpl",
            link = "servers",
            sub_link = "edit",
            server = error.model,
            errors = error.errors
        )

    # redirects the user to the show page of the server that
    # was just updated
    return flask.redirect(
        flask.url_for("show_server", name = name)
    )
Ejemplo n.º 33
0
def update_account(username):
    # finds the current account and applies the provided
    # arguments and then saves it into the data source,
    # all the validations should be ran upon the save operation
    account = models.Account.get(username = username)
    account.apply()
    try: account.save()
    except quorum.ValidationError as error:
        return flask.render_template(
            "account/edit.html.tpl",
            link = "accounts",
            sub_link = "edit",
            account = error.model,
            errors = error.errors
        )

    # redirects the user to the show page of the account that
    # was just updated
    return flask.redirect(
        flask.url_for("show_account", username = username)
    )
Ejemplo n.º 34
0
def create_account():
    # creates the new account, using the provided arguments and
    # then saves it into the data source, all the validations
    # should be ran upon the save operation
    account = models.Account.new()
    try: account.save()
    except quorum.ValidationError as error:
        return flask.render_template(
            "account/new.html.tpl",
            link = "accounts",
            sub_link = "create",
            account = error.model,
            errors = error.errors
        )

    # redirects the user to the pending page, indicating that
    # the account is not yet activated and is pending the email
    # confirmation action
    return flask.redirect(
        flask.url_for("pending", username = account.username)
    )
Ejemplo n.º 35
0
def update_server(name):
    # finds the current server and applies the provided
    # arguments and then saves it into the data source,
    # all the validations should be ran upon the save operation
    server = models.Server.get_i(name = name)
    server.apply()
    try: server.save()
    except quorum.ValidationError as error:
        return flask.render_template(
            "server/edit.html.tpl",
            link = "servers",
            sub_link = "edit",
            server = error.model,
            errors = error.errors
        )

    # redirects the user to the show page of the server that
    # was just updated
    return flask.redirect(
        flask.url_for("show_server", name = name)
    )
Ejemplo n.º 36
0
def create_account():
    # creates the new account, using the provided arguments and
    # then saves it into the data source, all the validations
    # should be ran upon the save operation
    account = models.Account.new()
    try: account.save()
    except quorum.ValidationError as error:
        return flask.render_template(
            "account/new.html.tpl",
            link = "accounts",
            sub_link = "create",
            account = error.model,
            errors = error.errors
        )

    # redirects the user to the pending page, indicating that
    # the account is not yet activated and is pending the email
    # confirmation action
    return flask.redirect(
        flask.url_for("pending", username = account.username)
    )
Ejemplo n.º 37
0
def update_contact(id):
    # finds the current contact and applies the provided
    # arguments and then saves it into the data source,
    # all the validations should be ran upon the save operation
    contact = models.Contact.get_i(id = id)
    contact.apply()
    try: contact.save()
    except quorum.ValidationError as error:
        return flask.render_template(
            "contact/edit.html.tpl",
            link = "contacts",
            sub_link = "edit",
            server = error.model,
            errors = error.errors
        )

    # redirects the user to the show page of the contact that
    # was just updated
    return flask.redirect(
        flask.url_for("show_contact", id = id)
    )
Ejemplo n.º 38
0
def update_account(username):
    # finds the current account and applies the provided
    # arguments and then saves it into the data source,
    # all the validations should be ran upon the save operation
    account = models.Account.get(username = username)
    account.apply()
    try: account.save()
    except quorum.ValidationError as error:
        return flask.render_template(
            "account/edit.html.tpl",
            link = "accounts",
            sub_link = "edit",
            account = error.model,
            errors = error.errors
        )

    # redirects the user to the show page of the account that
    # was just updated
    return flask.redirect(
        flask.url_for("show_account", username = username)
    )
Ejemplo n.º 39
0
def signin():
    return flask.render_template(
        "signin.html.tpl"
    )
Ejemplo n.º 40
0
def home():
    return flask.render_template(
        "site/index.html.tpl",
        link = "home"
    )
Ejemplo n.º 41
0
def list_accounts():
    return flask.render_template(
        "account/list.html.tpl",
        link = "accounts",
        sub_link = "list"
    )
Ejemplo n.º 42
0
def docs_api():
    return flask.render_template(
        "site/docs_api.html.tpl",
        link = "home"
    )
Ejemplo n.º 43
0
def index():
    return flask.render_template(
        "index.html.tpl",
        link = "home"
    )
Ejemplo n.º 44
0
def about():
    return flask.render_template(
        "about.html.tpl",
        link = "about"
    )
Ejemplo n.º 45
0
def pending(username):
    account = models.Account.get(username = username)
    return flask.render_template(
        "pending.html.tpl",
        account = account
    )
Ejemplo n.º 46
0
def list_accounts():
    return flask.render_template(
        "account/list.html.tpl",
        link = "accounts",
        sub_link = "list"
    )
Ejemplo n.º 47
0
def signin():
    return flask.render_template(
        "signin.html.tpl"
    )
Ejemplo n.º 48
0
def home():
    return flask.render_template(
        "site/index.html.tpl",
        link = "home"
    )
Ejemplo n.º 49
0
def docs_api():
    return flask.render_template(
        "site/docs_api.html.tpl",
        link = "home"
    )
Ejemplo n.º 50
0
def index():
    return flask.render_template(
        "index.html.tpl",
        link = "home"
    )
Ejemplo n.º 51
0
def about():
    return flask.render_template(
        "about.html.tpl",
        link = "about"
    )
Ejemplo n.º 52
0
def pending(username):
    account = models.Account.get(username = username)
    return flask.render_template(
        "pending.html.tpl",
        account = account
    )