mirror of
https://github.com/daniviga/django-ram.git
synced 2025-08-07 14:47:49 +02:00
Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
63379c9673
|
|||
be6a685f55
|
|||
ad33731913
|
|||
503a214a4d
|
|||
1528d1ba56
|
|||
5b04abb262
|
|||
9fa70ae656
|
@@ -22,13 +22,13 @@ class DecoderAdmin(admin.ModelAdmin):
|
||||
readonly_fields = ("image_thumbnail",)
|
||||
list_display = ("__str__", "interface")
|
||||
list_filter = ("manufacturer", "interface")
|
||||
search_fields = ("__str__",)
|
||||
search_fields = ("name", "manufacturer__name")
|
||||
|
||||
|
||||
@admin.register(Scale)
|
||||
class ScaleAdmin(admin.ModelAdmin):
|
||||
list_display = ("scale", "ratio", "gauge")
|
||||
list_filter = ("ratio", "gauge")
|
||||
list_display = ("scale", "ratio", "gauge", "tracks")
|
||||
list_filter = ("ratio", "gauge", "tracks")
|
||||
search_fields = list_display
|
||||
|
||||
|
||||
@@ -59,4 +59,4 @@ class TagAdmin(admin.ModelAdmin):
|
||||
class RollingStockTypeAdmin(SortableAdminMixin, admin.ModelAdmin):
|
||||
list_display = ("__str__",)
|
||||
list_filter = ("type", "category")
|
||||
search_fields = list_display
|
||||
search_fields = ("type", "category")
|
||||
|
18
ram/metadata/migrations/0005_rename_gauge_scale_track.py
Normal file
18
ram/metadata/migrations/0005_rename_gauge_scale_track.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 4.0.6 on 2022-07-18 21:40
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('metadata', '0004_alter_rollingstocktype_options_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name='scale',
|
||||
old_name='gauge',
|
||||
new_name='track',
|
||||
),
|
||||
]
|
18
ram/metadata/migrations/0006_scale_gauge.py
Normal file
18
ram/metadata/migrations/0006_scale_gauge.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 4.0.6 on 2022-07-18 21:41
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('metadata', '0005_rename_gauge_scale_track'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='scale',
|
||||
name='gauge',
|
||||
field=models.CharField(blank=True, max_length=16),
|
||||
),
|
||||
]
|
18
ram/metadata/migrations/0007_rename_track_scale_tracks.py
Normal file
18
ram/metadata/migrations/0007_rename_track_scale_tracks.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 4.0.6 on 2022-07-18 21:44
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('metadata', '0006_scale_gauge'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name='scale',
|
||||
old_name='track',
|
||||
new_name='tracks',
|
||||
),
|
||||
]
|
@@ -85,6 +85,7 @@ class Scale(models.Model):
|
||||
scale = models.CharField(max_length=32, unique=True)
|
||||
ratio = models.CharField(max_length=16, blank=True)
|
||||
gauge = models.CharField(max_length=16, blank=True)
|
||||
tracks = models.CharField(max_length=16, blank=True)
|
||||
|
||||
class Meta:
|
||||
ordering = ["scale"]
|
||||
|
@@ -57,6 +57,12 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{% url 'consists' %}">Consists</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{% url 'companies' %}">Companies</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{% url 'scales' %}">Scales</a>
|
||||
</li>
|
||||
</ul>
|
||||
{% include 'includes/search.html' %}
|
||||
</div>
|
||||
@@ -82,7 +88,10 @@
|
||||
{% if i.is_thumbnail %}<a href="{{r.get_absolute_url}}"><img src="{{ i.image.url }}" alt="Card image cap"></a>{% endif %}
|
||||
{% endfor %}
|
||||
<div class="card-body">
|
||||
<p class="card-text"><strong>{{ r }}</strong></p>
|
||||
<p class="card-text" style="position: relative;">
|
||||
<strong>{{ r }}</strong>
|
||||
<a class="stretched-link" href="{{ r.get_absolute_url }}"></a>
|
||||
</p>
|
||||
{% if r.tags.all %}
|
||||
<p class="card-text"><small>Tags:</small>
|
||||
{% for t in r.tags.all %}<a href="{% url 'filtered' _filter="tag" search=t.slug %}" class="badge rounded-pill bg-primary">
|
||||
@@ -123,7 +132,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Scale</th>
|
||||
<td><abbr title="{{ r.scale.ratio }} - {{ r.scale.gauge }}">{{ r.scale }}</abbr></td>
|
||||
<td><a href="{% url 'filtered' _filter="scale" search=r.scale %}"><abbr title="{{ r.scale.ratio }} - {{ r.scale.gauge }}">{{ r.scale }}</abbr></a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">SKU</th>
|
||||
|
95
ram/portal/templates/companies.html
Normal file
95
ram/portal/templates/companies.html
Normal file
@@ -0,0 +1,95 @@
|
||||
{% extends "base.html" %}
|
||||
{% load markdown %}
|
||||
|
||||
{% block header %}
|
||||
<h1 class="fw-light">Companies</h1>
|
||||
{% endblock %}
|
||||
{% block cards %}
|
||||
{% for c in company %}
|
||||
<div class="col">
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-body">
|
||||
<p class="card-text" style="position: relative;">
|
||||
<strong>{{ c.name }}</strong>
|
||||
</p>
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2" scope="row">Company</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% if c.logo %}
|
||||
<tr>
|
||||
<th width="35%" scope="row">Logo</th>
|
||||
<td><img style="max-height: 48px" src="{{ c.logo.url }}" /></td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
<tr>
|
||||
<th width="35%" scope="row">Name</th>
|
||||
<td>{{ c.extended_name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th width="35%" scope="row">Abbreviation</th>
|
||||
<td>{{ c }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th width="35%" scope="row">Country</th>
|
||||
<td>{{ c.country.name }} <img src="{{ c.country.flag }}" alt="{{ c.country }}" />
|
||||
</tr>
|
||||
{% if c.freelance %}
|
||||
<tr>
|
||||
<th width="35%" scope="row">Notes</th>
|
||||
<td>A <em>freelance</em> company</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="btn-group mb-4">
|
||||
<a class="btn btn-sm btn-outline-primary" href="{% url 'filtered' _filter="company" search=c %}">Show all rolling stock</a>
|
||||
{% if request.user.is_staff %}<a class="btn btn-sm btn-outline-danger" href="{% url 'admin:metadata_company_change' c.pk %}">Edit</a>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
{% block pagination %}
|
||||
{% if company.has_other_pages %}
|
||||
<nav aria-label="Page navigation example">
|
||||
<ul class="pagination justify-content-center mt-4">
|
||||
{% if company.has_previous %}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="{% url 'company_pagination' page=company.previous_page_number %}#rolling-stock" tabindex="-1">Previous</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="page-item disabled">
|
||||
<span class="page-link">Previous</span>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% for i in page_range %}
|
||||
{% if company.number == i %}
|
||||
<li class="page-item active">
|
||||
<span class="page-link">{{ i }}</span></span>
|
||||
</li>
|
||||
{% else %}
|
||||
{% if i == company.paginator.ELLIPSIS %}
|
||||
<li class="page-item"><span class="page-link">{{ i }}</span></li>
|
||||
{% else %}
|
||||
<li class="page-item"><a class="page-link" href="{% url 'company_pagination' page=i %}#rolling-stock">{{ i }}</a></li>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if company.has_next %}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="{% url 'company_pagination' page=company.next_page_number %}#rolling-stock" tabindex="-1">Next</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="page-item disabled">
|
||||
<span class="page-link">Next</span>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</nav>
|
||||
{% endif %}
|
||||
{% endblock %}
|
@@ -5,11 +5,11 @@
|
||||
<h1 class="fw-light">{{ consist }}</h1>
|
||||
{% if consist.tags.all %}
|
||||
<p><small>Tags:</small>
|
||||
{% for t in consist.tags.all %}<span class="badge bg-primary">
|
||||
{{ t.name }}</span>{# new line is required #}
|
||||
{% for t in consist.tags.all %}<a href="{% url 'filtered' _filter="tag" search=t.slug %}" class="badge rounded-pill bg-primary">
|
||||
{{ t.name }}</a>{# new line is required #}
|
||||
{% endfor %}
|
||||
</p>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
{% block cards %}
|
||||
{% for r in rolling_stock %}
|
||||
@@ -19,11 +19,14 @@
|
||||
{% if i.is_thumbnail %}<a href="{{r.rolling_stock.get_absolute_url}}"><img src="{{ i.image.url }}" alt="Card image cap"></a>{% endif %}
|
||||
{% endfor %}
|
||||
<div class="card-body">
|
||||
<p class="card-text"><strong>{{ r }}</strong></p>
|
||||
<p class="card-text" style="position: relative;">
|
||||
<strong>{{ r }}</strong>
|
||||
<a class="stretched-link" href="{{ r.rolling_stock.get_absolute_url }}"></a>
|
||||
</p>
|
||||
{% if r.rolling_stock.tags.all %}
|
||||
<p class="card-text"><small>Tags:</small>
|
||||
{% for t in r.rolling_stock.tags.all %}<span class="badge bg-primary">
|
||||
{{ t.name }}</span>{# new line is required #}
|
||||
{% for t in r.rolling_stock.tags.all %}<a href="{% url 'filtered' _filter="tag" search=t.slug %}" class="badge rounded-pill bg-primary">
|
||||
{{ t.name }}</a>{# new line is required #}
|
||||
{% endfor %}
|
||||
</p>
|
||||
{% endif %}
|
||||
@@ -60,7 +63,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Scale</th>
|
||||
<td><abbr title="{{ r.rolling_stock.scale.ratio }} - {{ r.rolling_stock.scale.gauge }}">{{ r.rolling_stock.scale }}</abbr></td>
|
||||
<td><a href="{% url 'filtered' _filter="scale" search=r.rolling_stock.scale %}"><abbr title="{{ r.rolling_stock.scale.ratio }} - {{ r.rolling_stock.scale.gauge }}">{{ r.rolling_stock.scale }}</abbr></a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">SKU</th>
|
||||
|
@@ -10,7 +10,10 @@
|
||||
<div class="card shadow-sm">
|
||||
{% if c.image %}<a href="{{ c.get_absolute_url }}"><img src="{{ c.image.url }}" alt="Card image cap"></a>{% endif %}
|
||||
<div class="card-body">
|
||||
<p class="card-text"><strong>{{ c }}</strong></p>
|
||||
<p class="card-text" style="position: relative;">
|
||||
<strong>{{ c }}</strong>
|
||||
<a class="stretched-link" href="{{ c.get_absolute_url }}"></a>
|
||||
</p>
|
||||
{% if c.tags.all %}
|
||||
<p class="card-text"><small>Tags:</small>
|
||||
{% for t in c.tags.all %}<a href="{% url 'filtered' _filter="tag" search=t.slug %}" class="badge rounded-pill bg-primary">
|
||||
@@ -76,7 +79,7 @@
|
||||
<span class="page-link">{{ i }}</span></span>
|
||||
</li>
|
||||
{% else %}
|
||||
{% if i == rolling_stock.paginator.ELLIPSIS %}
|
||||
{% if i == consist.paginator.ELLIPSIS %}
|
||||
<li class="page-item"><span class="page-link">{{ i }}</span></li>
|
||||
{% else %}
|
||||
<li class="page-item"><a class="page-link" href="{% url 'consists_pagination' page=i %}#rolling-stock">{{ i }}</a></li>
|
||||
|
@@ -76,7 +76,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Scale</th>
|
||||
<td><abbr title="{{ rolling_stock.scale.ratio }} - {{ rolling_stock.scale.gauge }}">{{ rolling_stock.scale }}</abbr></td>
|
||||
<td><a href="{% url 'filtered' _filter="scale" search=rolling_stock.scale %}"><abbr title="{{ rolling_stock.scale.ratio }} - {{ rolling_stock.scale.gauge }}">{{ rolling_stock.scale }}</abbr></a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">SKU</th>
|
||||
@@ -125,7 +125,7 @@
|
||||
<td>{{ rolling_stock.sku }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">ERA</th>
|
||||
<th scope="row">Era</th>
|
||||
<td>{{ rolling_stock.era }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
85
ram/portal/templates/scales.html
Normal file
85
ram/portal/templates/scales.html
Normal file
@@ -0,0 +1,85 @@
|
||||
{% extends "base.html" %}
|
||||
{% load markdown %}
|
||||
|
||||
{% block header %}
|
||||
<h1 class="fw-light">Scales</h1>
|
||||
{% endblock %}
|
||||
{% block cards %}
|
||||
{% for s in scale %}
|
||||
<div class="col">
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-body">
|
||||
<p class="card-text"><strong>{{ s }}</strong></p>
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2" scope="row">Scale</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th width="35%" scope="row">Name</th>
|
||||
<td>{{ s.scale }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th width="35%" scope="row">Ratio</th>
|
||||
<td>{{ s.ratio }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th width="35%" scope="row">Gauge</th>
|
||||
<td>{{ s.gauge }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th width="35%" scope="row">Tracks</th>
|
||||
<td>{{ s.tracks }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="btn-group mb-4">
|
||||
<a class="btn btn-sm btn-outline-primary" href="{% url 'filtered' _filter="scale" search=s %}">Show all rolling stock</a>
|
||||
{% if request.user.is_staff %}<a class="btn btn-sm btn-outline-danger" href="{% url 'admin:metadata_scale_change' s.pk %}">Edit</a>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
{% block pagination %}
|
||||
{% if scale.has_other_pages %}
|
||||
<nav aria-label="Page navigation example">
|
||||
<ul class="pagination justify-content-center mt-4">
|
||||
{% if scale.has_previous %}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="{% url 'scale_pagination' page=scale.previous_page_number %}#rolling-stock" tabindex="-1">Previous</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="page-item disabled">
|
||||
<span class="page-link">Previous</span>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% for i in page_range %}
|
||||
{% if scale.number == i %}
|
||||
<li class="page-item active">
|
||||
<span class="page-link">{{ i }}</span></span>
|
||||
</li>
|
||||
{% else %}
|
||||
{% if i == scale.paginator.ELLIPSIS %}
|
||||
<li class="page-item"><span class="page-link">{{ i }}</span></li>
|
||||
{% else %}
|
||||
<li class="page-item"><a class="page-link" href="{% url 'scale_pagination' page=i %}#rolling-stock">{{ i }}</a></li>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if scale.has_next %}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="{% url 'scale_pagination' page=scale.next_page_number %}#rolling-stock" tabindex="-1">Next</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="page-item disabled">
|
||||
<span class="page-link">Next</span>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</nav>
|
||||
{% endif %}
|
||||
{% endblock %}
|
@@ -10,7 +10,7 @@
|
||||
<ul class="pagination justify-content-center mt-4">
|
||||
{% if rolling_stock.has_previous %}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="{% url 'search_pagination' search=search page=rolling_stock.previous_page_number %}#rolling-stock" tabindex="-1">Previous</a>
|
||||
<a class="page-link" href="{% url 'filtered_pagination' _filter=filter search=search page=rolling_stock.previous_page_number %}#rolling-stock" tabindex="-1">Previous</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="page-item disabled">
|
||||
@@ -26,13 +26,13 @@
|
||||
{% if i == rolling_stock.paginator.ELLIPSIS %}
|
||||
<li class="page-item"><span class="page-link">{{ i }}</span></li>
|
||||
{% else %}
|
||||
<li class="page-item"><a class="page-link" href="{% url 'index_pagination' page=i %}#rolling-stock">{{ i }}</a></li>
|
||||
<li class="page-item"><a class="page-link" href="{% url 'filtered_pagination' _filter=filter search=search page=i %}#rolling-stock">{{ i }}</a></li>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if rolling_stock.has_next %}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="{% url 'search_pagination' search=search page=rolling_stock.next_page_number %}#rolling-stock" tabindex="-1">Next</a>
|
||||
<a class="page-link" href="{% url 'filtered_pagination' _filter=filter search=search page=rolling_stock.next_page_number %}#rolling-stock" tabindex="-1">Next</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="page-item disabled">
|
||||
|
@@ -6,6 +6,8 @@ from portal.views import (
|
||||
GetRollingStock,
|
||||
GetConsist,
|
||||
Consists,
|
||||
Companies,
|
||||
Scales,
|
||||
)
|
||||
|
||||
urlpatterns = [
|
||||
@@ -16,12 +18,6 @@ urlpatterns = [
|
||||
GetHomeFiltered.as_view(http_method_names=["post"]),
|
||||
name="search",
|
||||
),
|
||||
path("search/<str:search>", GetHomeFiltered.as_view(), name="search"),
|
||||
path(
|
||||
"search/<str:search>/<int:page>",
|
||||
GetHomeFiltered.as_view(),
|
||||
name="search_pagination",
|
||||
),
|
||||
path("consists", Consists.as_view(), name="consists"),
|
||||
path(
|
||||
"consists/<int:page>", Consists.as_view(), name="consists_pagination"
|
||||
@@ -32,6 +28,18 @@ urlpatterns = [
|
||||
GetConsist.as_view(),
|
||||
name="consist_pagination",
|
||||
),
|
||||
path("companies", Companies.as_view(), name="companies"),
|
||||
path(
|
||||
"companies/<int:page>",
|
||||
Companies.as_view(),
|
||||
name="companies_pagination"
|
||||
),
|
||||
path("scales", Scales.as_view(), name="scales"),
|
||||
path(
|
||||
"scales/<int:page>",
|
||||
Scales.as_view(),
|
||||
name="scales_pagination"
|
||||
),
|
||||
path(
|
||||
"<str:_filter>/<str:search>",
|
||||
GetHomeFiltered.as_view(),
|
||||
|
@@ -11,6 +11,7 @@ from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
|
||||
from portal.utils import get_site_conf
|
||||
from roster.models import RollingStock
|
||||
from consist.models import Consist
|
||||
from metadata.models import Company, Scale
|
||||
|
||||
|
||||
def order_by_fields():
|
||||
@@ -49,7 +50,7 @@ class GetHome(View):
|
||||
class GetHomeFiltered(View):
|
||||
def run_search(self, request, search, _filter, page=1):
|
||||
site_conf = get_site_conf()
|
||||
if _filter is None:
|
||||
if _filter == "search":
|
||||
query = reduce(
|
||||
operator.or_,
|
||||
(
|
||||
@@ -73,9 +74,9 @@ class GetHomeFiltered(View):
|
||||
| Q(rolling_class__company__extended_name__icontains=search)
|
||||
)
|
||||
elif _filter == "scale":
|
||||
query = Q(scale__scale__icontains=search)
|
||||
query = Q(scale__scale__iexact=search)
|
||||
elif _filter == "tag":
|
||||
query = Q(tags__slug__icontains=search)
|
||||
query = Q(tags__slug__iexact=search)
|
||||
else:
|
||||
raise Http404
|
||||
rolling_stock = RollingStock.objects.filter(query).order_by(
|
||||
@@ -89,7 +90,7 @@ class GetHomeFiltered(View):
|
||||
|
||||
return rolling_stock, matches, page_range
|
||||
|
||||
def get(self, request, search, _filter=None, page=1):
|
||||
def get(self, request, search, _filter="search", page=1):
|
||||
rolling_stock, matches, page_range = self.run_search(
|
||||
request, search, _filter, page
|
||||
)
|
||||
@@ -106,7 +107,7 @@ class GetHomeFiltered(View):
|
||||
},
|
||||
)
|
||||
|
||||
def post(self, request, _filter=None, page=1):
|
||||
def post(self, request, _filter="search", page=1):
|
||||
search = request.POST.get("search")
|
||||
if not search:
|
||||
raise Http404
|
||||
@@ -196,3 +197,35 @@ class GetConsist(View):
|
||||
"page_range": page_range,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
class Companies(View):
|
||||
def get(self, request, page=1):
|
||||
site_conf = get_site_conf()
|
||||
company = Company.objects.all()
|
||||
|
||||
paginator = Paginator(company, site_conf.items_per_page)
|
||||
company = paginator.get_page(page)
|
||||
page_range = paginator.get_elided_page_range(company.number)
|
||||
|
||||
return render(
|
||||
request,
|
||||
"companies.html",
|
||||
{"company": company, "page_range": page_range},
|
||||
)
|
||||
|
||||
|
||||
class Scales(View):
|
||||
def get(self, request, page=1):
|
||||
site_conf = get_site_conf()
|
||||
scale = Scale.objects.all()
|
||||
|
||||
paginator = Paginator(scale, site_conf.items_per_page)
|
||||
scale = paginator.get_page(page)
|
||||
page_range = paginator.get_elided_page_range(scale.number)
|
||||
|
||||
return render(
|
||||
request,
|
||||
"scales.html",
|
||||
{"scale": scale, "page_range": page_range},
|
||||
)
|
||||
|
@@ -1,4 +1,4 @@
|
||||
from ram.utils import git_suffix
|
||||
|
||||
__version__ = "0.0.6"
|
||||
__version__ = "0.0.9"
|
||||
__version__ += git_suffix(__file__)
|
||||
|
@@ -20,7 +20,11 @@ class RollingClass(admin.ModelAdmin):
|
||||
inlines = (RollingClassPropertyInline,)
|
||||
list_display = ("__str__", "type", "company")
|
||||
list_filter = ("company", "type__category", "type")
|
||||
search_fields = list_display
|
||||
search_fields = (
|
||||
"identifier",
|
||||
"company__name",
|
||||
"type__type",
|
||||
)
|
||||
|
||||
|
||||
class RollingStockDocInline(admin.TabularInline):
|
||||
@@ -62,10 +66,18 @@ class RollingStockAdmin(admin.ModelAdmin):
|
||||
list_filter = (
|
||||
"rolling_class__type__category",
|
||||
"rolling_class__type",
|
||||
"rolling_class__company__name",
|
||||
"scale",
|
||||
"manufacturer",
|
||||
)
|
||||
search_fields = list_display
|
||||
search_fields = (
|
||||
"rolling_class__identifier",
|
||||
"rolling_class__company__name",
|
||||
"manufacturer__name",
|
||||
"road_number",
|
||||
"address",
|
||||
"sku",
|
||||
)
|
||||
|
||||
fieldsets = (
|
||||
(
|
||||
|
Reference in New Issue
Block a user