Ask Your Question
1

Check if someone have a particular badge

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

squallirvine gravatar image

Hi,

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-{{question.id}}-delete" class="question-delete">
{% trans %}delete{% endtrans%}
</a>
{% endif %}
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

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

Evgeny gravatar image

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

Stats

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

Seen: 57 times

Last updated: Jul 03 '13