@permission_required('users.add_userban')
def ban_user_and_cleanup(request, username):
 user = get_object_or_404(User, username=username)
 user_ban = UserBan.objects.filter(user=user, is_active=True)
 date_three_days_ago = (datetime.now().date() - timedelta(days=3))
 revisions = user.created_revisions.prefetch_related('document')
 revisions = revisions.defer('content', 'summary').order_by('-id')
 revisions = revisions.filter(created__gte=date_three_days_ago)
 revisions_not_spam = revisions.filter(akismet_submissions=None)
 return render(request, 'users/ban_user_and_cleanup.html', {'detail_user': user, 'user_banned': user_ban, 'revisions': revisions, 'revisions_not_spam': revisions_not_spam, 'on_ban_page': True})

@ permission_required ( 'users.add_userban' ) def ban_user_and_cleanup ( request , username ) : user = get_object_or_404 ( User , username = username ) user_ban = UserBan . objects . filter ( user = user , is_active = True ) date_three_days_ago = ( datetime . now ( ) . date ( ) - timedelta ( days = 3 ) ) revisions = user . created_revisions . prefetch_related ( 'document' ) revisions = revisions . defer ( 'content' , 'summary' ) . order_by ( '-id' ) revisions = revisions . filter ( created__gte = date_three_days_ago ) revisions_not_spam = revisions . filter ( akismet_submissions = None ) return render ( request , 'users/ban_user_and_cleanup.html' , { 'detail_user' : user , 'user_banned' : user_ban , 'revisions' : revisions , 'revisions_not_spam' : revisions_not_spam , 'on_ban_page' : True } )
a page to ban a user for the reason of "spam" and mark the users revisions and page creations as spam .