<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
<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>
-{% 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
from django import template
+from django.utils.safestring import mark_safe
import logging
register = template.Library()
@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
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()
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">●</span>'
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,
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