[templates] Clean up redundent templates and fix main menu

This commit is contained in:
2024-09-09 16:58:33 -04:00
parent 0df3dd728d
commit 8d6707db95
12 changed files with 206 additions and 70 deletions

View File

@ -1,15 +1,14 @@
from django.views import generic
from boardgames.models import BoardGame, BoardGamePublisher
from scrobbles.views import ScrobbleableListView, ScrobbleableDetailView
class BoardGameListView(generic.ListView):
class BoardGameListView(ScrobbleableListView):
model = BoardGame
paginate_by = 20
class BoardGameDetailView(generic.DetailView):
class BoardGameDetailView(ScrobbleableDetailView):
model = BoardGame
slug_field = "uuid"
class BoardGamePublisherDetailView(generic.DetailView):

View File

@ -5,14 +5,14 @@ app_name = "books"
urlpatterns = [
path("book/", views.BookListView.as_view(), name="book_list"),
path("books/", views.BookListView.as_view(), name="book_list"),
path(
"book/<slug:slug>/",
"books/<slug:slug>/",
views.BookDetailView.as_view(),
name="book_detail",
),
path(
"author/<slug:slug>/",
"authors/<slug:slug>/",
views.AuthorDetailView.as_view(),
name="author_detail",
),

View File

@ -60,7 +60,7 @@ logger = logging.getLogger(__name__)
class ScrobbleableListView(ListView):
model = None
paginate_by = 20
paginate_by = 200
def get_queryset(self):
queryset = super().get_queryset()

View File

@ -6,15 +6,17 @@ app_name = "videogames"
urlpatterns = [
path(
"video-game/", views.VideoGameListView.as_view(), name="videogame_list"
"video-games/",
views.VideoGameListView.as_view(),
name="videogame_list",
),
path(
"video-game/<slug:slug>/",
"video-games/<slug:slug>/",
views.VideoGameDetailView.as_view(),
name="videogame_detail",
),
path(
"video-game-platform/<slug:slug>/",
"video-game-platforms/<slug:slug>/",
views.VideoGamePlatformDetailView.as_view(),
name="platform_detail",
),

View File

@ -0,0 +1,36 @@
{% load urlreplace %}
<table class="table table-striped table-sm">
<thead>
<tr>
<th scope="col">Title</th>
<th scope="col">Scrobbles</th>
<th scope="col">Start</th>
</tr>
</thead>
<tbody>
{% for obj in object_list %}
<tr>
<td><a href="{{obj.get_absolute_url}}">{{obj}}</a></td>
{% if request.user.is_authenticated %}
<td>{{obj.scrobble_count}}</td>
<td><a type="button" class="btn btn-sm btn-primary" href="{{obj.get_start_url}}">Scrobble</a></td>
{% endif %}
</tr>
{% 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>

View File

@ -234,6 +234,30 @@
Long plays
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/moods/">
<span data-feather="smiley"></span>
Moods
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/books/">
<span data-feather="book"></span>
Books
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/video-games/">
<span data-feather="video"></span>
Video games
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/board-games/">
<span data-feather="board"></span>
Board games
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/imports/">
<span data-feather="log"></span>

View File

@ -16,28 +16,8 @@
<div class="col-md">
<div class="table-responsive">
<table class="table table-striped table-sm">
<thead>
<tr>
<th scope="col">Title</th>
<th scope="col">Scrobbles</th>
<th scope="col">Start</th>
</tr>
</thead>
<tbody>
{% for obj in object_list %}
<tr>
<td><a href="{{obj.get_absolute_url}}">{{obj}}</a></td>
{% if request.user.is_authenticated %}
<td>{{obj.scrobble_count}}</td>
<td><a type="button" class="btn btn-sm btn-primary" href="{{obj.get_start_url}}">Scrobble</a></td>
{% endif %}
</tr>
{% endfor %}
</tbody>
</table>
{% include "_scrobblable_list.html" %}
</div>
</div>
</div>
{% endblock %}

View File

@ -0,0 +1,23 @@
{% extends "base_list.html" %}
{% block title %}Books{% endblock %}
{% block head_extra %}
<style>
dl { width: 210px; float:left; margin-right: 10px; }
dt a { color:white; text-decoration: none; font-size:smaller; }
img { height:200px; width: 200px; object-fit: cover; }
dd .right { float:right; }
</style>
{% endblock %}
{% block lists %}
<div class="row">
<div class="col-md">
<div class="table-responsive">
{% include "_scrobblable_list.html" %}
</div>
</div>
</div>
{% endblock %}

View File

@ -16,26 +16,7 @@
<div class="col-md">
<div class="table-responsive">
<table class="table table-striped table-sm">
<thead>
<tr>
<th scope="col">Title</th>
<th scope="col">Scrobbles</th>
<th scope="col">Start</th>
</tr>
</thead>
<tbody>
{% for mood in object_list %}
<tr>
<td><a href="{{mood.get_absolute_url}}">{{mood}}</a></td>
{% if request.user.is_authenticated %}
<td>{{mood.scrobble_count}}</td>
<td><a type="button" class="btn btn-sm btn-primary" href="{{mood.get_start_url}}">Scrobble</a></td>
{% endif %}
</tr>
{% endfor %}
</tbody>
</table>
{% include "_scrobblable_list.html" %}
</div>
</div>
</div>

View File

@ -0,0 +1,73 @@
{% extends "base_list.html" %}
{% load mathfilters %}
{% load static %}
{% load naturalduration %}
{% block title %}{{object.title}}{% endblock %}
{% block head_extra %}
<style>
.cover img {
width: 250px;
}
.cover {
float: left;
width: 252px;
padding: 0;
}
.summary {
float: left;
width: 600px;
margin-left: 10px;
}
</style>
{% endblock %}
{% block lists %}
<div class="row">
<div class="summary">
{% if object.description%}
<p>{{object.description|safe|linebreaks|truncatewords:160}}</p>
<hr />
{% endif %}
<p style="float:right;">
<a href="{{object.strava_link}}"><img src="{% static "images/strava-logo.png" %}" width=35></a>
</p>
</div>
</div>
<div class="row">
<p>{{object.scrobble_set.count}} scrobbles</p>
<p>
<a href="{{object.get_start_url}}">Play again</a>
</p>
</div>
<div class="row">
<div class="col-md">
<h3>Last scrobbles</h3>
<div class="table-responsive">
<table class="table table-striped table-sm">
<thead>
<tr>
<th scope="col">Date</th>
<th scope="col">Title</th>
<th scope="col">Distance</th>
</tr>
</thead>
<tbody>
{% for scrobble in object.scrobble_set.all|dictsortreversed:"timestamp" %}
<tr>
<td>{{scrobble.timestamp}}</td>
<td>{{scrobble.logdata}}</td>
<td>{{scrobble.media_obj.publisher}}</td>
<td>{% if scrobble.screenshot%}<img src="{{scrobble.screenshot.url}}" width=250 />{% endif %}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
{% endblock %}

View File

@ -0,0 +1,23 @@
{% extends "base_list.html" %}
{% block title %}Trails{% endblock %}
{% block head_extra %}
<style>
dl { width: 210px; float:left; margin-right: 10px; }
dt a { color:white; text-decoration: none; font-size:smaller; }
img { height:200px; width: 200px; object-fit: cover; }
dd .right { float:right; }
</style>
{% endblock %}
{% block lists %}
<div class="row">
<div class="col-md">
<div class="table-responsive">
{% include "_scrobblable_list.html" %}
</div>
</div>
</div>
{% endblock %}

View File

@ -1,27 +1,22 @@
{% extends "base_list.html" %}
{% block title %}Video games{% endblock %}
{% block head_extra %}
<style>
dl { width: 210px; float:left; margin-right: 10px; }
dt a { color:white; text-decoration: none; font-size:smaller; }
img { height:200px; width: 200px; object-fit: cover; }
dd .right { float:right; }
</style>
{% endblock %}
{% block lists %}
<div class="row">
<div class="col-md">
<div class="table-responsive">
<table class="table table-striped table-sm">
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Scrobbles</th>
<th scope="col">All time</th>
</tr>
</thead>
<tbody>
{% for obj in object_list %}
<tr>
<td><a href="{{obj.get_absolute_url}}">{{obj}}</a></td>
<td>{{obj.scrobble_set.count}}</td>
<td></td>
</tr>
{% endfor %}
</tbody>
</table>
{% include "_scrobblable_list.html" %}
</div>
</div>
</div>