Pārlūkot izejas kodu

Add board and video games to index

Colin Powell 2 gadi atpakaļ
vecāks
revīzija
9e38798f44

+ 8 - 0
vrobbler/apps/scrobbles/views.py

@@ -91,6 +91,14 @@ class RecentScrobbleList(ListView):
                 sport_event__isnull=False
             ).order_by("-timestamp")[:15]
 
+            data["videogame_scrobble_list"] = completed_for_user.filter(
+                video_game__isnull=False
+            ).order_by("-timestamp")[:15]
+
+            data["boardgame_scrobble_list"] = completed_for_user.filter(
+                board_game__isnull=False
+            ).order_by("-timestamp")[:15]
+
             data["active_imports"] = AudioScrobblerTSVImport.objects.filter(
                 processing_started__isnull=False,
                 processed_finished__isnull=True,

+ 67 - 0
vrobbler/templates/scrobbles/scrobble_list.html

@@ -451,6 +451,14 @@
                     <button class="nav-link" id="profile-tab" data-bs-toggle="tab" data-bs-target="#latest-sports"
                         type="button" role="tab" aria-controls="profile" aria-selected="false">Sports</button>
                 </li>
+                <li class="nav-item" role="presentation">
+                    <button class="nav-link" id="profile-tab" data-bs-toggle="tab" data-bs-target="#latest-videogames"
+                        type="button" role="tab" aria-controls="profile" aria-selected="false">Video Games</button>
+                </li>
+                <li class="nav-item" role="presentation">
+                    <button class="nav-link" id="profile-tab" data-bs-toggle="tab" data-bs-target="#latest-boardgames"
+                        type="button" role="tab" aria-controls="profile" aria-selected="false">Board Games</button>
+                </li>
             </ul>
 
             <div class="tab-content" id="myTabContent2">
@@ -560,6 +568,65 @@
                         </table>
                     </div>
                 </div>
+
+                <div class="tab-pane fade show" id="latest-videogames" role="tabpanel"
+                    aria-labelledby="latest-videogames-tab">
+                    <h2>Latest Video Games</h2>
+                    <div class="table-responsive">
+                        <table class="table table-striped table-sm">
+                            <thead>
+                                <tr>
+                                    <th scope="col">Date</th>
+                                    <th scope="col">Cover</th>
+                                    <th scope="col">Title</th>
+                                    <th scope="col">Score</th>
+                                </tr>
+                            </thead>
+                            <tbody>
+                                {% for scrobble in videogame_scrobble_list %}
+                                <tr>
+                                    <td>{{scrobble.timestamp|naturaltime}}</td>
+                                    {% if scrobble.videogame_screenshot %}
+                                    <td><a href="{{scrobble.media_obj.get_absolute_url}}"><img src="{{scrobble.videogame_screenshot.url}}" width=25 height=25 style="border:1px solid black;" /></aa></td>
+                                    {% else %}
+                                    <td><a href="{{scrobble.media_obj.get_absolute_url}}"><img src="{{scrobble.media_obj.primary_image_url}}" width=25 height=25 style="border:1px solid black;" /></aa></td>
+                                    {% endif %}
+                                    <td>{{scrobble.media_obj.title}}</td>
+                                    <td>{{scrobble.media_obj.hltb_score}}</td>
+                                </tr>
+                                {% endfor %}
+                            </tbody>
+                        </table>
+                    </div>
+                </div>
+
+
+                <div class="tab-pane fade show" id="latest-boardgames" role="tabpanel"
+                    aria-labelledby="latest-boardgames-tab">
+                    <h2>Latest Board Games</h2>
+                    <div class="table-responsive">
+                        <table class="table table-striped table-sm">
+                            <thead>
+                                <tr>
+                                    <th scope="col">Date</th>
+                                    <th scope="col">Cover</th>
+                                    <th scope="col">Title</th>
+                                    <th scope="col">Rating</th>
+                                </tr>
+                            </thead>
+                            <tbody>
+                                {% for scrobble in boardgame_scrobble_list %}
+                                <tr>
+                                    <td>{{scrobble.timestamp|naturaltime}}</td>
+                                    <td><a href="{{scrobble.media_obj.get_absolute_url}}"><img src="{{scrobble.media_obj.primary_image_url}}" width=25 height=25 style="border:1px solid black;" /></aa></td>
+                                    <td>{{scrobble.media_obj.title}}</td>
+                                    <td>{{scrobble.media_obj.rating}}</td>
+                                </tr>
+                                {% endfor %}
+                            </tbody>
+                        </table>
+                    </div>
+                </div>
             </div>
             {% endif %}
         </div>