Explorar o código

[templates] Add longplay complete to templates

Colin Powell hai 15 horas
pai
achega
d568a377f0

+ 2 - 4
vrobbler/apps/puzzles/models.py

@@ -11,17 +11,15 @@ from django_extensions.db.models import TimeStampedModel
 from imagekit.models import ImageSpecField
 from imagekit.processors import ResizeToFit
 from puzzles.sources import ipdb
-from scrobbles.dataclasses import JSONDataclass
+from scrobbles.dataclasses import BaseLogData, WithPeopleLogData, LongPlayLogData
 from scrobbles.mixins import ScrobblableConstants, ScrobblableMixin
 
 BNULL = {"blank": True, "null": True}
 
 
 @dataclass
-class PuzzleLogData(JSONDataclass):
-    with_people: Optional[int] = None
+class PuzzleLogData(BaseLogData, WithPeopleLogData, LongPlayLogData):
     rating: Optional[str] = None
-    notes: Optional[str] = None
 
 
 class PuzzleManufacturer(TimeStampedModel):

+ 1 - 1
vrobbler/apps/scrobbles/views.py

@@ -949,7 +949,7 @@ class ScrobbleDetailView(DetailView):
 
         log = self.object.log or {}
         initial_notes = log.get("notes", [])
-        if isinstance(initial_notes, list) and isinstance(initial_notes[0], dict):
+        if isinstance(initial_notes, list) and len(initial_notes) > 0 and isinstance(initial_notes[0], dict):
             notes_str = note_list_to_str(notes)
         else:
             notes_str = "\n".join(initial_notes)

+ 43 - 0
vrobbler/templates/_longplay_scrobblable_list.html

@@ -0,0 +1,43 @@
+{% load urlreplace %}
+{% load naturalduration %}
+
+<table class="table table-striped table-sm">
+    <thead>
+        <tr>
+            <th scope="col">Latest</th>
+            <th scope="col">Title</th>
+            <th scope="col">Scrobbles</th>
+            <th scope="col">Complete</th>
+            <th scope="col">Start</th>
+        </tr>
+    </thead>
+    <tbody>
+        {% for obj in object_list %}
+        {% if obj.title %}
+        <tr>
+            <td><a href="{{obj.scrobble_set.last.get_absolute_url}}">{{obj.scrobble_set.last.local_timestamp}}
+            <td><a href="{{obj.get_absolute_url}}">{{obj}}</a></td>
+            {% if request.user.is_authenticated %}
+            <td>{{obj.scrobble_count}}</td>
+            <td>{% if obj.scrobble_set.last.logdata.long_play_complete == True %}Yes{% endif %}</td>
+            <td><a type="button" class="btn btn-sm btn-primary" href="{{obj.start_url}}">Scrobble</a></td>
+            {% endif %}
+        </tr>
+        {% endif %}
+        {% endfor %}
+    </tbody>
+</table>
+
+<p class="pagination">
+    <span class="page-links">
+        {% if page_obj.has_previous %}
+            <a href="?{% urlreplace page=page_obj.previous_page_number %}">prev</a>
+        {% endif %}
+            <span class="page-current">
+                Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}
+            </span>
+        {% if page_obj.has_next %}
+            <a href="?{% urlreplace page=page_obj.next_page_number %}">next</a>
+        {% endif %}
+    </span>
+</p>

+ 1 - 1
vrobbler/templates/books/book_list.html

@@ -16,7 +16,7 @@
 
     <div class="col-md">
         <div class="table-responsive">
-            {% include "_scrobblable_list.html" %}
+            {% include "_longplay_scrobblable_list.html" %}
         </div>
     </div>
 </div>

+ 1 - 1
vrobbler/templates/bricksets/brickset_list.html

@@ -16,7 +16,7 @@
 
     <div class="col-md">
         <div class="table-responsive">
-            {% include "_scrobblable_list.html" %}
+            {% include "_longplay_scrobblable_list.html" %}
         </div>
     </div>
 </div>

+ 1 - 1
vrobbler/templates/puzzles/puzzle_list.html

@@ -16,7 +16,7 @@
 
     <div class="col-md">
         <div class="table-responsive">
-            {% include "_scrobblable_list.html" %}
+            {% include "_longplay_scrobblable_list.html" %}
         </div>
     </div>
 </div>