(request, post, **kwargs)
return url
Post may be marked as deleted or removed entirely
Post may be marked as deleted or removed entirely
Post may be marked as deleted or removed entirely
def delete_post(request, post, **kwargs):
    """
    Post may be marked as deleted or removed entirely
    """
    user = request.user

    # Decide on the removal
    remove = removal_condition(post, user)

    if remove:
        msg = f"removed post"
        messages.info(request, mark_safe(msg))
        auth.db_logger(user=user, post=post, text=msg)
        post.delete()
        # Deleted children should return root url.
        url = "/" if post.is_toplevel else post.root.get_absolute_url()
    else:
        Post.objects.filter(uid=post.uid).update(status=Post.DELETED)
        post.recompute_scores()
        msg = f"deleted post"
        messages.info(request, mark_safe(msg))
        auth.db_logger(user=user, post=post, text=msg)
        url = post.get_absolute_url()

    # Recompute post score.
    if not post.is_toplevel:
        post.root.recompute_scores()

    return url
def delete_post ( request , post , * * kwargs ) : user = request . user # Decide on the removal remove = removal_condition ( post , user ) if remove : msg = f"removed post" messages . info ( request , mark_safe ( msg ) ) auth . db_logger ( user = user , post = post , text = msg ) post . delete ( ) # Deleted children should return root url. url = "/" if post . is_toplevel else post . root . get_absolute_url ( ) else : Post . objects . filter ( uid = post . uid ) . update ( status = Post . DELETED ) post . recompute_scores ( ) msg = f"deleted post" messages . info ( request , mark_safe ( msg ) ) auth . db_logger ( user = user , post = post , text = msg ) url = post . get_absolute_url ( ) # Recompute post score. if not post . is_toplevel : post . root . recompute_scores ( ) return url