def add_graph_to_group(request, group_id, graph_id): if graph_id is not None: graph = db.get_graph_by_id(request.db_session, graph_id) else: raise Exception("Required Parameter is missing!") if graph is not None: return db.add_graph_to_group(request.db_session, group_id=group_id, graph_id=graph.id) else: raise Exception("Graph does not exit.")
def is_user_authorized_to_delete_graph(request, username, graph_id): is_authorized = False graph = db.get_graph_by_id(request.db_session, graph_id) if graph is not None: # Graph exists if graph.owner_email == username: is_authorized = True return is_authorized
def update_graph_with_html_legend(request, graph_id, param): graph = db.get_graph_by_id(request.db_session, graph_id) style_json = json.loads(graph.style_json) graph_json = json.loads(graph.graph_json) updated_style_json = convert_html_legend(graph_json=graph_json, style_json=style_json, param=param) del graph_json["data"]["description"] return update_graph(request, graph_id=graph_id, style_json=updated_style_json, graph_json=graph_json)
def is_user_authorized_to_update_graph(request, username, graph_id): is_authorized = False user = users.controllers.get_user(request, username) graph = db.get_graph_by_id(request.db_session, graph_id) if graph is not None: # Graph exists if graph.owner_email == username: is_authorized = True elif user is not None and user.is_admin == 1: is_authorized = True return is_authorized
def is_user_authorized_to_view_graph(request, username, graph_id): is_authorized = False graph = db.get_graph_by_id(request.db_session, graph_id) if graph is not None: # Graph doesnt exists if graph.owner_email == username: is_authorized = True elif graph.is_public == 1: # graph is public is_authorized = True else: # graph is not public for group in graph.groups: if users.controllers.is_member_of_group(request, username, group.id): is_authorized = True return is_authorized
def get_graph_by_id(request, graph_id): return db.get_graph_by_id(request.db_session, graph_id)