]> git.openstreetmap.org Git - osqa.git/commitdiff
adding functionality to freeze accept rate to 100% for specific users
authorjordan <jordan@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Thu, 22 Sep 2011 16:13:00 +0000 (16:13 +0000)
committerjordan <jordan@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Thu, 22 Sep 2011 16:13:00 +0000 (16:13 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@1175 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum/settings/users.py
forum/templatetags/extra_tags.py

index 2c2c3acac40743edf8ad8c087096df0cc04eafc6..a108ebf408882ccc4adce5620b48ba9d909bcfa6 100644 (file)
@@ -1,4 +1,4 @@
-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
@@ -43,6 +43,13 @@ label = _("Show user accept rate"),
 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.")))
index e01ff068d3377863add7c536c833ff156dee2516..b8d9f5cad3ce18c49189200856c6b2f5d764c7e7 100644 (file)
@@ -86,6 +86,13 @@ def get_accept_rate(user):
     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()
 
@@ -110,7 +117,10 @@ def get_accept_rate(user):
         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>
@@ -118,7 +128,7 @@ def get_accept_rate(user):
     """ % {
         '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,
     }