make sure stars don't go over 5 (bug 574520)
This commit is contained in:
Родитель
c07bf74b93
Коммит
5836e39a9d
|
@ -1,5 +1,3 @@
|
|||
import math
|
||||
|
||||
import jinja2
|
||||
|
||||
import jingo
|
||||
|
@ -13,7 +11,7 @@ def stars(num):
|
|||
if num is None or num == 0.0:
|
||||
return _('Not yet rated')
|
||||
else:
|
||||
num = int(math.ceil(num))
|
||||
num = min(5, int(round(num)))
|
||||
rating = '<span itemprop="rating">%s</span>' % num
|
||||
title = _('Rated %s out of 5 stars') % num
|
||||
msg = _('Rated %s out of 5 stars') % rating
|
||||
|
|
|
@ -26,6 +26,11 @@ def test_stars():
|
|||
eq_(doc.text(), msg)
|
||||
|
||||
|
||||
def test_stars_max():
|
||||
doc = PyQuery(render('{{ num|stars }}', {'num': 5.3}))
|
||||
eq_(doc.attr('class'), 'stars stars-5')
|
||||
|
||||
|
||||
def test_reviews_link():
|
||||
a = Addon(average_rating=4, total_reviews=37, id=1)
|
||||
s = render('{{ myaddon|reviews_link }}', {'myaddon': a})
|
||||
|
|
Загрузка…
Ссылка в новой задаче