From 53f93a7bb9da88c32153371c7d4426fe261fd530 Mon Sep 17 00:00:00 2001 From: simon Date: Wed, 15 Dec 2021 17:39:52 +0700 Subject: [PATCH] fix missing average_rating due to lack of dislikes --- tubearchivist/home/templates/home/video.html | 4 +++- tubearchivist/home/views.py | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/tubearchivist/home/templates/home/video.html b/tubearchivist/home/templates/home/video.html index 12896fd..b1b2222 100644 --- a/tubearchivist/home/templates/home/video.html +++ b/tubearchivist/home/templates/home/video.html @@ -55,7 +55,9 @@

Views: {{ video.stats.view_count|intcomma }}

-

thumbs-down: {{ video.stats.dislike_count|intcomma }}

+ {% if video.stats.dislike_count %} +

thumbs-down: {{ video.stats.dislike_count|intcomma }}

+ {% endif %} {% if video.stats.average_rating %}

Rating: {% for star in video.stats.average_rating %} diff --git a/tubearchivist/home/views.py b/tubearchivist/home/views.py index 7248bbb..340f69d 100644 --- a/tubearchivist/home/views.py +++ b/tubearchivist/home/views.py @@ -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: