def list(): """ """ list_id = request.args.get("list-id", None) user = core_users_list(user_id=list_id) return jsonify(user)
def create(): """ """ name = request.json.get("name", None) rank = request.json.get("rank", None) data = core.rank.create(name=name, rank=rank) data = set_message(data) return jsonify(data)
def show(): """ """ user_id = request.args.get("user-id", None) user = core_users_show(user_id=user_id) return jsonify(user)
def remove(): """ This method removes an hash map. :param _id: MongoDB ObjectId """ page_id = request.args.get("_id", None) data = core.pages.remove(page_id=page_id) data = set_message(data) return jsonify(data)
def update(): """ """ params = request.json user_id = params["_id"] data = core.users.update(user_id=user_id, params=params) return jsonify(data)
def update_password(): """ """ params = request.json user_id = g.my['_id'] data = core.users.update_password(user_id=user_id, params=params) return jsonify(data)
def settings(): """ """ params = request.json user = core_settings(params) return jsonify(user)
def index(): """ """ data = { } return jsonify(data)
def join(): """ """ data = { } return jsonify(data)
def logout(): """ """ data = { } return jsonify(data)
def list(): """ Returns a JSON object with the users list """ my_rank = g.my['rank'] if g.my else None my_id = g.my['_id'] if g.my else None data = users.get_list(my_rank=my_rank, my_id=my_id) return jsonify(data)
def remove(): """ Removes a user. :param _id: MongoDB ObjectId """ user_id = request.args.get("_id", None) data = users.remove(user_id=user_id) return jsonify(data)
def update(): """ """ rank_id = request.json.get("rank-id", None) name = request.json.get("name", None) rank = request.json.get("rank", None) data = core.rank.update(rank_id=rank_id, name=name, rank=rank) data = set_message(data) return jsonify(data)
def overview(): """ List all the documents, each has a name that identifies it, and an hash map. """ page_list = list(g.db.pages.find().sort('name')) data = { "success": True, "page_list": page_list } return jsonify(data)
def get(): """ """ _id = request.args.get("_id", None) page = g.db.pages.find_one({ "_id": ensure_objectid(_id) }) data = { "success": True, "page": page } return jsonify(data)
def overview(): """ List all the documents, each has a name that identifies it, and an hash map. """ hash_map_list = hash_table_list() data = { "success": True, "hash_map_list": hash_map_list } return jsonify(data)
def get(): """ """ _id = request.args.get("_id", None) hash_map = hash_table_get(_id) data = { "success": True, "hash_map": hash_map } return jsonify(data)
def change(): """ Change language """ lang = request.args.get("lang", None) my_id = None if hasattr(g, 'my') and g.my: my_id = g.my['_id'] data = core.languages.change(lang=lang, my_id=my_id) return jsonify(data)
def api(): """ """ if request.method == "GET": data = core.languages.show() elif request.method == "POST": data = core.languages.new() elif request.method == "PUT": data = core.languages.update() elif request.method == "DELETE": data = core.languages.remove() return jsonify(data)
def remove(): """ This method removes an hash map. :param _id: MongoDB ObjectId """ _id = request.args.get("_id", None) page_object = Pages(_id=_id) success = False if _id: success = page_object.remove() data = {"success": success} return jsonify(data)
def new(): """ Create a new document within the hash table. """ params = request.json page_object = Pages(params=params) page_object.new() data = { "success": page_object.success, "message": page_object.message, "page": page_object.page } return jsonify(data)
def show(): """ By passing a user id, return an object with the user info. That object could be different in base of different rank permission. :param user-id: user id :returns: an object with all the user information """ my_rank = g.my['rank'] if g.my else None my_id = g.my['_id'] if g.my else None user_id = request.args.get("user_id", None) data = users.get(user_id=user_id, my_rank=my_rank, my_id=my_id) return jsonify(data)
def update_password(): """ """ params = request.json user_object = User(params=params, _id=params["_id"]) user_object.update_password() data = { "success": user_object.success, "message": user_object.message, "user": user_object.user } return jsonify(data)
def new(): """ Create a new document within the hash table. """ language_name = languages_object.get_languages(5) params = request.json hash_object = HashTable(params=params) hash_object.new() data = { "success": hash_object.success, "message": hash_object.message, "hash_map": hash_object.hash_map } return jsonify(data)
def update_account(): """ """ params = request.json user_object = User(params=params, _id=params["_id"]) user_object.update_account() data = { "success": user_object.success, "message": user_object.message, "user": user_object.user } return jsonify(data)
def new(): """ """ params = request.json user_object = User(params=params) user_object.new() data = { "success": user_object.success, "message": user_object.message, "user": user_object.user } return jsonify(data)
def remove(): """ This method removes an hash map. :param _id: MongoDB ObjectId """ _id = request.args.get("_id", None) page_object = Pages(_id=_id) success = False if _id: success = page_object.remove() data = { "success": success } return jsonify(data)
def update(): """ """ params = request.json success = False message = "" page = {} if "_id" in params: page_object = Pages(params=params, _id=params["_id"]) page_object.update() success = page_object.success message = page_object.message page = page_object.page data = {"success": success, "message": message, "page": page} return jsonify(data)
def update(): """ """ language_name = languages_object.get_languages(5) params = request.json success = False message = "" hash_map = {} if "_id" in params: hash_object = HashTable(params=params, _id=params["_id"]) hash_object.update() success = hash_object.success message = hash_object.message hash_map = hash_object.hash_map data = {"success": success, "message": message, "hash_map": hash_map} return jsonify(data)
def upload_avatar(): """ """ name = secure_filename(request.headers.get('X-File-Name')) extension = name.rsplit('.', 1)[1].lower() up = Upload() path_image = up.ajax_upload(UP_AVATARS_TMP_FOLDER, extension) if not up.allowed_file(): success = False message = g.users_msg('error_upload_1') else: up.thumb((128, 128), os.path.join(UP_AVATARS_TMP_FOLDER, path_image)) if path_image != 'error': success = True message = path_image data = {"success": success, "message": message} return jsonify(data)
def update(): """ """ params = request.json success = False message = "" page = {} if "_id" in params: page_object = Pages(params=params, _id=params["_id"]) page_object.update() success = page_object.success message = page_object.message page = page_object.page data = { "success": success, "message": message, "page": page } return jsonify(data)
def update(): """ """ language_name = languages_object.get_languages(5) params = request.json success = False message = "" hash_map = {} if "_id" in params: hash_object = HashTable(params=params, _id=params["_id"]) hash_object.update() success = hash_object.success message = hash_object.message hash_map = hash_object.hash_map data = { "success": success, "message": message, "hash_map": hash_map } return jsonify(data)
def upload_avatar(): """ """ name = secure_filename(request.headers.get('X-File-Name')) extension = name.rsplit('.', 1)[1].lower() up = Upload() path_image = up.ajax_upload(UP_AVATARS_TMP_FOLDER, extension) if not up.allowed_file(): success = False message = g.users_msg('error_upload_1') else: up.thumb((128, 128), os.path.join(UP_AVATARS_TMP_FOLDER, path_image)) if path_image != 'error': success = True message = path_image data = { "success": success, "message": message } return jsonify(data)
def overview(): """ List all the documents, each has a name that identifies it, and an hash map. """ data = core.pages.get_list(sorted_by='name') data = set_message(data) return jsonify(data)
def get(): """ """ _id = request.args.get("_id", None) data = core.hash_table.get(_id) data = set_message(data) return jsonify(data)
def new(): """ Create a new document within the hash table. """ params = request.json data = core.pages.create(params=params, my_rank=g.my['rank']) data = set_message(data) return jsonify(data)
def get(): """ """ page_id = request.args.get("_id", None) data = core.pages.get(page_id=page_id) data = set_message(data) return jsonify(data)
def update(): """ """ params = request.json data = core.pages.update(params=params) data = set_message(data) return jsonify(data)
def update(): """ """ params = request.json data = core.hash_table.update(params=params, my_rank=g.my['rank']) data = set_message(data) return jsonify(data)
def remove(): """ This method removes an hash map""" _id = request.args.get("_id", None) data = core.hash_table.remove(_id=_id) data = set_message(data) return jsonify(data)
def overview(): """ List all the documents, each has a name that identifies it, and an hash map. """ data = core.hash_table.get_list() data = set_message(data) return jsonify(data)
def new(): """ Create a new document within the hash table. """ params = request.json data = core.hash_table.new(params=params) data = set_message(data) return jsonify(data)