Fully implement UI for magazines

This commit is contained in:
2025-12-10 22:56:22 +01:00
parent 0688725326
commit 49da8f58fe
11 changed files with 334 additions and 31 deletions

View File

@@ -89,7 +89,30 @@
</tr>
<tr>
<th class="w-33" scope="row">Publisher</th>
<td>{{ book.publisher }}</td>
<td>
<img src="{{ book.publisher.country.flag }}" alt="{{ book.publisher.country }}"> {{ book.publisher }}
{% if book.publisher.website %} <a href="{{ book.publisher.website }}" target="_blank"><i class="bi bi-box-arrow-up-right"></i></a>{% endif %}
</td>
</tr>
{% elif type == "magazineissue" %}
<tr>
<th class="w-33" scope="row">Magazine</th>
<td><a href="{% url 'magazine' book.magazine.pk %}">{{ book.magazine }}</a></td>
</tr>
<tr>
<th class="w-33" scope="row">Publisher</th>
<td>
<img src="{{ book.publisher.country.flag }}" alt="{{ book.publisher.country }}"> {{ book.publisher }}
{% if book.publisher.website %} <a href="{{ book.publisher.website }}" target="_blank"><i class="bi bi-box-arrow-up-right"></i></a>{% endif %}
</td>
</tr>
<tr>
<th class="w-33" scope="row">Issue</th>
<td>{{ book.issue_number }}</td>
</tr>
<tr>
<th class="w-33" scope="row">Date</th>
<td>{{ book.publication_year|default:"-" }} / {{ book.publication_month|default:"-" }}</td>
</tr>
{% endif %}
<tr>
@@ -104,10 +127,12 @@
<th scope="row">Number of pages</th>
<td>{{ book.number_of_pages|default:"-" }}</td>
</tr>
{% if type == "boook" or type == "catalog" %}
<tr>
<th scope="row">Publication year</th>
<td>{{ book.publication_year|default:"-" }}</td>
</tr>
{% endif %}
{% if book.description %}
<tr>
<th class="w-33" scope="row">Description</th>

View File

@@ -10,6 +10,9 @@
{% if catalogs_menu %}
<li><a class="dropdown-item" href="{% url 'catalogs' %}">Catalogs</a></li>
{% endif %}
{% if magazines_menu %}
<li><a class="dropdown-item" href="{% url 'magazines' %}">Magazines</a></li>
{% endif %}
</ul>
</li>
{% endif %}

View File

@@ -18,7 +18,7 @@
{% include "cards/consist.html" %}
{% elif d.type == "manufacturer" %}
{% include "cards/manufacturer.html" %}
{% elif d.type == "magazine" or d.type == "issue" %}
{% elif d.type == "magazine" or d.type == "magazineissue" %}
{% include "cards/magazine.html" %}
{% elif d.type == "book" or d.type == "catalog" %}
{% include "cards/book.html" %}

View File

