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
评论列表
文章目录