Example #1
0
def right_mod(appname, rid, data):
    '''
        this api is used to modify one right
        Request URL: /auth/user/{uid}
        HTTP Method:POST
        Parameters:
            {
            "group_name":"xxx",
            "perm_list":[1,2,3,4]
            }
        Return :
        {
        "status":0
        "data":{}
        "msg":"modify successfully"
        }
        '''
    cond = {"_id": rid}
    if not App.find_one_app(appname, {"name": data["app_label"]}):
        return json_response_error(PARAM_ERROR, msg="the app label not exist")
    if not Module.find_one_module(appname, {"module_name": data["module"]}):
        return json_response_error(PARAM_ERROR, msg="the app module not exist")
    perm_name = '%s-%s-%s' % (
        data["app_label"], data["module"], data["action"])
    data["perm_name"] = perm_name
    Right.update_right(appname, cond, data)
    return json_response_ok()