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 %}

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
squallirvine's avatar
1
squallirvine
asked 11 years ago

Comments

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.

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
Evgeny's avatar
13.2k
Evgeny
answered 11 years ago, updated 11 years ago
link

Comments

see more comments