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") )
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 )
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 )
def new_account(): return flask.render_template( "account/new.html.tpl", link = "accounts", sub_link = "create", account = {}, errors = {} )
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 )
def new_server(): return flask.render_template( "server/new.html.tpl", link = "servers", sub_link = "create", server = {}, errors = {} )
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" )
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 )
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 )
def list_servers(): servers = models.Server.find_i() return flask.render_template( "server/list.html.tpl", link = "servers", sub_link = "list", servers = servers )
def list_contacts(): contacts = models.Contact.find_i() return flask.render_template( "contact/list.html.tpl", link = "contacts", sub_link = "list", contacts = contacts )
def new_contact(): return flask.render_template( "contact/new.html.tpl", link = "contacts", sub_link = "create", contact = {}, errors = {} )
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 = {} )
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 = {} )
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 = {} )
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 )
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) )
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) )
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) )
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) )
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) )
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) )
def signin(): return flask.render_template( "signin.html.tpl" )
def home(): return flask.render_template( "site/index.html.tpl", link = "home" )
def list_accounts(): return flask.render_template( "account/list.html.tpl", link = "accounts", sub_link = "list" )
def docs_api(): return flask.render_template( "site/docs_api.html.tpl", link = "home" )
def index(): return flask.render_template( "index.html.tpl", link = "home" )
def about(): return flask.render_template( "about.html.tpl", link = "about" )
def pending(username): account = models.Account.get(username = username) return flask.render_template( "pending.html.tpl", account = account )