admin.py 文件源码

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

项目:dappr 作者: millanp 项目源码 文件源码
def selection_valid(modeladmin, request, queryset):
    """
    Verify that the selected registration profiles are ready for action

    Args:
        modeladmin: the current admin interface
        request: request object sent with admin action
        queryset: queryset of objects selected
    Returns:
        boolean, indicating whether selection is valid
    """
    # Check whether selection contains profiles of people whose identity has not been confirmed.
    if queryset.filter(identity_confirmed=False).exists():
        modeladmin.message_user(request, 
                                "One or more users have not confirmed their identity", 
                                level=messages.ERROR)
        return False
    # Check whether selection contains inactive (dealt with) registration profiles
    if queryset.filter(active=False).exists():
        modeladmin.message_user(request,
                                "One or more registration profiles are inactive (already dealt with)",
                                level=messages.ERROR)
        return False
    return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号