fix
authorRadek Czajka <rczajka@rczajka.pl>
Fri, 25 Jun 2021 15:37:18 +0000 (17:37 +0200)
committerRadek Czajka <rczajka@rczajka.pl>
Fri, 25 Jun 2021 15:37:18 +0000 (17:37 +0200)
src/archive/templates/archive/book.html
src/archive/views.py

index 5a7f273..d17190f 100644 (file)
                     –
                   </td>
                   <td>
                     –
                   </td>
                   <td>
-                    <span class="text-secondary" class="edit-youtube-volume" data-audiobook="{{ audiobook.id }}">
-                      {{ audiobook.youtube_volume }}
+                    <span class="text-secondary">
+                      <form method="POST" action="{% url 'book_youtube_volume' audiobook.id %}">
+                        {% csrf_token %}
+                        <input name='volume' value="{{ audiobook.youtube_volume }}" class="form-control">
+                      </form>
                     </span>
                   </td>
                   <td>
                     </span>
                   </td>
                   <td>
+                  </td>                      >
+                  <td class="text-secondary">
+                    {{ audiobook.duration|duration }}
                   </td>
                   <td>
                   </td>
                   </td>
                   <td>
                   </td>
-                  <td>
-                    {{ audiobook.duration }}
-                  </td>
                 {% endifchanged %}
               </tr>
             {% endfor %}
                 {% endifchanged %}
               </tr>
             {% endfor %}
index cafda5d..6ae2ef6 100644 (file)
@@ -302,13 +302,12 @@ class BookView(ListView):
         qs = models.Audiobook.objects.filter(slug=self.kwargs["slug"]).order_by(
             "index"
         )
         qs = models.Audiobook.objects.filter(slug=self.kwargs["slug"]).order_by(
             "index"
         )
-        total = 0
         last_vol = None
         for b in qs:
         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)
 
 
         return list(qs)