(request, post, **kwds)
return url
Moves an answer to a comment and viceversa.
Moves an answer to a comment and viceversa.
Moves an answer to a comment and viceversa .
def relocate(request, post, **kwds):
    """
    Moves an answer to a comment and viceversa.
    """
    url = post.get_absolute_url()

    if post.is_toplevel:
        messages.warning(request, "cannot relocate a top level post")
        return url

    if post.type == Post.COMMENT:
        msg = f"relocated comment to answer"
        post.type = Post.ANSWER
    else:
        msg = f"relocated answer to comment"
        post.type = Post.COMMENT

    post.parent = post.root
    post.save()
    post.update_parent_counts()

    auth.db_logger(user=request.user, post=post, text=f"{msg}")
    messages.info(request, msg)
    return url
def relocate ( request , post , * * kwds ) : url = post . get_absolute_url ( ) if post . is_toplevel : messages . warning ( request , "cannot relocate a top level post" ) return url if post . type == Post . COMMENT : msg = f"relocated comment to answer" post . type = Post . ANSWER else : msg = f"relocated answer to comment" post . type = Post . COMMENT post . parent = post . root post . save ( ) post . update_parent_counts ( ) auth . db_logger ( user = request . user , post = post , text = f"{msg}" ) messages . info ( request , msg ) return url