(request, post, **kwargs)
return url
Marks post as off topic. Generate off topic comment.
Marks post as off topic. Generate off topic comment.
Marks post as off topic . Generate off topic comment .
def off_topic(request, post, **kwargs):
    """
    Marks post as off topic. Generate off topic comment.
    """
    user = request.user
    if "offtopic" not in post.tag_val:
        post.tag_val += ",offtopic "
        post.save()

        # Generate off comment.
        template = 'messages/offtopic.md'
        tmpl = loader.get_template(template)
        context = dict(post=post)
        content = tmpl.render(context)

        auth.create_post(ptype=Post.COMMENT, parent=post, content=content, title='', author=request.user, request=request)
        msg = "off topic"
        messages.info(request, mark_safe(msg))
        auth.db_logger(user=user, text=f"{msg}", post=post)
    else:
        messages.warning(request, "post has been already tagged as off topic")

    url = post.get_absolute_url()
    return url
def off_topic ( request , post , * * kwargs ) : user = request . user if "offtopic" not in post . tag_val : post . tag_val += ",offtopic " post . save ( ) # Generate off comment. template = 'messages/offtopic.md' tmpl = loader . get_template ( template ) context = dict ( post = post ) content = tmpl . render ( context ) auth . create_post ( ptype = Post . COMMENT , parent = post , content = content , title = '' , author = request . user , request = request ) msg = "off topic" messages . info ( request , mark_safe ( msg ) ) auth . db_logger ( user = user , text = f"{msg}" , post = post ) else : messages . warning ( request , "post has been already tagged as off topic" ) url = post . get_absolute_url ( ) return url