2009-10-23 03:43:38 +04:00
|
|
|
import jinja2
|
|
|
|
|
2010-03-04 03:43:42 +03:00
|
|
|
import jingo
|
2010-04-14 09:15:16 +04:00
|
|
|
from tower import ugettext as _
|
2009-10-23 03:43:38 +04:00
|
|
|
|
|
|
|
|
2010-03-04 03:43:42 +03:00
|
|
|
@jingo.register.filter
|
2009-10-23 03:43:38 +04:00
|
|
|
def stars(num):
|
2010-06-16 19:49:26 +04:00
|
|
|
# check for 0.0 incase None was cast to a float. Should
|
|
|
|
# be safe since lowest rating you can give is 1.0
|
|
|
|
if num is None or num == 0.0:
|
2009-10-23 03:43:38 +04:00
|
|
|
return _('Not yet rated')
|
|
|
|
else:
|
2010-06-25 22:22:06 +04:00
|
|
|
num = min(5, int(round(num)))
|
2010-05-14 08:23:53 +04:00
|
|
|
rating = '<span itemprop="rating">%s</span>' % num
|
|
|
|
title = _('Rated %s out of 5 stars') % num
|
|
|
|
msg = _('Rated %s out of 5 stars') % rating
|
|
|
|
s = (u'<span class="stars stars-{num}" title="{title}">{msg}</span>'
|
|
|
|
.format(num=num, title=title, msg=msg))
|
2009-10-23 03:43:38 +04:00
|
|
|
return jinja2.Markup(s)
|
2010-02-12 21:07:48 +03:00
|
|
|
|
|
|
|
|
2010-03-04 03:43:42 +03:00
|
|
|
@jingo.register.filter
|
2010-02-12 21:07:48 +03:00
|
|
|
def reviews_link(addon, collection_uuid=None):
|
2010-03-04 03:43:42 +03:00
|
|
|
t = jingo.env.get_template('reviews/reviews_link.html')
|
|
|
|
return jinja2.Markup(t.render(addon=addon,
|
|
|
|
collection_uuid=collection_uuid))
|
2010-07-13 02:57:39 +04:00
|
|
|
|
|
|
|
|
|
|
|
@jingo.register.inclusion_tag('reviews/report_review.html')
|
|
|
|
@jinja2.contextfunction
|
|
|
|
def report_review_popup(context):
|
|
|
|
return context
|