mirror of
https://github.com/daniviga/django-ram.git
synced 2025-08-07 14:47:49 +02:00
Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
2d00436a87 | |||
6ff5450124 |
@@ -121,6 +121,7 @@ class CatalogAdmin(SortableAdminBase, admin.ModelAdmin):
|
||||
BookDocInline,
|
||||
)
|
||||
list_display = (
|
||||
"__str__",
|
||||
"manufacturer",
|
||||
"years",
|
||||
"get_scales",
|
||||
|
@@ -46,10 +46,12 @@
|
||||
<div class="mx-auto">
|
||||
<nav class="nav nav-tabs d-none d-lg-flex flex-row mb-2" id="nav-tab" role="tablist">
|
||||
<button class="nav-link active" id="nav-summary-tab" data-bs-toggle="tab" data-bs-target="#nav-summary" type="button" role="tab" aria-controls="nav-summary" aria-selected="true">Summary</button>
|
||||
{% if documents %}<button class="nav-link" id="nav-documents-tab" data-bs-toggle="tab" data-bs-target="#nav-documents" type="button" role="tab" aria-controls="nav-documents" aria-selected="false">Documents</button>{% endif %}
|
||||
{% if book.notes %}<button class="nav-link" id="nav-notes-tab" data-bs-toggle="tab" data-bs-target="#nav-notes" type="button" role="tab" aria-controls="nav-notes" aria-selected="false">Notes</button>{% endif %}
|
||||
</nav>
|
||||
<select class="form-select d-lg-none mb-2" id="tabSelector" aria-label="Tab selector">
|
||||
<option value="nav-summary" selected>Summary</option>
|
||||
{% if documents %}<option value="nav-documents">Documents</option>{% endif %}
|
||||
{% if book.notes %}<option value="nav-notes">Notes</option>{% endif %}
|
||||
</select>
|
||||
<div class="tab-content" id="nav-tabContent">
|
||||
@@ -131,6 +133,24 @@
|
||||
</table>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="tab-pane" id="nav-documents" role="tabpanel" aria-labelledby="nav-documents-tab">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="3" scope="row">Documents</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="table-group-divider">
|
||||
{% for d in documents.all %}
|
||||
<tr>
|
||||
<td class="w-33">{{ d.description }}</td>
|
||||
<td><a href="{{ d.file.url }}" target="_blank">{{ d.filename }}</a></td>
|
||||
<td class="text-end">{{ d.file.size | filesizeformat }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="tab-pane" id="nav-notes" role="tabpanel" aria-labelledby="nav-notes-tab">
|
||||
{{ book.notes | safe }}
|
||||
</div>
|
||||
|
@@ -28,7 +28,7 @@
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="d-grid gap-2 mb-1 d-md-block">
|
||||
<a class="btn btn-sm btn-outline-primary" href="{% url 'filtered' _filter="scale" search=d.item.slug %}">Show all rolling stock</a>
|
||||
<a class="btn btn-sm btn-outline-primary{% if d.item.num_items == 0 %} disabled{% endif %}" href="{% url 'filtered' _filter="scale" search=d.item.slug %}">Show all rolling stock</a>
|
||||
{% if request.user.is_staff %}<a class="btn btn-sm btn-outline-danger" href="{% url 'admin:metadata_scale_change' d.item.pk %}">Edit</a>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -7,7 +7,7 @@ from urllib.parse import unquote
|
||||
from django.views import View
|
||||
from django.http import Http404, HttpResponseBadRequest
|
||||
from django.db.utils import OperationalError, ProgrammingError
|
||||
from django.db.models import Q
|
||||
from django.db.models import Q, Count
|
||||
from django.shortcuts import render, get_object_or_404, get_list_or_404
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.core.paginator import Paginator
|
||||
@@ -507,7 +507,9 @@ class Scales(GetData):
|
||||
queryset = Scale.objects.all()
|
||||
|
||||
def get_data(self, request):
|
||||
return Scale.objects.all()
|
||||
return Scale.objects.annotate(
|
||||
num_items=Count("rollingstock")
|
||||
) # .filter(num_items__gt=0) to filter data with no items
|
||||
|
||||
|
||||
class Types(GetData):
|
||||
@@ -549,14 +551,16 @@ class GetBookCatalog(View):
|
||||
except ObjectDoesNotExist:
|
||||
raise Http404
|
||||
|
||||
book_properties = book.property.get_public(request.user)
|
||||
properties = book.property.get_public(request.user)
|
||||
documents = book.document.get_public(request.user)
|
||||
return render(
|
||||
request,
|
||||
"bookshelf/book.html",
|
||||
{
|
||||
"title": book,
|
||||
"book_properties": book_properties,
|
||||
"book": book,
|
||||
"documents": documents,
|
||||
"properties": properties,
|
||||
"type": selector
|
||||
},
|
||||
)
|
||||
|
@@ -1,4 +1,4 @@
|
||||
from ram.utils import git_suffix
|
||||
|
||||
__version__ = "0.14.0"
|
||||
__version__ = "0.14.2"
|
||||
__version__ += git_suffix(__file__)
|
||||
|
Reference in New Issue
Block a user