Made file based cache the default.
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@157
0cfe37f9-358a-4d5e-be75-
b63607b5c754
return super(BadgeManager, self).get(*args, **kwargs)\r
\r
from forum.badges.base import BadgesMeta\r
return super(BadgeManager, self).get(*args, **kwargs)\r
\r
from forum.badges.base import BadgesMeta\r
- badge = BadgesMeta.by_id.get(pk, None)\r
+ badge = BadgesMeta.by_id.get(int(pk), None)\r
if not badge:\r
return super(BadgeManager, self).get(*args, **kwargs)\r
return badge.ondb\r
if not badge:\r
return super(BadgeManager, self).get(*args, **kwargs)\r
return badge.ondb\r
</p>
<div>
{% if badge.awarded_count %}
</p>
<div>
{% if badge.awarded_count %}
- <p style="float:left"><span class="count">{{ awards|length|intcomma }}</span>
+ <p style="float:left"><span class="count">{{ award_count|intcomma }}</span>
<strong>{% trans "The users have been awarded with badges:" %}</strong></p>
{% endif %}
</div>
<strong>{% trans "The users have been awarded with badges:" %}</strong></p>
{% endif %}
</div>
+from itertools import groupby
from django.shortcuts import render_to_response, get_object_or_404
from django.core.urlresolvers import reverse
from django.template import RequestContext
from django.shortcuts import render_to_response, get_object_or_404
from django.core.urlresolvers import reverse
from django.template import RequestContext
def badge(request, id, slug):
badge = Badge.objects.get(id=id)
def badge(request, id, slug):
badge = Badge.objects.get(id=id)
- awards = Award.objects.filter(badge=badge).annotate(count=Count('user')).distinct('user').order_by('-count')
+ awards = list(Award.objects.filter(badge=badge).order_by('user', 'awarded_at'))
+ award_count = len(awards)
+
+ awards = sorted([dict(count=len(list(g)), user=k) for k, g in groupby(awards, lambda a: a.user)],
+ lambda c1, c2: c2['count'] - c1['count'])
return render_to_response('badge.html', {
return render_to_response('badge.html', {
+ 'award_count': award_count,
'awards' : awards,
'badge' : badge,
}, context_instance=RequestContext(request))
'awards' : awards,
'badge' : badge,
}, context_instance=RequestContext(request))
DATABASE_HOST = ''
DATABASE_PORT = ''
DATABASE_HOST = ''
DATABASE_PORT = ''
-#CACHE_BACKEND = 'file://%s' % os.path.join(os.path.dirname(__file__),'cache').replace('\\','/')
-CACHE_BACKEND = 'dummy://'
+CACHE_BACKEND = 'file://%s' % os.path.join(os.path.dirname(__file__),'cache').replace('\\','/')
+#CACHE_BACKEND = 'dummy://'
SESSION_ENGINE = 'django.contrib.sessions.backends.db'
APP_URL = 'http://' #used by email notif system and RSS
SESSION_ENGINE = 'django.contrib.sessions.backends.db'
APP_URL = 'http://' #used by email notif system and RSS