@@ -1,5 +1,4 @@
{% load static %}
<div class="col">
<div class="card shadow-sm">
{% if d.type == "magazine" %}
@@ -15,9 +14,7 @@
<img class="card-img-top d-none d-sm-block" src="{% static DEFAULT_CARD_IMAGE %}" alt="{{ d.item }}">
{% endif %}
</a>
{% endif %}
{% if d.type == "issue" %}
{% elif d.type == "magazineissue" %}
<a href="{{ d.item.get_absolute_url }}">
{% if d.item.image.exists %}
<img class="card-img-top" src="{{ d.item.image.first.image.url }}" alt="{{ d.item }}">
@@ -54,10 +51,33 @@
</tr>
</thead>
<tbody class="table-group-divider">
{% if d.type == "magazineissue" %}
<tr>
<th class="w-33" scope="row">Magazine</th>
<td>{{ d.item.magazine }}</td>
</tr>
{% endif %}
<tr>
<th class="w-33" scope="row">Publisher</th>
<td><img src="{{ d.item.publisher.country.flag }}" alt="{{ d.item.publisher.country }}"> {{ d.item.publisher }}</td>
<td>
<img src="{{ d.item.publisher.country.flag }}" alt="{{ d.item.publisher.country }}"> {{ d.item.publisher }}
{% if d.item.publisher.website %} <a href="{{ d.item.publisher.website }}" target="_blank"><i class="bi bi-box-arrow-up-right"></i></a>{% endif %}
</td>
</tr>
{% if d.type == "magazineissue" %}
<tr>
<th class="w-33" scope="row">Issue</th>
<td>{{ d.item.issue_number }}</td>
</tr>
<tr>
<th class="w-33" scope="row">Date</th>
<td>{{ d.item.publication_year|default:"-" }} / {{ d.item.publication_month|default:"-" }}</td>
</tr>
<tr>
<th class="w-33" scope="row">Pages</th>
<td>{{ d.item.number_of_pages|default:"-" }}</td>
</tr>
{% endif %}
<tr>
<th class="w-33" scope="row">Language</th>
<td>{{ d.item.get_language_display }}</td>
@@ -65,8 +85,12 @@
</tbody>
</table>
<div class="d-grid gap-2 mb-1 d-md-block">
{% if d.type == "magazine" %}
<a class="btn btn-sm btn-outline-primary{% if d.item.issues == 0 %} disabled{% endif %}" href="{{ d.item.get_absolute_url }}">Show {{ d.item.issues }} issue{{ d.item.issues|pluralize }}</a>
{% else %}
<a class="btn btn-sm btn-outline-primary" href="{{ d.item.get_absolute_url }}">Show all data</a>
{% if request.user.is_staff %}<a class="btn btn-sm btn-outline-danger" href="{% url 'admin:bookshelf_magazine_change' d.item.pk %}">Edit</a>{% endif %}
{% endif %}
{% if request.user.is_staff %}<a class="btn btn-sm btn-outline-danger" href="{% url 'admin:bookshelf_magazineissue_change' d.item.pk %}">Edit</a>{% endif %}
</div>
</div>
</div>

View File

@@ -31,7 +31,7 @@
</table>
<div class="d-grid gap-2 mb-1 d-md-block">
{% with items=d.item.num_items %}
<a class="btn btn-sm btn-outline-primary{% if items == 0 %} disabled{% endif %}" href="{% url 'filtered' _filter="manufacturer" search=d.item.slug %}">Show {{ items }} item{{ items | pluralize}}</a>
<a class="btn btn-sm btn-outline-primary{% if items == 0 %} disabled{% endif %}" href="{% url 'filtered' _filter="manufacturer" search=d.item.slug %}">Show {{ items }} item{{ items|pluralize }}</a>
{% if request.user.is_staff %}<a class="btn btn-sm btn-outline-danger" href="{% url 'admin:metadata_manufacturer_change' d.item.pk %}">Edit</a>{% endif %}
{% endwith %}
</div>

View File

@@ -1,6 +1,6 @@
{% extends "cards.html" %}
{% block header %}
{{ block.super }}
{% if magazine.tags.all %}
<p><small>Tags:</small>
{% for t in magazine.tags.all %}<a href="{% url 'filtered' _filter="tag" search=t.slug %}" class="badge rounded-pill bg-primary">
@@ -87,13 +87,19 @@
</thead>
<tbody class="table-group-divider">
<tr>
<th class="w-33" scope="row">Company</th>
<th class="w-33" scope="row">Name</th>
<td>{{ magazine }} </td>
</tr>
<tr>
<th class="w-33" scope="row">Publisher</th>
<td>
<img src="{{ magazine.publisher.country.flag }}" alt="{{ magazine.publisher.country }}"> {{ magazine.publisher }}
{% if magazine.publisher.website %} <a href="{{ magazine.publisher.website }}" target="_blank"><i class="bi bi-box-arrow-up-right"></i></a>{% endif %}
</td>
</tr>
<tr>
<th scope="row">Era</th>
<td>{{ magazine.era }}</td>
<th scope="row">ISBN</th>
<td>{{ magazine.ISBN | default:"-" }}</td>
</tr>
{% if magazine.description %}
<tr>
@@ -101,14 +107,6 @@
<td>{{ magazine.description | safe }}</td>
</tr>
{% endif %}
<tr>
<th scope="row">Length</th>
<td>{{ magazine.length }}</td>
</tr>
<tr>
<th scope="row">Composition</th>
<td>{% for t in magazine.get_type_count %}{{ t.count }}x {{ t.type }} {{t.category }}{% if not forloop.last %} &raquo; {% endif %}{% endfor %}</td>
</tr>
</tbody>
</table>
</div>