# HG changeset patch # User Brian Neal # Date 1344043858 18000 # Node ID 838eb32383a9c10ceb6b76b866eb8d80ab20d15e # Parent 678a1a2ef55a06ee3238378db8264cdfa07bfcb1 Show member flags on forum index page. diff -r 678a1a2ef55a -r 838eb32383a9 bio/templatetags/bio_tags.py --- a/bio/templatetags/bio_tags.py Sat Jul 28 15:12:09 2012 -0500 +++ b/bio/templatetags/bio_tags.py Fri Aug 03 20:30:58 2012 -0500 @@ -4,6 +4,7 @@ from django import template from django.conf import settings from django.core.cache import cache +from django.db.models import Count import bio.flags import bio.models @@ -115,3 +116,19 @@ 'size': size, 'STATIC_URL': settings.STATIC_URL, } + + +@register.inclusion_tag('bio/member_flags_tag.html') +def member_flags(): + """Displays a list of member flags.""" + + flag_data = UserProfile.objects.exclude(country='').values('country').\ + annotate(count=Count('country')).order_by('country') + + for rec in flag_data: + rec['name'] = bio.flags.FLAG_DATA[rec['country']] + + return { + 'flag_data': flag_data, + 'STATIC_URL': settings.STATIC_URL, + } diff -r 678a1a2ef55a -r 838eb32383a9 sg101/templates/accounts/user_stats_tag.html --- a/sg101/templates/accounts/user_stats_tag.html Sat Jul 28 15:12:09 2012 -0500 +++ b/sg101/templates/accounts/user_stats_tag.html Fri Aug 03 20:30:58 2012 -0500 @@ -1,10 +1,12 @@ {% load url from future %} {% load bio_tags %} +{% load cache %} {% load humanize %}
{% if num_users %} -Our site has {{ num_users|intcomma }} members. +Our site has {{ num_users|intcomma }} members from around the world: {% endif %} +{% cache 360 member_flags_tag %}{% member_flags %}{% endcache %} {% if new_users %} Please welcome our newest members: