common_helpers.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:State-TalentMAP-API 作者: 18F 项目源码 文件源码
def in_group_or_403(user, group_name):
    '''
    This function mimics the functionality of get_object_or_404, but for permission groups.
    The function accepts a user and group name, doing nothing if the user is present in
    the permission group; otherwise, throws a PermissionDenied error

    Args:
        - user (Object) - The user instance
        - group_name (String) - The name of the permission group
    '''
    try:
        group = get_group_by_name(group_name)
    except:
        raise PermissionDenied
    if group not in user.groups.all():
        raise PermissionDenied
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号