mirror of
https://github.com/daniviga/django-ram.git
synced 2025-08-07 14:47:49 +02:00
Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
c7fa54e90e
|
|||
9164ba494f
|
|||
97989c3384
|
|||
7865bf04f0
|
|||
e6f1480894
|
|||
8d8ede4c06
|
|||
87e1107156 | |||
448ecae070
|
|||
2b0fdc4487
|
|||
764240d67a
|
|||
424b17ae58
|
|||
c73efb01e4 | |||
a21baac10c
|
2
.github/workflows/django.yml
vendored
2
.github/workflows/django.yml
vendored
@@ -13,7 +13,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
max-parallel: 2
|
max-parallel: 2
|
||||||
matrix:
|
matrix:
|
||||||
python-version: ['3.9', '3.10', '3.11']
|
python-version: ['3.9', '3.10', '3.11', '3.12']
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
@@ -0,0 +1,20 @@
|
|||||||
|
# Generated by Django 4.2.6 on 2023-10-09 21:08
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
dependencies = [
|
||||||
|
("bookshelf", "0007_alter_book_options"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterModelOptions(
|
||||||
|
name="author",
|
||||||
|
options={"ordering": ["last_name", "first_name"]},
|
||||||
|
),
|
||||||
|
migrations.AlterModelOptions(
|
||||||
|
name="publisher",
|
||||||
|
options={"ordering": ["name"]},
|
||||||
|
),
|
||||||
|
]
|
@@ -16,6 +16,9 @@ class Publisher(models.Model):
|
|||||||
country = CountryField(blank=True)
|
country = CountryField(blank=True)
|
||||||
website = models.URLField(blank=True)
|
website = models.URLField(blank=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
ordering = ["name"]
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
@@ -24,6 +27,9 @@ class Author(models.Model):
|
|||||||
first_name = models.CharField(max_length=100)
|
first_name = models.CharField(max_length=100)
|
||||||
last_name = models.CharField(max_length=100)
|
last_name = models.CharField(max_length=100)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
ordering = ["last_name", "first_name"]
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.last_name}, {self.first_name}"
|
return f"{self.last_name}, {self.first_name}"
|
||||||
|
|
||||||
|
@@ -15,6 +15,7 @@ from metadata.models import (
|
|||||||
|
|
||||||
@admin.register(Property)
|
@admin.register(Property)
|
||||||
class PropertyAdmin(admin.ModelAdmin):
|
class PropertyAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ("name", "private")
|
||||||
search_fields = ("name",)
|
search_fields = ("name",)
|
||||||
|
|
||||||
|
|
||||||
|
18
ram/metadata/migrations/0013_decoderdocument_private.py
Normal file
18
ram/metadata/migrations/0013_decoderdocument_private.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 4.2.5 on 2023-10-06 19:48
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("metadata", "0012_alter_decoder_manufacturer_decoderdocument"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="decoderdocument",
|
||||||
|
name="private",
|
||||||
|
field=models.BooleanField(default=False),
|
||||||
|
),
|
||||||
|
]
|
@@ -0,0 +1,20 @@
|
|||||||
|
# Generated by Django 4.2.6 on 2023-10-10 12:44
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
dependencies = [
|
||||||
|
("metadata", "0013_decoderdocument_private"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterModelOptions(
|
||||||
|
name="decoder",
|
||||||
|
options={"ordering": ["manufacturer", "name"]},
|
||||||
|
),
|
||||||
|
migrations.AlterModelOptions(
|
||||||
|
name="tag",
|
||||||
|
options={"ordering": ["name"]},
|
||||||
|
),
|
||||||
|
]
|
@@ -95,6 +95,9 @@ class Decoder(models.Model):
|
|||||||
upload_to="images/", storage=DeduplicatedStorage, null=True, blank=True
|
upload_to="images/", storage=DeduplicatedStorage, null=True, blank=True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
class Meta(object):
|
||||||
|
ordering = ["manufacturer", "name"]
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "{0} - {1}".format(self.manufacturer, self.name)
|
return "{0} - {1}".format(self.manufacturer, self.name)
|
||||||
|
|
||||||
@@ -163,6 +166,9 @@ class Tag(models.Model):
|
|||||||
name = models.CharField(max_length=128, unique=True)
|
name = models.CharField(max_length=128, unique=True)
|
||||||
slug = models.CharField(max_length=128, unique=True)
|
slug = models.CharField(max_length=128, unique=True)
|
||||||
|
|
||||||
|
class Meta(object):
|
||||||
|
ordering = ["name"]
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
@@ -66,7 +66,6 @@ class Flatpage(models.Model):
|
|||||||
return reverse("flatpage", kwargs={"flatpage": self.path})
|
return reverse("flatpage", kwargs={"flatpage": self.path})
|
||||||
|
|
||||||
def get_link(self):
|
def get_link(self):
|
||||||
if self.published:
|
|
||||||
return mark_safe(
|
return mark_safe(
|
||||||
'<a href="{0}" target="_blank">Link</a>'.format(
|
'<a href="{0}" target="_blank">Link</a>'.format(
|
||||||
self.get_absolute_url()
|
self.get_absolute_url()
|
||||||
|
@@ -7,6 +7,16 @@ html[data-bs-theme='dark'] .navbar svg {
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
td > img.logo {
|
||||||
|
max-width: 200px;
|
||||||
|
max-height: 48px;
|
||||||
|
}
|
||||||
|
|
||||||
|
td > img.logo-xl {
|
||||||
|
max-width: 400px;
|
||||||
|
max-height: 96px;
|
||||||
|
}
|
||||||
|
|
||||||
.btn > span {
|
.btn > span {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
@@ -121,7 +121,7 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<header>
|
<header>
|
||||||
<nav class="navbar navbar-expand-lg bg-body-tertiary shadow-sm">
|
<nav class="navbar navbar-expand-sm bg-body-tertiary shadow-sm">
|
||||||
<div class="container d-flex">
|
<div class="container d-flex">
|
||||||
<div class="me-auto">
|
<div class="me-auto">
|
||||||
<a href="{% url 'index' %}" class="navbar-brand d-flex align-items-center">
|
<a href="{% url 'index' %}" class="navbar-brand d-flex align-items-center">
|
||||||
@@ -146,29 +146,30 @@
|
|||||||
<nav class="navbar navbar-expand-lg">
|
<nav class="navbar navbar-expand-lg">
|
||||||
<div class="container-fluid g-0">
|
<div class="container-fluid g-0">
|
||||||
<a class="navbar-brand" href="{% url 'index' %}">Home</a>
|
<a class="navbar-brand" href="{% url 'index' %}">Home</a>
|
||||||
<div class="navbar-collapse" id="navbarSupportedContent">
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||||
<li class="nav-item dropdown">
|
<li class="nav-item">
|
||||||
<a class="nav-link dropdown-toggle" href="#" id="rosterDropdownMenu" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
<a class="nav-link" href="{% url 'roster' %}">Roster</a>
|
||||||
Roster
|
|
||||||
</a>
|
|
||||||
<ul class="dropdown-menu" aria-labelledby="rosterDropdownMenu">
|
|
||||||
<li><a class="dropdown-item" href="{% url 'roster' %}">Rolling stock</a></li>
|
|
||||||
<li><a class="dropdown-item" href="{% url 'companies' %}">Companies</a></li>
|
|
||||||
<li><a class="dropdown-item" href="{% url 'types' %}">Types</a></li>
|
|
||||||
<li><a class="dropdown-item" href="{% url 'scales' %}">Scales</a></li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="{% url 'consists' %}">Consists</a>
|
<a class="nav-link" href="{% url 'consists' %}">Consists</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item dropdown">
|
<li class="nav-item dropdown">
|
||||||
<a class="nav-link dropdown-toggle" href="#" id="manufacturersDropdownMenu" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
<a class="nav-link dropdown-toggle" href="#" id="filterDropdownMenu" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||||
Manufacturers
|
Search by
|
||||||
</a>
|
</a>
|
||||||
<ul class="dropdown-menu" aria-labelledby="manufacturersDropdownMenu">
|
<ul class="dropdown-menu" aria-labelledby="filterDropdownMenu">
|
||||||
<li><a class="dropdown-item" href="{% url 'manufacturers' category='model' %}">Models</a></li>
|
<li class="ps-2 text-secondary">Model</li>
|
||||||
<li><a class="dropdown-item" href="{% url 'manufacturers' category='real' %}">Real</a></li>
|
<li><a class="dropdown-item" href="{% url 'scales' %}">Scale</a></li>
|
||||||
|
<li><a class="dropdown-item" href="{% url 'manufacturers' category='model' %}">Manufacturer</a></li>
|
||||||
|
<li><hr class="dropdown-divider"></li>
|
||||||
|
<li class="ps-2 text-secondary">Prototype</li>
|
||||||
|
<li><a class="dropdown-item" href="{% url 'types' %}">Type</a></li>
|
||||||
|
<li><a class="dropdown-item" href="{% url 'companies' %}">Company</a></li>
|
||||||
|
<li><a class="dropdown-item" href="{% url 'manufacturers' category='real' %}">Manufacturer</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
{% show_bookshelf_menu %}
|
{% show_bookshelf_menu %}
|
||||||
|
@@ -3,11 +3,11 @@
|
|||||||
<p class="lead text-muted">Results found: {{ matches }}</p>
|
<p class="lead text-muted">Results found: {{ matches }}</p>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block cards_layout %}
|
{% block cards_layout %}
|
||||||
<div class="row row-cols-1 row-cols-sm-2 row-cols-md-3 g-3">
|
<div class="row row-cols-1 row-cols-md-2 row-cols-lg-3 g-3">
|
||||||
{% block cards %}
|
{% block cards %}
|
||||||
{% for d in data %}
|
{% for d in data %}
|
||||||
{% if d.type == "rolling_stock" %}
|
{% if d.type == "rolling_stock" %}
|
||||||
{% include "cards/rolling_stock.html" %}
|
{% include "cards/roster.html" %}
|
||||||
{% elif d.type == "company" %}
|
{% elif d.type == "company" %}
|
||||||
{% include "cards/company.html" %}
|
{% include "cards/company.html" %}
|
||||||
{% elif d.type == "rolling_stock_type" %}
|
{% elif d.type == "rolling_stock_type" %}
|
||||||
|
@@ -1,11 +1,7 @@
|
|||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="card shadow-sm">
|
<div class="card shadow-sm">
|
||||||
{% if d.item.image.all %}
|
{% if d.item.image.exists %}
|
||||||
<a href="{{ d.item.get_absolute_url }}">
|
<a href="{{d.item.get_absolute_url}}"><img class="card-img-top" src="{{ d.item.image.first.image.url }}" alt="{{ d }}"></a>
|
||||||
{% for r in d.item.image.all %}
|
|
||||||
{% if forloop.first %}<img src="{{ r.image.url }}" alt="Card image cap">{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<p class="card-text" style="position: relative;">
|
<p class="card-text" style="position: relative;">
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
{% if d.item.logo %}
|
{% if d.item.logo %}
|
||||||
<tr>
|
<tr>
|
||||||
<th class="w-33" scope="row">Logo</th>
|
<th class="w-33" scope="row">Logo</th>
|
||||||
<td><img style="max-height: 48px" src="{{ d.item.logo.url }}" /></td>
|
<td><img class="logo" src="{{ d.item.logo.url }}" /></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<tr>
|
<tr>
|
||||||
|
@@ -2,12 +2,10 @@
|
|||||||
<div class="card shadow-sm">
|
<div class="card shadow-sm">
|
||||||
<a href="{{ d.item.get_absolute_url }}">
|
<a href="{{ d.item.get_absolute_url }}">
|
||||||
{% if d.item.image %}
|
{% if d.item.image %}
|
||||||
<img src="{{ d.item.image.url }}" alt="Card image cap">
|
<img class="card-img-top" src="{{ d.item.image.url }}" alt="{{ d }}">
|
||||||
{% else %}
|
{% else %}
|
||||||
{% with d.item.consist_item.first.rolling_stock as r %}
|
{% with d.item.consist_item.first.rolling_stock as r %}
|
||||||
{% for i in r.image.all %}
|
<img class="card-img-top" src="{{ r.image.first.image.url }}" alt="{{ d }}"></a>
|
||||||
{% if forloop.first %}<img src="{{ i.image.url }}" alt="Card image cap">{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</a>
|
</a>
|
||||||
@@ -26,7 +24,7 @@
|
|||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="2" scope="row">Consist data</th>
|
<th colspan="2" scope="row">Consist</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="table-group-divider">
|
<tbody class="table-group-divider">
|
||||||
@@ -46,7 +44,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Length</th>
|
<th scope="row">Length</th>
|
||||||
<td>{{ d.item.consist_item.all | length }}</td>
|
<td>{{ d.item.consist_item.count }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
{% if d.item.logo %}
|
{% if d.item.logo %}
|
||||||
<tr>
|
<tr>
|
||||||
<th class="w-33" scope="row">Logo</th>
|
<th class="w-33" scope="row">Logo</th>
|
||||||
<td><img style="max-height: 48px" src="{{ d.item.logo.url }}" /></td>
|
<td><img class="logo" src="{{ d.item.logo.url }}" /></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if d.item.website %}
|
{% if d.item.website %}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
{% load static %}
|
{% load static %}
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="card shadow-sm">
|
<div class="card shadow-sm">
|
||||||
{% if d.item.image.count > 0 %}
|
{% if d.item.image.exists %}
|
||||||
<a href="{{d.item.get_absolute_url}}"><img class="card-img-top" src="{{ d.item.image.first.image.url }}" alt="{{ d }}"></a>
|
<a href="{{d.item.get_absolute_url}}"><img class="card-img-top" src="{{ d.item.image.first.image.url }}" alt="{{ d }}"></a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<!-- Do not show the "Coming soon" image when running in a single card column mode (e.g. on mobile) -->
|
<!-- Do not show the "Coming soon" image when running in a single card column mode (e.g. on mobile) -->
|
@@ -81,7 +81,9 @@
|
|||||||
<tbody class="table-group-divider">
|
<tbody class="table-group-divider">
|
||||||
<tr>
|
<tr>
|
||||||
<th class="w-33" scope="row">Company</th>
|
<th class="w-33" scope="row">Company</th>
|
||||||
<td><abbr title="{{ consist.company.extended_name }}">{{ consist.company }}</abbr></td>
|
<td>
|
||||||
|
<a href="{% url 'filtered' _filter="company" search=consist.company.slug %}">{{ consist.company }}</a> ({{ consist.company.extended_name }})
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Era</th>
|
<th scope="row">Era</th>
|
||||||
|
@@ -1,4 +1,7 @@
|
|||||||
<div class="navbar-collapse justify-content-end" id="loginNavbar">
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#loginNavbar" aria-controls="loginNavbar" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="bi bi-person-fill-gear"></span>
|
||||||
|
</button>
|
||||||
|
<div class="collapse navbar-collapse justify-content-end" id="loginNavbar">
|
||||||
<ul class="navbar-nav">
|
<ul class="navbar-nav">
|
||||||
<li class="nav-item dropdown">
|
<li class="nav-item dropdown">
|
||||||
{% if request.user.is_staff %}
|
{% if request.user.is_staff %}
|
||||||
@@ -14,7 +17,6 @@
|
|||||||
<li><hr class="dropdown-divider"></li>
|
<li><hr class="dropdown-divider"></li>
|
||||||
<li><a class="dropdown-item" href="{% url 'admin:index' %}">Admin</a></li>
|
<li><a class="dropdown-item" href="{% url 'admin:index' %}">Admin</a></li>
|
||||||
<li><a class="dropdown-item" href="{% url 'admin:portal_siteconfiguration_changelist' %}">Site configuration</a></li>
|
<li><a class="dropdown-item" href="{% url 'admin:portal_siteconfiguration_changelist' %}">Site configuration</a></li>
|
||||||
<li><a class="dropdown-item" href="{% url 'admin:driver_driverconfiguration_changelist' %}">DCC configuration</a></li>
|
|
||||||
<li><hr class="dropdown-divider"></li>
|
<li><hr class="dropdown-divider"></li>
|
||||||
<li><a class="dropdown-item text-danger" href="{% url 'admin:logout' %}?next={{ request.path }}">Logout</a></li>
|
<li><a class="dropdown-item text-danger" href="{% url 'admin:logout' %}?next={{ request.path }}">Logout</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@@ -45,13 +45,16 @@
|
|||||||
<div class="mx-auto">
|
<div class="mx-auto">
|
||||||
<nav class="nav nav-tabs flex-column flex-md-row mb-2" id="nav-tab">
|
<nav class="nav nav-tabs flex-column flex-md-row mb-2" id="nav-tab">
|
||||||
<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>
|
<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>
|
||||||
<button class="nav-link" id="nav-model-tab" data-bs-toggle="tab" data-bs-target="#nav-model" type="button" role="tab" aria-controls="nav-model" aria-selected="false">Model data</button>
|
<button class="nav-link" id="nav-model-tab" data-bs-toggle="tab" data-bs-target="#nav-model" type="button" role="tab" aria-controls="nav-model" aria-selected="false">Model</button>
|
||||||
<button class="nav-link" id="nav-class-tab" data-bs-toggle="tab" data-bs-target="#nav-class" type="button" role="tab" aria-controls="nav-class" aria-selected="false">Class data</button>
|
<button class="nav-link" id="nav-class-tab" data-bs-toggle="tab" data-bs-target="#nav-class" type="button" role="tab" aria-controls="nav-class" aria-selected="false">Class</button>
|
||||||
|
<button class="nav-link" id="nav-company-tab" data-bs-toggle="tab" data-bs-target="#nav-company" type="button" role="tab" aria-controls="nav-company" aria-selected="false">Company</button>
|
||||||
{% if rolling_stock.decoder %}<button class="nav-link" id="nav-dcc-tab" data-bs-toggle="tab" data-bs-target="#nav-dcc" type="button" role="tab" aria-controls="nav-dcc" aria-selected="false">DCC</button>{% endif %}
|
{% if rolling_stock.decoder %}<button class="nav-link" id="nav-dcc-tab" data-bs-toggle="tab" data-bs-target="#nav-dcc" type="button" role="tab" aria-controls="nav-dcc" aria-selected="false">DCC</button>{% endif %}
|
||||||
{% if rolling_stock.document.count > 0 or rolling_stock.decoder.document.count > 0 %}<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 documents or decoder_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 rolling_stock_journal.count > 0 %}<button class="nav-link" id="nav-journal-tab" data-bs-toggle="tab" data-bs-target="#nav-journal" type="button" role="tab" aria-controls="nav-journal" aria-selected="false">Journal</button>{% endif %}
|
{% if journal %}<button class="nav-link" id="nav-journal-tab" data-bs-toggle="tab" data-bs-target="#nav-journal" type="button" role="tab" aria-controls="nav-journal" aria-selected="false">Journal</button>{% endif %}
|
||||||
{% if rolling_stock.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 %}
|
{% if rolling_stock.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 %}
|
||||||
|
{% if consists %}<button class="nav-link" id="nav-consists-tab" data-bs-toggle="tab" data-bs-target="#nav-consists" type="button" role="tab" aria-controls="nav-consists" aria-selected="false">Consists</button>{% endif %}
|
||||||
</nav>
|
</nav>
|
||||||
|
{% with class=rolling_stock.rolling_class company=rolling_stock.rolling_class.company %}
|
||||||
<div class="tab-content" id="nav-tabContent">
|
<div class="tab-content" id="nav-tabContent">
|
||||||
<div class="tab-pane show active" id="nav-summary" role="tabpanel" aria-labelledby="nav-summary-tab">
|
<div class="tab-pane show active" id="nav-summary" role="tabpanel" aria-labelledby="nav-summary-tab">
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
@@ -63,17 +66,17 @@
|
|||||||
<tbody class="table-group-divider">
|
<tbody class="table-group-divider">
|
||||||
<tr>
|
<tr>
|
||||||
<th class="w-33" scope="row">Type</th>
|
<th class="w-33" scope="row">Type</th>
|
||||||
<td>{{ rolling_stock.rolling_class.type }}</td>
|
<td>{{ class.type }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Company</th>
|
<th scope="row">Company</th>
|
||||||
<td>
|
<td>
|
||||||
<a href="{% url 'filtered' _filter="company" search=rolling_stock.rolling_class.company.slug %}"><abbr title="{{ rolling_stock.rolling_class.company.extended_name }}">{{ rolling_stock.rolling_class.company }}</abbr></a>
|
<a href="{% url 'filtered' _filter="company" search=company.slug %}">{{ company }}</a> ({{ company.extended_name }})
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Class</th>
|
<th scope="row">Class</th>
|
||||||
<td>{{ rolling_stock.rolling_class.identifier }}</td>
|
<td>{{ class.identifier }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Road number</th>
|
<th scope="row">Road number</th>
|
||||||
@@ -170,7 +173,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{% if rolling_stock_properties %}
|
{% if properties %}
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -178,7 +181,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="table-group-divider">
|
<tbody class="table-group-divider">
|
||||||
{% for p in rolling_stock_properties %}
|
{% for p in properties %}
|
||||||
<tr>
|
<tr>
|
||||||
<th class="w-33" scope="row">{{ p.property }}</th>
|
<th class="w-33" scope="row">{{ p.property }}</th>
|
||||||
<td>{{ p.value }}</td>
|
<td>{{ p.value }}</td>
|
||||||
@@ -198,26 +201,16 @@
|
|||||||
<tbody class="table-group-divider">
|
<tbody class="table-group-divider">
|
||||||
<tr>
|
<tr>
|
||||||
<th class="w-33" scope="row">Class</th>
|
<th class="w-33" scope="row">Class</th>
|
||||||
<td>{{ rolling_stock.rolling_class.identifier }}</td>
|
<td>{{ class.identifier }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Type</th>
|
<th scope="row">Type</th>
|
||||||
<td>{{ rolling_stock.rolling_class.type }}</td>
|
<td>{{ class.type }}</td>
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th scope="row">Company</th>
|
|
||||||
<td>
|
|
||||||
<a href="{% url 'filtered' _filter="company" search=rolling_stock.rolling_class.company.slug %}">{{ rolling_stock.rolling_class.company }}</a> ({{ rolling_stock.rolling_class.company.extended_name }})
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th scope="row">Country</th>
|
|
||||||
<td>{{ rolling_stock.rolling_class.company.country.name }}</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Manufacturer</th>
|
<th scope="row">Manufacturer</th>
|
||||||
<td>{%if rolling_stock.rolling_class.manufacturer %}
|
<td>{%if class.manufacturer %}
|
||||||
<a href="{% url 'filtered' _filter="manufacturer" search=rolling_stock.rolling_class.manufacturer.slug %}">{{ rolling_stock.rolling_class.manufacturer }}{% if rolling_stock.rolling_class.manufacturer.website %}</a> <a href="{{ rolling_stock.rolling_class.manufacturer.website }}" target="_blank"><i class="bi bi-box-arrow-up-right"></i></a>{% endif %}
|
<a href="{% url 'filtered' _filter="manufacturer" search=class.manufacturer.slug %}">{{ class.manufacturer }}{% if class.manufacturer.website %}</a> <a href="{{ class.manufacturer.website }}" target="_blank"><i class="bi bi-box-arrow-up-right"></i></a>{% endif %}
|
||||||
{% endif %}</td>
|
{% endif %}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
@@ -240,11 +233,42 @@
|
|||||||
</table>
|
</table>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
<div class="tab-pane" id="nav-company" role="tabpanel" aria-labelledby="nav-company-tab">
|
||||||
|
<table class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th colspan="2" scope="row">Company data</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody class="table-group-divider">
|
||||||
|
{% if company.logo %}
|
||||||
|
<tr>
|
||||||
|
<th class="w-33" scope="row">Logo</th>
|
||||||
|
<td><img class="logo-xl" src="{{ company.logo.url }}" /></td>
|
||||||
|
</tr>
|
||||||
|
{% endif %}
|
||||||
|
<tr>
|
||||||
|
<th class="w-33" scope="row">Name</th>
|
||||||
|
<td><a href="{% url 'filtered' _filter="company" search=company.slug %}">{{ company.name }}</a> ({{ company.extended_name }})</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th class="w-33" scope="row">Country</th>
|
||||||
|
<td>{{ company.country.name }} <img src="{{ company.country.flag }}" alt="{{ company.country }}" />
|
||||||
|
</tr>
|
||||||
|
{% if company.freelance %}
|
||||||
|
<tr>
|
||||||
|
<th class="w-33" scope="row">Notes</th>
|
||||||
|
<td>A <em>freelance</em> company</td>
|
||||||
|
</tr>
|
||||||
|
{% endif %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
<div class="tab-pane" id="nav-dcc" role="tabpanel" aria-labelledby="nav-dcc-tab">
|
<div class="tab-pane" id="nav-dcc" role="tabpanel" aria-labelledby="nav-dcc-tab">
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="2" scope="row">DCC data</th>
|
<th colspan="2" scope="row">Decoder data</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="table-group-divider">
|
<tbody class="table-group-divider">
|
||||||
@@ -276,7 +300,7 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="tab-pane" id="nav-documents" role="tabpanel" aria-labelledby="nav-documents-tab">
|
<div class="tab-pane" id="nav-documents" role="tabpanel" aria-labelledby="nav-documents-tab">
|
||||||
{% if rolling_stock.document.count > 0 %}
|
{% if documents %}
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -284,7 +308,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="table-group-divider">
|
<tbody class="table-group-divider">
|
||||||
{% for d in rolling_stock.document.all %}
|
{% for d in documents.all %}
|
||||||
<tr>
|
<tr>
|
||||||
<td class="w-33">{{ d.description }}</td>
|
<td class="w-33">{{ d.description }}</td>
|
||||||
<td><a href="{{ d.file.url }}" target="_blank">{{ d.filename }}</a></td>
|
<td><a href="{{ d.file.url }}" target="_blank">{{ d.filename }}</a></td>
|
||||||
@@ -294,7 +318,7 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if rolling_stock.decoder.document.count > 0 %}
|
{% if decoder_documents %}
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -302,7 +326,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="table-group-divider">
|
<tbody class="table-group-divider">
|
||||||
{% for d in rolling_stock.decoder.document.all %}
|
{% for d in decoder_documents.all %}
|
||||||
<tr>
|
<tr>
|
||||||
<td class="w-33">{{ d.description }}</td>
|
<td class="w-33">{{ d.description }}</td>
|
||||||
<td><a href="{{ d.file.url }}" target="_blank">{{ d.filename }}</a></td>
|
<td><a href="{{ d.file.url }}" target="_blank">{{ d.filename }}</a></td>
|
||||||
@@ -321,7 +345,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="table-group-divider">
|
<tbody class="table-group-divider">
|
||||||
{% for j in rolling_stock_journal %}
|
{% for j in journal %}
|
||||||
<tr>
|
<tr>
|
||||||
<th class="w-33" scope="row">{{ j.date }}</th>
|
<th class="w-33" scope="row">{{ j.date }}</th>
|
||||||
<td>{{ j.log | safe }}</a></td>
|
<td>{{ j.log | safe }}</a></td>
|
||||||
@@ -333,7 +357,15 @@
|
|||||||
<div class="tab-pane" id="nav-notes" role="tabpanel" aria-labelledby="nav-notes-tab">
|
<div class="tab-pane" id="nav-notes" role="tabpanel" aria-labelledby="nav-notes-tab">
|
||||||
{{ rolling_stock.notes | safe }}
|
{{ rolling_stock.notes | safe }}
|
||||||
</div>
|
</div>
|
||||||
|
<div class="tab-pane" id="nav-consists" role="tabpanel" aria-labelledby="nav-cosists-tab">
|
||||||
|
<div class="row row-cols-1 row-cols-md-2 row-cols-lg-3 g-3 mb-3">
|
||||||
|
{% for d in consists %}
|
||||||
|
{% include "cards/consist.html" %}
|
||||||
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endwith %}
|
||||||
<div class="d-grid gap-2 d-md-flex justify-content-md-end">
|
<div class="d-grid gap-2 d-md-flex justify-content-md-end">
|
||||||
{% if request.user.is_staff %}<a class="btn btn-sm btn-outline-danger" href="{% url 'admin:roster_rollingstock_change' rolling_stock.pk %}">Edit</a>{% endif %}
|
{% if request.user.is_staff %}<a class="btn btn-sm btn-outline-danger" href="{% url 'admin:roster_rollingstock_change' rolling_stock.pk %}">Edit</a>{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
<ul class="pagination justify-content-center mt-4 mb-0">
|
<ul class="pagination justify-content-center mt-4 mb-0">
|
||||||
{% if data.has_previous %}
|
{% if data.has_previous %}
|
||||||
<li class="page-item">
|
<li class="page-item">
|
||||||
<a class="page-link" href="{% url 'scales_pagination' page=data.previous_page_number %}#main-content" tabindex="-1">Previous</a>
|
<a class="page-link" href="{% url 'types_pagination' page=data.previous_page_number %}#main-content" tabindex="-1">Previous</a>
|
||||||
</li>
|
</li>
|
||||||
{% else %}
|
{% else %}
|
||||||
<li class="page-item disabled">
|
<li class="page-item disabled">
|
||||||
@@ -21,13 +21,13 @@
|
|||||||
{% if i == data.paginator.ELLIPSIS %}
|
{% if i == data.paginator.ELLIPSIS %}
|
||||||
<li class="page-item"><span class="page-link">{{ i }}</span></li>
|
<li class="page-item"><span class="page-link">{{ i }}</span></li>
|
||||||
{% else %}
|
{% else %}
|
||||||
<li class="page-item"><a class="page-link" href="{% url 'scales_pagination' page=i %}#main-content">{{ i }}</a></li>
|
<li class="page-item"><a class="page-link" href="{% url 'types_pagination' page=i %}#main-content">{{ i }}</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% if data.has_next %}
|
{% if data.has_next %}
|
||||||
<li class="page-item">
|
<li class="page-item">
|
||||||
<a class="page-link" href="{% url 'scales_pagination' page=data.next_page_number %}#main-content" tabindex="-1">Next</a>
|
<a class="page-link" href="{% url 'types_pagination' page=data.next_page_number %}#main-content" tabindex="-1">Next</a>
|
||||||
</li>
|
</li>
|
||||||
{% else %}
|
{% else %}
|
||||||
<li class="page-item disabled">
|
<li class="page-item disabled">
|
||||||
|
@@ -3,7 +3,7 @@ from django.urls import path
|
|||||||
from portal.views import (
|
from portal.views import (
|
||||||
GetData,
|
GetData,
|
||||||
GetRoster,
|
GetRoster,
|
||||||
GetRosterFiltered,
|
GetObjectsFiltered,
|
||||||
GetFlatpage,
|
GetFlatpage,
|
||||||
GetRollingStock,
|
GetRollingStock,
|
||||||
GetConsist,
|
GetConsist,
|
||||||
@@ -14,7 +14,7 @@ from portal.views import (
|
|||||||
Types,
|
Types,
|
||||||
Books,
|
Books,
|
||||||
GetBook,
|
GetBook,
|
||||||
SearchRoster,
|
SearchObjects,
|
||||||
)
|
)
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
@@ -26,9 +26,15 @@ urlpatterns = [
|
|||||||
GetFlatpage.as_view(),
|
GetFlatpage.as_view(),
|
||||||
name="flatpage",
|
name="flatpage",
|
||||||
),
|
),
|
||||||
path("consists", Consists.as_view(), name="consists"),
|
|
||||||
path(
|
path(
|
||||||
"consists/<int:page>", Consists.as_view(), name="consists_pagination"
|
"consists",
|
||||||
|
Consists.as_view(template="consists.html"),
|
||||||
|
name="consists"
|
||||||
|
),
|
||||||
|
path(
|
||||||
|
"consists/<int:page>",
|
||||||
|
Consists.as_view(template="consists.html"),
|
||||||
|
name="consists_pagination"
|
||||||
),
|
),
|
||||||
path("consist/<uuid:uuid>", GetConsist.as_view(), name="consist"),
|
path("consist/<uuid:uuid>", GetConsist.as_view(), name="consist"),
|
||||||
path(
|
path(
|
||||||
@@ -89,22 +95,22 @@ urlpatterns = [
|
|||||||
path("bookshelf/book/<uuid:uuid>", GetBook.as_view(), name="book"),
|
path("bookshelf/book/<uuid:uuid>", GetBook.as_view(), name="book"),
|
||||||
path(
|
path(
|
||||||
"search",
|
"search",
|
||||||
SearchRoster.as_view(http_method_names=["post"]),
|
SearchObjects.as_view(http_method_names=["post"]),
|
||||||
name="search",
|
name="search",
|
||||||
),
|
),
|
||||||
path(
|
path(
|
||||||
"search/<str:search>/<int:page>",
|
"search/<str:search>/<int:page>",
|
||||||
SearchRoster.as_view(),
|
SearchObjects.as_view(),
|
||||||
name="search_pagination",
|
name="search_pagination",
|
||||||
),
|
),
|
||||||
path(
|
path(
|
||||||
"<str:_filter>/<str:search>",
|
"<str:_filter>/<str:search>",
|
||||||
GetRosterFiltered.as_view(),
|
GetObjectsFiltered.as_view(),
|
||||||
name="filtered",
|
name="filtered",
|
||||||
),
|
),
|
||||||
path(
|
path(
|
||||||
"<str:_filter>/<str:search>/<int:page>",
|
"<str:_filter>/<str:search>/<int:page>",
|
||||||
GetRosterFiltered.as_view(),
|
GetObjectsFiltered.as_view(),
|
||||||
name="filtered_pagination",
|
name="filtered_pagination",
|
||||||
),
|
),
|
||||||
path("<uuid:uuid>", GetRollingStock.as_view(), name="rolling_stock"),
|
path("<uuid:uuid>", GetRollingStock.as_view(), name="rolling_stock"),
|
||||||
|
@@ -5,6 +5,7 @@ from urllib.parse import unquote
|
|||||||
|
|
||||||
from django.views import View
|
from django.views import View
|
||||||
from django.http import Http404, HttpResponseBadRequest
|
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
|
||||||
from django.shortcuts import render, get_object_or_404
|
from django.shortcuts import render, get_object_or_404
|
||||||
from django.core.exceptions import ObjectDoesNotExist
|
from django.core.exceptions import ObjectDoesNotExist
|
||||||
@@ -15,11 +16,17 @@ from portal.models import Flatpage
|
|||||||
from roster.models import RollingStock
|
from roster.models import RollingStock
|
||||||
from consist.models import Consist
|
from consist.models import Consist
|
||||||
from bookshelf.models import Book
|
from bookshelf.models import Book
|
||||||
from metadata.models import Company, Manufacturer, Scale, RollingStockType, Tag
|
from metadata.models import (
|
||||||
|
Company, Manufacturer, Scale, DecoderDocument, RollingStockType, Tag
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def order_by_fields():
|
def order_by_fields():
|
||||||
|
try:
|
||||||
order_by = get_site_conf().items_ordering
|
order_by = get_site_conf().items_ordering
|
||||||
|
except (OperationalError, ProgrammingError):
|
||||||
|
order_by = "type"
|
||||||
|
|
||||||
fields = [
|
fields = [
|
||||||
"rolling_class__type",
|
"rolling_class__type",
|
||||||
"rolling_class__company",
|
"rolling_class__company",
|
||||||
@@ -71,12 +78,12 @@ class GetData(View):
|
|||||||
|
|
||||||
|
|
||||||
class GetRoster(GetData):
|
class GetRoster(GetData):
|
||||||
title = "Rolling stock"
|
title = "Roster"
|
||||||
item_type = "rolling_stock"
|
item_type = "rolling_stock"
|
||||||
queryset = RollingStock.objects.order_by(*order_by_fields())
|
queryset = RollingStock.objects.order_by(*order_by_fields())
|
||||||
|
|
||||||
|
|
||||||
class SearchRoster(View):
|
class SearchObjects(View):
|
||||||
def run_search(self, request, search, _filter, page=1):
|
def run_search(self, request, search, _filter, page=1):
|
||||||
site_conf = get_site_conf()
|
site_conf = get_site_conf()
|
||||||
if _filter is None:
|
if _filter is None:
|
||||||
@@ -208,15 +215,17 @@ class SearchRoster(View):
|
|||||||
return self.get(request, search, page)
|
return self.get(request, search, page)
|
||||||
|
|
||||||
|
|
||||||
class GetRosterFiltered(View):
|
class GetObjectsFiltered(View):
|
||||||
def run_filter(self, request, search, _filter, page=1):
|
def run_filter(self, request, search, _filter, page=1):
|
||||||
site_conf = get_site_conf()
|
site_conf = get_site_conf()
|
||||||
|
|
||||||
if _filter == "type":
|
if _filter == "type":
|
||||||
title = RollingStockType.objects.get(slug__iexact=search)
|
title = get_object_or_404(RollingStockType, slug__iexact=search)
|
||||||
query = Q(rolling_class__type__slug__iexact=search)
|
query = Q(rolling_class__type__slug__iexact=search)
|
||||||
elif _filter == "company":
|
elif _filter == "company":
|
||||||
title = get_object_or_404(Company, slug__iexact=search)
|
title = get_object_or_404(Company, slug__iexact=search)
|
||||||
query = Q(rolling_class__company__slug__iexact=search)
|
query = Q(rolling_class__company__slug__iexact=search)
|
||||||
|
query_2nd = Q(company__slug__iexact=search)
|
||||||
elif _filter == "manufacturer":
|
elif _filter == "manufacturer":
|
||||||
title = get_object_or_404(Manufacturer, slug__iexact=search)
|
title = get_object_or_404(Manufacturer, slug__iexact=search)
|
||||||
query = Q(
|
query = Q(
|
||||||
@@ -226,9 +235,13 @@ class GetRosterFiltered(View):
|
|||||||
elif _filter == "scale":
|
elif _filter == "scale":
|
||||||
title = get_object_or_404(Scale, slug__iexact=search)
|
title = get_object_or_404(Scale, slug__iexact=search)
|
||||||
query = Q(scale__slug__iexact=search)
|
query = Q(scale__slug__iexact=search)
|
||||||
|
query_2nd = Q(
|
||||||
|
consist_item__rolling_stock__scale__slug__iexact=search
|
||||||
|
)
|
||||||
elif _filter == "tag":
|
elif _filter == "tag":
|
||||||
title = get_object_or_404(Tag, slug__iexact=search)
|
title = get_object_or_404(Tag, slug__iexact=search)
|
||||||
query = Q(tags__slug__iexact=search)
|
query = Q(tags__slug__iexact=search)
|
||||||
|
query_2nd = query # For tags the 2nd level query doesn't change
|
||||||
else:
|
else:
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
@@ -245,9 +258,9 @@ class GetRosterFiltered(View):
|
|||||||
"item": item
|
"item": item
|
||||||
})
|
})
|
||||||
|
|
||||||
if _filter == "tag":
|
try: # Execute only if query_2nd is defined
|
||||||
consists = (
|
consists = (
|
||||||
Consist.objects.filter(query)
|
Consist.objects.filter(query_2nd)
|
||||||
.distinct()
|
.distinct()
|
||||||
)
|
)
|
||||||
for item in consists:
|
for item in consists:
|
||||||
@@ -255,8 +268,9 @@ class GetRosterFiltered(View):
|
|||||||
"type": "consist",
|
"type": "consist",
|
||||||
"item": item
|
"item": item
|
||||||
})
|
})
|
||||||
|
if _filter == "tag": # Books can be filtered only by tag
|
||||||
books = (
|
books = (
|
||||||
Book.objects.filter(query)
|
Book.objects.filter(query_2nd)
|
||||||
.distinct()
|
.distinct()
|
||||||
)
|
)
|
||||||
for item in books:
|
for item in books:
|
||||||
@@ -264,6 +278,8 @@ class GetRosterFiltered(View):
|
|||||||
"type": "book",
|
"type": "book",
|
||||||
"item": item
|
"item": item
|
||||||
})
|
})
|
||||||
|
except NameError:
|
||||||
|
pass
|
||||||
|
|
||||||
paginator = Paginator(data, site_conf.items_per_page)
|
paginator = Paginator(data, site_conf.items_per_page)
|
||||||
data = paginator.get_page(page)
|
data = paginator.get_page(page)
|
||||||
@@ -300,24 +316,36 @@ class GetRollingStock(View):
|
|||||||
except ObjectDoesNotExist:
|
except ObjectDoesNotExist:
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
class_properties = (
|
# FIXME there's likely a better and more efficient way of doing this
|
||||||
rolling_stock.rolling_class.property.all()
|
# but keeping KISS for now
|
||||||
if request.user.is_authenticated
|
decoder_documents = []
|
||||||
else rolling_stock.rolling_class.property.filter(
|
if request.user.is_authenticated:
|
||||||
|
class_properties = rolling_stock.rolling_class.property.all()
|
||||||
|
properties = rolling_stock.property.all()
|
||||||
|
documents = rolling_stock.document.all()
|
||||||
|
journal = rolling_stock.journal.all()
|
||||||
|
if rolling_stock.decoder:
|
||||||
|
decoder_documents = rolling_stock.decoder.document.all()
|
||||||
|
else:
|
||||||
|
class_properties = rolling_stock.rolling_class.property.filter(
|
||||||
property__private=False
|
property__private=False
|
||||||
)
|
)
|
||||||
|
properties = rolling_stock.property.filter(
|
||||||
|
property__private=False
|
||||||
)
|
)
|
||||||
rolling_stock_properties = (
|
documents = rolling_stock.document.filter(private=False)
|
||||||
rolling_stock.property.all()
|
journal = rolling_stock.journal.filter(private=False)
|
||||||
if request.user.is_authenticated
|
if rolling_stock.decoder:
|
||||||
else rolling_stock.property.filter(property__private=False)
|
decoder_documents = rolling_stock.decoder.document.filter(
|
||||||
|
private=False
|
||||||
)
|
)
|
||||||
|
|
||||||
rolling_stock_journal = (
|
consists = [{
|
||||||
rolling_stock.journal.all()
|
"type": "consist",
|
||||||
if request.user.is_authenticated
|
"item": c
|
||||||
else rolling_stock.journal.filter(private=False)
|
} for c in Consist.objects.filter(
|
||||||
)
|
consist_item__rolling_stock=rolling_stock
|
||||||
|
)] # A dict with "item" is required by the consists card
|
||||||
|
|
||||||
return render(
|
return render(
|
||||||
request,
|
request,
|
||||||
@@ -326,17 +354,19 @@ class GetRollingStock(View):
|
|||||||
"title": rolling_stock,
|
"title": rolling_stock,
|
||||||
"rolling_stock": rolling_stock,
|
"rolling_stock": rolling_stock,
|
||||||
"class_properties": class_properties,
|
"class_properties": class_properties,
|
||||||
"rolling_stock_properties": rolling_stock_properties,
|
"properties": properties,
|
||||||
"rolling_stock_journal": rolling_stock_journal,
|
"decoder_documents": decoder_documents,
|
||||||
|
"documents": documents,
|
||||||
|
"journal": journal,
|
||||||
|
"consists": consists,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class Consists(GetData):
|
class Consists(GetData):
|
||||||
def __init__(self):
|
title = "Consists"
|
||||||
self.title = "Consists"
|
item_type = "consist"
|
||||||
self.item_type = "consist"
|
queryset = Consist.objects.all()
|
||||||
self.queryset = Consist.objects.all()
|
|
||||||
|
|
||||||
|
|
||||||
class GetConsist(View):
|
class GetConsist(View):
|
||||||
@@ -431,10 +461,12 @@ class GetBook(View):
|
|||||||
|
|
||||||
class GetFlatpage(View):
|
class GetFlatpage(View):
|
||||||
def get(self, request, flatpage):
|
def get(self, request, flatpage):
|
||||||
|
_filter = Q(published=True) # Show only published pages
|
||||||
|
if request.user.is_authenticated:
|
||||||
|
_filter = Q() # Reset the filter if user is authenticated
|
||||||
|
|
||||||
try:
|
try:
|
||||||
flatpage = Flatpage.objects.get(
|
flatpage = Flatpage.objects.filter(_filter).get(path=flatpage)
|
||||||
Q(Q(path=flatpage) & Q(published=True))
|
|
||||||
)
|
|
||||||
except ObjectDoesNotExist:
|
except ObjectDoesNotExist:
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
from ram.utils import git_suffix
|
from ram.utils import git_suffix
|
||||||
|
|
||||||
__version__ = "0.6.1"
|
__version__ = "0.9.0"
|
||||||
__version__ += git_suffix(__file__)
|
__version__ += git_suffix(__file__)
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
# vim: syntax=python
|
# vim: syntax=python
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Django local_settings for ram project.
|
Example of changes suitable for production
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# SECURITY WARNING: keep the secret key used in production secret!
|
# SECURITY WARNING: keep the secret key used in production secret!
|
||||||
@@ -12,9 +13,23 @@ SECRET_KEY = (
|
|||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
DEBUG = False
|
DEBUG = False
|
||||||
|
|
||||||
|
# SECURITY WARNING: cache middlewares must be loaded before cookies one
|
||||||
|
MIDDLEWARE = [
|
||||||
|
"django.middleware.cache.UpdateCacheMiddleware",
|
||||||
|
"django.middleware.common.CommonMiddleware",
|
||||||
|
"django.middleware.cache.FetchFromCacheMiddleware",
|
||||||
|
] + settings.MIDDLEWARE
|
||||||
|
|
||||||
|
CACHES = {
|
||||||
|
"default": {
|
||||||
|
"BACKEND": "django.core.cache.backends.redis.RedisCache",
|
||||||
|
"LOCATION": "redis://127.0.0.1:6379",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CACHE_MIDDLEWARE_SECONDS = 300
|
||||||
STORAGE_DIR = BASE_DIR / "storage"
|
STORAGE_DIR = BASE_DIR / "storage"
|
||||||
ALLOWED_HOSTS = ["127.0.0.1"]
|
ALLOWED_HOSTS = ["127.0.0.1", "myhost"]
|
||||||
CSRF_TRUSTED_ORIGINS = ["https://myhost"]
|
CSRF_TRUSTED_ORIGINS = ["https://myhost"]
|
||||||
ROOT_URLCONF = "ram.urls"
|
|
||||||
STATIC_URL = "static/"
|
STATIC_URL = "static/"
|
||||||
MEDIA_URL = "media/"
|
MEDIA_URL = "media/"
|
||||||
|
@@ -14,6 +14,7 @@ class Document(models.Model):
|
|||||||
null=True,
|
null=True,
|
||||||
blank=True,
|
blank=True,
|
||||||
)
|
)
|
||||||
|
private = models.BooleanField(default=False)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
abstract = True
|
abstract = True
|
||||||
|
@@ -51,7 +51,7 @@ INSTALLED_APPS = [
|
|||||||
"rest_framework",
|
"rest_framework",
|
||||||
"ram",
|
"ram",
|
||||||
"portal",
|
"portal",
|
||||||
"driver",
|
# "driver",
|
||||||
"metadata",
|
"metadata",
|
||||||
"roster",
|
"roster",
|
||||||
"consist",
|
"consist",
|
||||||
|
@@ -13,6 +13,7 @@ Including another URLconf
|
|||||||
1. Import the include() function: from django.urls import include, path
|
1. Import the include() function: from django.urls import include, path
|
||||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||||
"""
|
"""
|
||||||
|
from django.apps import apps
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.shortcuts import redirect
|
from django.shortcuts import redirect
|
||||||
from django.conf.urls.static import static
|
from django.conf.urls.static import static
|
||||||
@@ -27,10 +28,15 @@ urlpatterns = [
|
|||||||
path("admin/", admin.site.urls),
|
path("admin/", admin.site.urls),
|
||||||
path("api/v1/consist/", include("consist.urls")),
|
path("api/v1/consist/", include("consist.urls")),
|
||||||
path("api/v1/roster/", include("roster.urls")),
|
path("api/v1/roster/", include("roster.urls")),
|
||||||
path("api/v1/dcc/", include("driver.urls")),
|
|
||||||
path("api/v1/bookshelf/", include("bookshelf.urls")),
|
path("api/v1/bookshelf/", include("bookshelf.urls")),
|
||||||
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||||
|
|
||||||
|
# Enable the "/dcc" routing only if the "driver" app is active
|
||||||
|
if apps.is_installed("driver"):
|
||||||
|
urlpatterns += [
|
||||||
|
path("api/v1/dcc/", include("driver.urls")),
|
||||||
|
]
|
||||||
|
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
from django.views.generic import TemplateView
|
from django.views.generic import TemplateView
|
||||||
from rest_framework.schemas import get_schema_view
|
from rest_framework.schemas import get_schema_view
|
||||||
@@ -54,3 +60,7 @@ if settings.DEBUG:
|
|||||||
name="openapi-schema",
|
name="openapi-schema",
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
if apps.is_installed("debug_toolbar"):
|
||||||
|
urlpatterns += [
|
||||||
|
path("__debug__/", include("debug_toolbar.urls")),
|
||||||
|
]
|
||||||
|
@@ -64,6 +64,7 @@ class RollingStockDocumentAdmin(admin.ModelAdmin):
|
|||||||
"__str__",
|
"__str__",
|
||||||
"rolling_stock",
|
"rolling_stock",
|
||||||
"description",
|
"description",
|
||||||
|
"private",
|
||||||
"download",
|
"download",
|
||||||
)
|
)
|
||||||
search_fields = (
|
search_fields = (
|
||||||
|
18
ram/roster/migrations/0019_rollingstockdocument_private.py
Normal file
18
ram/roster/migrations/0019_rollingstockdocument_private.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 4.2.5 on 2023-10-06 19:48
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("roster", "0018_rename_sku_rollingstock_item_number"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="rollingstockdocument",
|
||||||
|
name="private",
|
||||||
|
field=models.BooleanField(default=False),
|
||||||
|
),
|
||||||
|
]
|
@@ -1 +1,2 @@
|
|||||||
gunicorn
|
gunicorn
|
||||||
|
pylibmc
|
||||||
|
@@ -8,5 +8,8 @@ django-countries
|
|||||||
django-health-check
|
django-health-check
|
||||||
django-admin-sortable2
|
django-admin-sortable2
|
||||||
django-ckeditor
|
django-ckeditor
|
||||||
# psycopg2-binary
|
# Optional: # psycopg2-binary
|
||||||
pySerial
|
# Optional: # pySerial
|
||||||
|
# Required by django-countries and not always installed
|
||||||
|
# by default on modern venvs (like Python 3.12 on Fedora 39)
|
||||||
|
setuptools
|
||||||
|
Reference in New Issue
Block a user