fix missing average_rating due to lack of dislikes

This commit is contained in:
simon 2021-12-15 17:39:52 +07:00
parent 7924f28ccb
commit 53f93a7bb9
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
2 changed files with 6 additions and 1 deletions

View File

@ -55,7 +55,9 @@
<div>
<p>Views: {{ video.stats.view_count|intcomma }}</p>
<p class="thumb-icon like"><img src="{% static 'img/icon-thumb.svg' %}" alt="thumbs-up">: {{ video.stats.like_count|intcomma }}</p>
{% if video.stats.dislike_count %}
<p class="thumb-icon dislike"><img src="{% static 'img/icon-thumb.svg' %}" alt="thumbs-down">: {{ video.stats.dislike_count|intcomma }}</p>
{% endif %}
{% if video.stats.average_rating %}
<p class="rating-stars">Rating:
{% for star in video.stats.average_rating %}

View File

@ -875,6 +875,9 @@ class VideoView(View):
@staticmethod
def star_creator(rating):
"""convert rating float to stars"""
if not rating:
return False
stars = []
for _ in range(1, 6):
if rating >= 0.75: