4 Commits

4 changed files with 16 additions and 7 deletions

View File

@@ -115,7 +115,7 @@
</tr>
</tbody>
</table>
{% if book_properties %}
{% if properties %}
<table class="table table-striped">
<thead>
<tr>
@@ -123,7 +123,7 @@
</tr>
</thead>
<tbody class="table-group-divider">
{% for p in book_properties %}
{% for p in properties %}
<tr>
<th class="w-33" scope="row">{{ p.property }}</th>
<td>{{ p.value }}</td>

View File

@@ -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>

View File

@@ -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
@@ -259,7 +259,7 @@ class GetManufacturerItem(View):
manufacturer,
# all returned records must have the same `item_number``;
# just pick it up the first result, otherwise `search`
roster.first.item_number if roster else search,
roster[0].item_number if roster else search,
)
else:
roster = (
@@ -344,6 +344,13 @@ class GetObjectsFiltered(View):
)
for item in books:
data.append({"type": "book", "item": item})
catalogs = (
Catalog.objects.get_published(request.user)
.filter(query_2nd)
.distinct()
)
for item in catalogs:
data.append({"type": "catalog", "item": item})
except NameError:
pass
@@ -507,7 +514,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):

View File

@@ -1,4 +1,4 @@
from ram.utils import git_suffix
__version__ = "0.14.1"
__version__ = "0.14.3"
__version__ += git_suffix(__file__)