First time here? Check out the FAQ!
1

Check if someone have a particular badge

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 %}
squallirvine's avatar
1
squallirvine
asked 2013-07-03 12:58:38 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

0

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.

Evgeny's avatar
13.2k
Evgeny
answered 2013-07-03 13:02:45 -0500, updated 2013-07-03 13:04:54 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments