def get_user_by_id_action(): """ Get user data by it's id """ token = request.args.get('token') user_id = request.args.get('user_id') validate_token(token) data = User.get_user_by_id(user_id) return response_ok_obj(data)
def save_package(): """ Saves package (create or update) """ data = request.get_json() validate_data(data, {'token'}) validate_token(data['token']) package = Package.save_or_create(data) return response_ok_obj(package)
def get_package_by_id_action(): """ Get packge by id """ token = request.args.get('token') validate_token(token) package_id = request.args.get('package_id') data = Package.get_package_by_id(package_id) return response_ok_obj(data)
def get_project_by_id_action(): """ Get project data by it's id """ token = request.args.get('token') id = request.args.get('id') validate_token(token) #check permissions in the future data = Project.get_project_by_id(id) return response_ok_obj(data)
def get_module_permission_by_id_action(id): """ Get module permission by it's id :param id: """ token = request.args.get('token') validate_token(token) #check permissions in the future data = ModulePerm.get_module_perm_by_id(ModulePerm, id) return response_ok_obj(data)
def get_project_permission_by_project_id_action(id): """ Get project permission by it's projects id :param id: """ token = request.args.get('token') validate_token(token) #check permissions in the future data = ProjectPerm.get_project_perm_all_by_project_id(ProjectPerm, id) return response_ok_obj(data)
def get_module_by_name_action(name): """ Get module data by it's name """ token = request.args.get('token') name = request.args.get('name') validate_token(token) #check permissions in the future data = Module.get_module_by_name(name) return response_ok_obj(data)
def update_user(): """ Update user with suplied data, now works only for email, password, name and user type """ data = request.get_json() validate_data(data, {'token', 'user_id'}) user_id = data['user_id'] token = data['token'] validate_token(token) user = User.update_user_by_id_from_array(user_id, data) return response_ok_obj(user)
def get_module_all_by_project_id_action(id): """ Get data for all modules in project :param id: Project ID """ token = request.args.get('token') id = request.args.get('id') validate_token(token) #check permissions in the future data = Module.get_module_all_by_project_id(id) return response_ok_obj(data)
def get_project_by_name_action(name): """ Get project data by it's name """ token = request.args.get('token') name = request.args.get('name') validate_token(token) #check permissions in the future data = Project.get_project_by_name(name) if (data == None): return response_err(ApiException(400, "Name already in use.")) return response_ok_obj(data)
def update_or_create_module_action(): """ Update or create module """ data = request.get_json() if data == None: raise ApiException(400, "data") if (data['token'] == None): raise ApiException(403, "Invalid token") if (('module_id' not in data) or (data['module_id'] == None)): moduleId = None else: moduleId = data['module_id'] validate_token(data['token']) #check permissions in the future data = Module.create_or_update_module_by_id_from_array(moduleId, data['data']) if (data == None): raise ApiException(400, "Name already in use.") return response_ok_obj(data)
def update_or_create_poject_action(): """ Update or create poject """ data = request.get_json() if data == None: raise ApiException(400, "data") if (data['token'] == None): raise ApiException(403, "Invalid token") if (('poject_id' not in data) or (data['poject_id'] == None)): poject_id = None else: poject_id = data['poject_id'] validate_token(data['token']) #check permissions in the future data = Project.create_or_update_project_by_id_array( poject_id, data['data'], True) if (data == None): raise ApiException(400, "Name already in use.") return response_ok_obj(data)