def get_check_uids( appname, projectname, applabel, module, action="checked", perm_lc="all"): # get perm id perm_name = '%s-%s-%s' % (applabel, module, action) right_cond = { 'perm_name': perm_name, 'app_name': projectname, "lc": perm_lc} perm = Right.find_one(appname, right_cond) if not perm: _LOGGER.error("the right:%s not exist" % perm_name) #get user who has this right check_ids = [] perm_id = perm["_id"] perm_key = "permission_list.%s" % projectname group_cond = {perm_key: perm_id} groups_info = Group.find(appname, group_cond) group_ids = [i["_id"] for i in groups_info] for gid in group_ids: group_info = user_info(appname, gid) user_ids = [i["id"] for i in group_info] check_ids += user_ids user_cond = {perm_key: perm_id} users_info = User.find(appname, user_cond) user_ids = [i["_id"] for i in users_info] check_ids += user_ids check_ids = list(set(check_ids)) return check_ids