X-Git-Url: https://git.mdrn.pl/audio.git/blobdiff_plain/5715ba5816c2773949689461f715a08caa8c5d11..d5f57479d0929fe75aee4203ec875d1510f2e4c0:/src/archive/views.py?ds=inline diff --git a/src/archive/views.py b/src/archive/views.py index cafda5d..1d4341e 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) @@ -322,7 +321,7 @@ def book_youtube_volume(request, aid): audiobook.youtube_volume = new_vol audiobook.save() - for a in models.Audiobook.objects.filter(youtube_volume=cur_vol, index__gt=audiobook.index).order_by('index'): + for a in models.Audiobook.objects.filter(slug=slug, youtube_volume=cur_vol, index__gt=audiobook.index).order_by('index'): if a.youtube_volume != cur_vol: break a.youtube_volume = new_vol