-from forms import CommaStringListWidget
+from forms import CommaStringListWidget, StringListWidget
from django.forms import CheckboxSelectMultiple
from django.forms.widgets import RadioSelect
from base import Setting, SettingSet
from django.forms import CheckboxSelectMultiple
from django.forms.widgets import RadioSelect
from base import Setting, SettingSet
help_text = _("If you check this the user accept rate will be displayed on the user posts."),
required=False))
help_text = _("If you check this the user accept rate will be displayed on the user posts."),
required=False))
+FREEZE_ACCEPT_RATE_FOR = Setting('FREEZE_ACCEPT_RATE_FOR',
+["admin",],
+USERS_SET, dict(
+label = _("Freeze accept rate"),
+help_text = _("Freeze answers accept rate for the selected users."),
+widget=StringListWidget))
+
TRUNCATE_USERNAMES_LONGER_THAN = Setting('TRUNCATE_USERNAMES_LONGER_THAN', 15, USERS_SET, dict(
label = _("Truncate usernames longer than"),
help_text = _("The usernames that are longer than this will be truncated and ... will be appended.")))
TRUNCATE_USERNAMES_LONGER_THAN = Setting('TRUNCATE_USERNAMES_LONGER_THAN', 15, USERS_SET, dict(
label = _("Truncate usernames longer than"),
help_text = _("The usernames that are longer than this will be truncated and ... will be appended.")))
if not settings.SHOW_USER_ACCEPT_RATE:
return ""
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()
# We get the number of all user's answers.
total_answers_count = Answer.objects.filter(author=user).count()
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 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>
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_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,
}
'accept_rate_number_title' : u'%s' % accept_rate_number_title,
}