@register.simple_tag
def get_score_badge(user):
+ return _get_score_badge(user)
+
+def _get_score_badge(user):
if user.is_suspended():
return _("(suspended)")
# Usage: {% get_accept_rate node.author %}
@register.simple_tag
def get_accept_rate(user):
+ # If the Show Accept Rate feature is not activated this tag should return a blank string
+ if not settings.SHOW_USER_ACCEPT_RATE:
+ return ""
+
+ # Freeze accept rate for users
+ freeze_accept_rate_for_users_users = settings.FREEZE_ACCEPT_RATE_FOR.value
+ if user.username in list(freeze_accept_rate_for_users_users):
+ freeze = True
+ else:
+ freeze = False
+
# We get the number of all user's answers.
total_answers_count = Answer.objects.filter(author=user).count()
}
# If the user has one accepted answer we'll be using singular.
elif accepted_answers_count == 1:
- accept_rate_number_title = _('%s has one accepted answer') % user.username
+ accept_rate_number_title = _('%s has one accepted answer') % smart_unicode(user.username)
# This are the only options. Otherwise there are no accepted answers at all.
else:
- accept_rate_number_title = _('%s has no accepted answers') % smart_unicode(user.username)
+ if freeze:
+ accept_rate_number_title = ""
+ else:
+ accept_rate_number_title = _('%s has no accepted answers') % smart_unicode(user.username)
html_output = """
<span title="%(accept_rate_title)s" class="accept_rate">%(accept_rate_label)s:</span>
""" % {
'accept_rate_label' : _('accept rate'),
'accept_rate_title' : _('Rate of the user\'s accepted answers'),
- 'accept_rate' : int(accept_rate),
+ 'accept_rate' : 100 if freeze else int(accept_rate),
'accept_rate_number_title' : u'%s' % accept_rate_number_title,
}