Minor view changes.
authorRadek Czajka <rczajka@rczajka.pl>
Mon, 27 Dec 2021 13:10:19 +0000 (14:10 +0100)
committerRadek Czajka <rczajka@rczajka.pl>
Mon, 27 Dec 2021 13:10:19 +0000 (14:10 +0100)
src/archive/models.py
src/archive/templates/archive/book.html
src/archive/templates/archive/list_publishing.html
src/archive/views.py

index aa84ce4..b467a68 100644 (file)
@@ -198,7 +198,7 @@ class Audiobook(models.Model):
         return (
             not self.youtube_volume
             or not type(self)
-            .objects.filter(youtube_volume=self.youtube_volume, index__lt=self.index)
+            .objects.filter(slug=self.slug, youtube_volume=self.youtube_volume, index__lt=self.index)
             .exists()
         )
 
index 9c44a9c..9cb1c80 100644 (file)
                     </form>
                   </td>
                   <td>
-                    {{ audiobook.total|duration }}
+                    {% if audiobook.youtube_volume %}
+                      {{ audiobook.total|duration }}
+                    {% else %}
+                      <small class="text-secondary">{{ audiobook.subtotal|duration }}</small>
+                    {% endif %}
                   </td>
                   <td>
                     {{ audiobook.duration|duration }}
@@ -72,6 +76,7 @@
                     </span>
                   </td>
                   <td>
+                    <small class="text-secondary">{{ audiobook.subtotal|duration }}</small>
                   </td>
                   <td class="text-secondary">
                     {{ audiobook.duration|duration }}
index ad13504..2a8512d 100644 (file)
     <table class="table">
       {% for file in objects %}
         <tr>
-          <td><a href='{% url "file" file.id %}'>{{ file }}</a></td>
+          <td>
+            <a href='{% url "file" file.id %}'>
+              {{ file }}
+              {% if file.youtube_status == k.0 and file.youtube_volume %}
+                <br>
+                <small>
+                  ({{ file.youtube_volume_index }}/{{ file.youtube_volume_count }})
+                  {{ file.youtube_volume }}
+                </small>
+              {% endif %}
+            </a>
+          </td>
           <td class="text-warning">
             {% if file.mp3_status == k.0 %}MP3{% endif %}
           </td>
index 87eee5b..0b5a5ac 100644 (file)
@@ -292,11 +292,17 @@ class BookView(ListView):
             "index"
         )
         last_vol = None
+        last_vol_sub = None
         for b in qs:
-            if last_vol is None or last_vol.youtube_volume != b.youtube_volume:
+            if last_vol is None or last_vol.youtube_volume_index != b.youtube_volume_index:
                 last_vol = b
                 b.total = 0
+                if last_vol_sub is None or b.youtube_volume:
+                    last_vol_sub = last_vol
+                    last_vol_sub.total_for_sub = 0
             last_vol.total += b.duration
+            last_vol_sub.total_for_sub += b.duration
+            b.subtotal = last_vol_sub.total_for_sub
         return list(qs)