Ask Your Question

Check if someone have a particular badge

asked 2013-07-03 12:58:38 -0500

squallirvine's avatar


I created a badge moderator and I want to check if the user have this badge to allow him to delete some posts.

For example, in the file askbot/templates/question/question_controls.html

I want to put that :

{% if <check if the logged user have the badge moderator (id = 34)> %}
<a id="post-{{}}-delete" class="question-delete">
{% trans %}delete{% endtrans%}
{% endif %}
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-07-03 13:02:45 -0500

Evgeny's avatar

updated 2013-07-03 13:04:54 -0500

The issue is that badges are rewards not a record of permission. It will be better if you assign "moderator" status to that user via the user profile --> moderation page.

Secondly - it is not a great idea to add checks like this if user.is_X() in the templates, because this makes it more difficult to cache the template fragments. We want to share the cached template fragments with all users.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2013-07-03 12:58:38 -0500

Seen: 128 times

Last updated: Jul 03 '13