~widelands-dev/widelands-website/update_beautifulsoup4

« back to all changes in this revision

Viewing changes to wlmaps/templatetags/wlmaps_extra.py

  • Committer: Shevonar
  • Date: 2012-04-24 21:14:22 UTC
  • mto: This revision was merged to the branch mainline in revision 330.
  • Revision ID: infomh@anmaruco.de-20120424211422-d80y5yd8x9q9gzpx
Maps modul reworked and adjusted to new style.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python -tt
 
2
# encoding: utf-8
 
3
 
 
4
from django import template
 
5
 
 
6
register = template.Library()
 
7
 
 
8
@register.filter
 
9
def average_rating(rating):
 
10
    if rating.votes > 0:
 
11
        avg = "%.1f" %( float(rating.score) / rating.votes )
 
12
    else:
 
13
        avg = "0.0"
 
14
    return avg