def submit_info(projectname, appname, applabel, module): if not session.get("uid"): return json_response_error(AUTH_ERROR) uid = session.get("uid") required_list = ("items",) data = check_required_params(request, required_list) # view logic return checklist_create(appname, projectname, applabel, module, uid, data["items"])
def login(appname): required_list = ("user_name", "password") data = check_required_params(request, required_list) if isinstance(data, Response): return data # view logic return user_login( appname, data['user_name'], data['password'], session)
def check_info(appname, projectname, applabel, module, id): if not session.get("uid"): return json_response_error(AUTH_ERROR) uid = session.get("uid") required_list = ("checked", "mark") data = check_required_params(request, required_list) data["uid"] = uid return check_content(appname, projectname, applabel, module, id, data)
def add_app(appname, projectname): required_list = ('name', "app_value", "order") data = check_required_params(request, required_list) if isinstance(data, Response): return data # view logic return app_create( appname, projectname, data['name'], data["app_value"], data["order"])
def del_right(appname): if not session.get('uid'): return json_response_error(AUTH_ERROR) required_list = ('pids', ) data = check_required_params(request, required_list) if isinstance(data, Response): return data # view logic return right_delete(appname, data['pids'])
def add_group(appname): if not session.get('uid'): return json_response_error(AUTH_ERROR) required_list = ("rolename", ) data = check_required_params(request, required_list) if isinstance(data, Response): return data # view logic return group_create(appname, data['rolename'])
def auth_right(appname): if not session.get('uid'): return json_response_error(AUTH_ERROR) required_list = ('perm_module', 'perm_opname', 'perm_action') data = check_required_params(request, required_list) if isinstance(data, Response): return data perm_lc = request.form.get('perm_lc', "all") return check_session( appname, data["perm_module"], data["perm_opname"], data["perm_action"], perm_lc, session["uid"])
def add_user(appname): if not session.get('uid'): return json_response_error(AUTH_ERROR) required_list = ("user_name", "group_id") data = check_required_params(request, required_list) if isinstance(data, Response): return data add_data = ArmoryJson.decode(request.data) data["mark"] = add_data.get("mark", "") # view logic return user_create(appname, data)
def chpasswd_user(appname): if not session.get('uid'): _LOGGER.error('cant find uid in session') return json_response_error(AUTH_ERROR) required_list = ("current_password", "new_password") data = check_required_params(request, required_list) if isinstance(data, Response): return data return user_chpasswd( appname, session.get('uid'), data['current_password'], data['new_password'])
def right_info(appname, id): if request.method == 'GET': # this method get group right info by gid return right_get(appname, int(id)) elif request.method == 'POST': # this method mod group right info data = check_required_params(request, Right.params) if isinstance(data, Response): return data return right_mod(appname, int(id), data) else: return json_response_error(METHOD_ERROR)
def user_edit(appname, id): if request.method == 'GET': # this method get user info by uid return user_get(appname, int(id)) elif request.method == 'POST': # this method mod user info data = check_required_params(request, User.params) if isinstance(data, Response): return data return user_mod(appname, int(id), data) else: return json_response_error(METHOD_ERROR)
def user_right_info(appname, projectname, id): if request.method == 'GET': # this method get right info by gid return user_right_get(appname, projectname, int(id)) elif request.method == 'POST': # this method mod user right info required_list = ("perm_list", "disable_list") data = check_required_params(request, required_list) if isinstance(data, Response): return data return user_right_mod(appname, projectname, int(id), data) else: return json_response_error(METHOD_ERROR)
def add_right(appname, projectname): required_list = ('perm_module', 'perm_opname', 'perm_action', "perm_type") data = check_required_params(request, required_list) if isinstance(data, Response): return data action_value = ['list', 'add', 'edit', 'delete'] if data["perm_type"] == "module" and \ data["perm_action"] not in action_value: return json_response_error(PARAM_ERROR) perm_lc = request.form.get('perm_lc', "all") # view logic return right_create( appname, projectname, data["perm_module"], data["perm_opname"], data["perm_action"], data["perm_type"], perm_lc)
def active_user(appname): required_list = ('id', 'is_active') data = check_required_params(request, required_list) if isinstance(data, Response): return data return user_active(appname, data)
def list_navigate(appname): required_list = ('uid', ) data = check_required_params(request, required_list) if isinstance(data, Response): return data return navigate_list(appname, data["uid"])
def list_menu(appname, projectname): required_list = ('uid', ) data = check_required_params(request, required_list) if isinstance(data, Response): return data return menu_list(appname, projectname, data["uid"])