From ba1734bdc35bfac91d5692389f2d5600e9341370 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Fri, 25 Jun 2021 17:37:18 +0200 Subject: [PATCH] fix --- src/archive/templates/archive/book.html | 13 ++++++++----- src/archive/views.py | 9 ++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/archive/templates/archive/book.html b/src/archive/templates/archive/book.html index 5a7f273..d17190f 100644 --- a/src/archive/templates/archive/book.html +++ b/src/archive/templates/archive/book.html @@ -64,17 +64,20 @@ – - - {{ audiobook.youtube_volume }} + +
+ {% csrf_token %} + +
+ > + + {{ audiobook.duration|duration }} - - {{ audiobook.duration }} - {% endifchanged %} {% endfor %} diff --git a/src/archive/views.py b/src/archive/views.py index cafda5d..6ae2ef6 100644 --- a/src/archive/views.py +++ b/src/archive/views.py @@ -302,13 +302,12 @@ class BookView(ListView): qs = models.Audiobook.objects.filter(slug=self.kwargs["slug"]).order_by( "index" ) - total = 0 last_vol = None for b in qs: - if last_vol != b.youtube_volume: - last_vol = b.youtube_volume - total = 0 - total = b.total = total + b.duration + if last_vol is None or last_vol.youtube_volume != b.youtube_volume: + last_vol = b + b.total = 0 + last_vol.total += b.duration return list(qs) -- 2.20.1