(post, user, age=1)
return True
Removal condition for the post.
Removal condition for the post.
Removal condition for the post .
def removal_condition(post, user, age=1):
    """
    Removal condition for the post.
    """

    # Only authors may remove their own posts
    if post.author != user:
        return False

    # Post older than a day may not be removed
    if post.age_in_days > age:
        return False

    # If the post has children it may not be removed
    if Post.objects.filter(parent=post).exclude(pk=post.id):
        return False

    # If the post has votes it may not be removed
    if post.vote_count:
        return False

    return True
def removal_condition ( post , user , age = 1 ) : # Only authors may remove their own posts if post . author != user : return False # Post older than a day may not be removed if post . age_in_days > age : return False # If the post has children it may not be removed if Post . objects . filter ( parent = post ) . exclude ( pk = post . id ) : return False # If the post has votes it may not be removed if post . vote_count : return False return True