]> git.openstreetmap.org Git - osqa.git/commitdiff
Handle big reputation numbers slightly better.
authorhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Fri, 8 Oct 2010 01:13:51 +0000 (01:13 +0000)
committerhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Fri, 8 Oct 2010 01:13:51 +0000 (01:13 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@603 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum/skins/default/templates/question_list/item.html
forum/skins/default/templates/question_summary_list_roll.html
forum/skins/default/templates/users/signature.html
forum/templatetags/extra_filters.py
forum/templatetags/extra_tags.py
forum_modules/exporter/forms.py

index 19cbb36fd860a7f1471d05ab1e7284aa7fdcb77e..b28cdf49d0670a29c1417c6d9fa7feb116b29e8e 100644 (file)
@@ -15,7 +15,7 @@
             <div>{% ifequal question.answer_count 1 %}{% trans "answer" %}{% else %}{% trans "answers" %}{% endifequal %}</div>\r
         </div>\r
         <div class="views">\r
-             <div class="item-count">{{question.view_count|cnprog_intword|safe}}</div>\r
+             <div class="item-count">{{question.view_count|decorated_int|safe}}</div>\r
              <div>{% ifequal question.view_count 1 %}{% trans "view" %}{% else %}{% trans "views" %}{% endifequal %}</div>\r
         </div>\r
     </div>\r
index 769aa206fd25c8fbd3c83f9b42a98c13f435c22a..f80cef7848263df59f464a54bc42f2133e6c24bf 100644 (file)
@@ -7,7 +7,7 @@
                 <tr>
                     <td><span class="num">{{ question.answer_count|intcomma }}</span> </td>
                     <td><span class="num">{{ question.score|intcomma }}</span> </td>
-                    <td><span class="num">{{ question.view_count|cnprog_intword|safe }}</span> </td>
+                    <td><span class="num">{{ question.view_count|decorated_int|safe }}</span> </td>
                 </tr>  
                 <tr>
                     <td><span class="unit">{% trans "answers" %}</span></td>
index 9805429aa52d86d88f4496aae35e493bb590a772..e8aebf3519d3223f761217a86af621f374c91eca 100644 (file)
@@ -1,11 +1,11 @@
-{% load i18n %}{% spaceless %}\r
+{% load i18n extra_filters %}{% spaceless %}\r
 \r
 {% if not user.is_suspended %}\r
     {% ifequal format "full" %}\r
 \r
     {% else %}\r
         <a href="{{ user.get_absolute_url }}">{{ user.decorated_name }}</a>\r
-        <span class="score" title="{{ user.reputation }} {% trans "reputation" %}">{{ user.reputation }}</span>\r
+        <span class="score" title="{{ user.reputation }} {% trans "reputation" %}">{{ user.reputation|decorated_int:"" }}</span>\r
         {% ifequal format "badges" %}\r
             {% if user.gold %}\r
             <span title="{{ user.gold }} {% trans "badges" %}">\r
index df1c24dafd7aec22f92d3a9d7e3d917658df3522..590f5550012cfd23bddb48773b9d7e6552d9da00 100644 (file)
@@ -1,4 +1,5 @@
 from django import template
+from django.utils.safestring import mark_safe
 import logging
 
 register = template.Library()
@@ -15,13 +16,17 @@ def can_edit_post(user, post):
 
 
 @register.filter
-def cnprog_intword(number):
+def decorated_int(number, cls="thousand"):
     try:
-        if 1000 <= number < 10000:
-            string = str(number)[0:1]
-            return "<span class=""thousand"">%sk</span>" % string
-        else:
-            return number
+        if number > 999:
+            if number > 9999:
+                s = str(number)[:-3]
+            else:
+                s = str(number)
+                s = "%s.%s" % (s[0], s[1])
+
+            return mark_safe("<span class=\"%s\">%sk</span>" % (cls, s))
+        return number
     except:
         return number
 
index 560239265e635eeeda7e68e98ac7119eb9b4e6da..3e0cf4c9f0d3f5c238cd1a942ef167930da4ce04 100644 (file)
@@ -16,6 +16,7 @@ from forum import settings
 from django.template.defaulttags import url as default_url
 from forum import skins
 from forum.utils import html
+from extra_filters import decorated_int
 from django.core.urlresolvers import reverse
 
 register = template.Library()
@@ -47,7 +48,9 @@ def get_score_badge(user):
     if user.is_suspended():
         return _("(suspended)")
 
-    BADGE_TEMPLATE = '<span class="score" title="%(reputation)s %(reputationword)s">%(reputation)s</span>'
+    repstr = decorated_int(user.reputation, "")
+
+    BADGE_TEMPLATE = '<span class="score" title="%(reputation)s %(reputationword)s">%(repstr)s</span>'
     if user.gold > 0 :
         BADGE_TEMPLATE = '%s%s' % (BADGE_TEMPLATE, '<span title="%(gold)s %(badgesword)s">'
         '<span class="badge1">&#9679;</span>'
@@ -66,6 +69,7 @@ def get_score_badge(user):
     BADGE_TEMPLATE = smart_unicode(BADGE_TEMPLATE, encoding='utf-8', strings_only=False, errors='strict')
     return mark_safe(BADGE_TEMPLATE % {
     'reputation' : user.reputation,
+    'repstr': repstr,
     'gold' : user.gold,
     'silver' : user.silver,
     'bronze' : user.bronze,
index 94ce8004aa3dfedae60f09ad1b257b05405b743f..5e4adecd2a35d7fe5c57617eae1f7d62c2241d4e 100644 (file)
@@ -2,5 +2,5 @@ from django import forms
 from django.utils.translation import ugettext as _
 
 class ExporterForm(forms.Form):
-    anon_data = forms.BooleanField(label=_('Anonimyzed data'), help_text=_('Don\'t export user data and make all content anonymous'), required=False)
+    anon_data = forms.BooleanField(label=_('Anonymized data'), help_text=_('Don\'t export user data and make all content anonymous'), required=False)
     
\ No newline at end of file