def top_votes(phone_id, db): """Returns list of top opened votes for a user.""" user = controller.get_user(db, phone_id) if not user: abort(400, "Invalid or unregistered phone id") response.content_type = "application/json" return json_encode_query(controller.get_top_votes(db, user))
def logs(db): logger.info('Serving logs()') formatter = logging.Formatter(fmt='%(asctime)s %(levelname)s %(name)s %(message)s', datefmt='%Y-%m-%d %H:%M:%S') logs = [formatter.format(record) for record in config.env.history.records] if 'json' not in request.query: return template('logs.tpl', rows=logs) response.content_type = 'application/json' return json_encode_query(logs)
def pending_votes(phone_id, db): """Returns list of pending votes for a user.""" user = controller.get_user(db, phone_id) response.content_type = "application/json" return json_encode_query(controller.get_pending_votes(db, user))
def user_listing(db): logger.info("Listing users...") response.content_type = "application/json" return json_encode_query(controller.get_users(db))