(sender, instance, created, **kwargs)
Delete all posts and awards belonging to a banned user.
Delete all posts and awards belonging to a banned user.
Delete all posts and awards belonging to a banned user .
def ban_user(sender, instance, created, **kwargs):
    """
    Delete all posts and awards belonging to a banned user.
    """

    if instance.state == Profile.BANNED:
        # Delete all posts by this users
        #print(Post.objects.filter(author=instance.user).thread_users)
        Post.objects.filter(author=instance.user).delete()
        #print(Post.objects.filter(author=instance))
        # Remove all 'lastedit user' flags for this user.
        # posts = Post.objects.filter(lastedit_user=instance.user)
        # for post in posts:
        #     Post.objects.filter(id=post.id).update(lastedit_user=post.author)

        # Delete all awards by the user.
        Award.objects.filter(user=instance.user).delete()

        Subscription.objects.filter(user=instance.user).delete()
        # Take out any personal information user added.
        #Profile.objects.filter(uid=instance.uid).update(text='')

        # Delete all messages
        Message.objects.filter(Q(sender=instance.user) | Q(recipient=instance.user)).delete()

    # Label all posts by a spammer as 'spam'
    if instance.is_spammer:
        Post.objects.filter(author=instance.user).update(spam=Post.SPAM)
def ban_user ( sender , instance , created , * * kwargs ) : if instance . state == Profile . BANNED : # Delete all posts by this users #print(Post.objects.filter(author=instance.user).thread_users) Post . objects . filter ( author = instance . user ) . delete ( ) #print(Post.objects.filter(author=instance)) # Remove all 'lastedit user' flags for this user. # posts = Post.objects.filter(lastedit_user=instance.user) # for post in posts: #     Post.objects.filter(id=post.id).update(lastedit_user=post.author) # Delete all awards by the user. Award . objects . filter ( user = instance . user ) . delete ( ) Subscription . objects . filter ( user = instance . user ) . delete ( ) # Take out any personal information user added. #Profile.objects.filter(uid=instance.uid).update(text='') # Delete all messages Message . objects . filter ( Q ( sender = instance . user ) | Q ( recipient = instance . user ) ) . delete ( ) # Label all posts by a spammer as 'spam' if instance . is_spammer : Post . objects . filter ( author = instance . user ) . update ( spam = Post . SPAM )