Fix KnowledgeBase item score

This commit is contained in:
bbe 2020-06-29 14:38:41 +02:00
parent 630cfd9179
commit d961b2b692
2 changed files with 3 additions and 2 deletions

View File

@ -1031,8 +1031,9 @@ class KBItem(models.Model):
return super(KBItem, self).save(*args, **kwargs) return super(KBItem, self).save(*args, **kwargs)
def _score(self): def _score(self):
""" Return a score out of 10 or Unrated if no votes """
if self.votes > 0: if self.votes > 0:
return int(self.recommendations / self.votes) return (self.recommendations / self.votes) * 10
else: else:
return _('Unrated') return _('Unrated')
score = property(_score) score = property(_score)

View File

@ -29,7 +29,7 @@
<ul> <ul>
<li>{% blocktrans with item.recommendations as recommendations %}Recommendations: {{ recommendations }}{% endblocktrans %}</li> <li>{% blocktrans with item.recommendations as recommendations %}Recommendations: {{ recommendations }}{% endblocktrans %}</li>
<li>{% blocktrans with item.votes as votes %}Votes: {{ votes }}{% endblocktrans %}</li> <li>{% blocktrans with item.votes as votes %}Votes: {{ votes }}{% endblocktrans %}</li>
<li>{% blocktrans with item.score as score %}Overall Rating: {{ score }}{% endblocktrans %}</li> <li>{% blocktrans with item.score|floatformat as score %}Overall Rating: {{ score }}{% endblocktrans %}/10</li>
</ul> </ul>
</div> </div>
</div> </div>