예제 #1
0
파일: topic.py 프로젝트: zhuowp-fork/Icarus
def check_remove_content_for_select(ability, user, action, record: DataRecord,
                                    available_columns: list):
    if record.get('visible') == POST_VISIBLE.CONTENT_IF_LOGIN:
        if not user:
            available_columns.remove('content')
    elif record.get('visible') == POST_VISIBLE.ADMIN_ONLY:
        pass
    return True
예제 #2
0
def check_is_me(ability, user, action, record: DataRecord,
                available_columns: list):
    # 拒绝其他人写入自己的个人资料
    if user:
        if record.get('id') != user.id:
            available_columns.clear()
    return True
예제 #3
0
파일: user.py 프로젝트: feitianyiren/Icarus
def check_is_admin(ability, user, action, record: DataRecord, available_columns: list):
    # 阻止superuser写入superuser或更高权限用户组
    if user:
        if record.get('group') in (USER_GROUP.SUPERUSER, USER_GROUP.ADMIN):
            # 只允许写这两列
            available_columns[:] = filter(lambda x: x in {'credit', 'repute'}, available_columns)
    return True
예제 #4
0
def check_is_users_post(ability, user, action, record: DataRecord, available_columns: list):
    if user:
        if record.get('user_id') != user.id:
            available_columns.clear()
    return True
예제 #5
0
def check_remove_content_for_select(ability, user, action, record: DataRecord, available_columns: list):
    if user:
        if record.get('state') == POST_VISIBLE.CONTENT_IF_LOGIN:
            available_columns.remove('content')
    return True
예제 #6
0
파일: topic.py 프로젝트: zhuowp-fork/Icarus
def check_is_users_post(ability, user, action, record: DataRecord,
                        available_columns: Set):
    if user:
        if record.get('user_id') != get_bytes_from_blob(user.id):
            available_columns.clear()
    return True