mirror of
https://github.com/daniviga/django-ram.git
synced 2025-08-07 14:47:49 +02:00
Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
8e0a18d707
|
|||
46a2aa7011
|
|||
a176682615
|
|||
ad4591da04 | |||
2f2b96b2bb
|
|||
6cf3ad03cc | |||
2c5f0dcd6f
|
|||
3545824016 | |||
78f9faee5e
|
|||
6fbea294da
|
|||
35bdffdb3f
|
|||
dccf467d38 | |||
9dfa9172f4
|
|||
9279142a41
|
|||
aff1d20260
|
@@ -96,7 +96,8 @@ Browse to `http://localhost:8000`
|
||||
|
||||
The DCC++ EX connector exposes an Arduino board running DCC++ EX Command Station,
|
||||
connected via serial port, to the network, allowing commands to be sent via a
|
||||
TCP socket.
|
||||
TCP socket. A response generated by the DCC++ EX board is sent to all connected clients,
|
||||
providing synchronization between multiple clients (eg. multiple JMRI instances).
|
||||
|
||||
Its use is not needed when running DCC++ EX from a [WiFi](https://dcc-ex.com/get-started/wifi-setup.html) capable board (like when
|
||||
using an ESP8266 module or a [Mega+WiFi board](https://dcc-ex.com/advanced-setup/supported-microcontrollers/wifi-mega.html)).
|
||||
@@ -112,7 +113,7 @@ Settings may need to be customized based on your setup.
|
||||
```bash
|
||||
$ cd daemons
|
||||
$ podman build -t dcc/net-to-serial .
|
||||
$ podman run -d -p 2560:2560 dcc/net-to-serial
|
||||
$ podman run --group-add keep-groups --device /dev/ttyACM0 -p 2560:2560 dcc/net-to-serial
|
||||
```
|
||||
|
||||
### Manual setup
|
||||
|
Submodule arduino/CommandStation-EX updated: aca9c9c941...ff53b90034
Submodule arduino/arduino-cli updated: 76251df924...940c94573b
Submodule arduino/dcc-ex.github.io updated: d1e5c92c7b...57928e8729
@@ -1,4 +1,4 @@
|
||||
FROM python:3.10-alpine
|
||||
FROM python:3.11-alpine
|
||||
|
||||
RUN mkdir /opt/dcc && pip -q install pyserial
|
||||
ADD net-to-serial.py config.ini /opt/dcc
|
||||
|
3
daemons/README.md
Normal file
3
daemons/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
## DCC++ EX connector
|
||||
|
||||
See [README.md](../README.md)
|
@@ -2,6 +2,7 @@
|
||||
LogLevel = debug
|
||||
ListeningIP = 0.0.0.0
|
||||
ListeningPort = 2560
|
||||
MaxClients = 10
|
||||
|
||||
[Serial]
|
||||
# UNO
|
||||
|
@@ -1,6 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
import re
|
||||
import time
|
||||
import logging
|
||||
import serial
|
||||
import asyncio
|
||||
@@ -10,11 +9,15 @@ from pathlib import Path
|
||||
|
||||
|
||||
class SerialDaemon:
|
||||
connected_clients = set()
|
||||
|
||||
def __init__(self, config):
|
||||
self.ser = serial.Serial(
|
||||
config["Serial"]["Port"],
|
||||
timeout=int(config["Serial"]["Timeout"])/1000)
|
||||
timeout=int(config["Serial"]["Timeout"]) / 1000,
|
||||
)
|
||||
self.ser.baudrate = config["Serial"]["Baudrate"]
|
||||
self.max_clients = int(config["Daemon"]["MaxClients"])
|
||||
|
||||
def __del__(self):
|
||||
try:
|
||||
@@ -43,19 +46,32 @@ class SerialDaemon:
|
||||
|
||||
async def handle_echo(self, reader, writer):
|
||||
"""Process a request from socket and return the response"""
|
||||
while 1: # keep connection to client open
|
||||
data = await reader.read(100)
|
||||
if not data: # client has disconnected
|
||||
break
|
||||
logging.info(
|
||||
"Clients already connected: {} (max: {})".format(
|
||||
len(self.connected_clients),
|
||||
self.max_clients,
|
||||
)
|
||||
)
|
||||
|
||||
addr = writer.get_extra_info('peername')
|
||||
logging.info("Received {} from {}".format(data, addr[0]))
|
||||
|
||||
self.__write_serial(data)
|
||||
response = self.__read_serial()
|
||||
writer.write(response)
|
||||
await writer.drain()
|
||||
logging.info("Sent: {}".format(response))
|
||||
addr = writer.get_extra_info("peername")[0]
|
||||
if len(self.connected_clients) < self.max_clients:
|
||||
self.connected_clients.add(writer)
|
||||
while True: # keep connection to client open
|
||||
data = await reader.read(100)
|
||||
if not data: # client has disconnected
|
||||
break
|
||||
logging.info("Received {} from {}".format(data, addr))
|
||||
self.__write_serial(data)
|
||||
response = self.__read_serial()
|
||||
for client in self.connected_clients:
|
||||
client.write(response)
|
||||
await client.drain()
|
||||
logging.info("Sent: {}".format(response))
|
||||
self.connected_clients.remove(writer)
|
||||
else:
|
||||
logging.warning(
|
||||
"TooManyClients: client {} disconnected".format(addr)
|
||||
)
|
||||
|
||||
writer.close()
|
||||
await writer.wait_closed()
|
||||
@@ -68,33 +84,37 @@ class SerialDaemon:
|
||||
while "DCC-EX" not in line:
|
||||
line = self.__read_serial().decode()
|
||||
board = re.findall(r"<iDCC-EX.*>", line)[0]
|
||||
return(board)
|
||||
return board
|
||||
|
||||
|
||||
async def main():
|
||||
config = configparser.ConfigParser()
|
||||
config.read(
|
||||
Path(__file__).resolve().parent / "config.ini") # mimick os.path.join
|
||||
Path(__file__).resolve().parent / "config.ini"
|
||||
) # mimick os.path.join
|
||||
logging.basicConfig(level=config["Daemon"]["LogLevel"].upper())
|
||||
|
||||
sd = SerialDaemon(config)
|
||||
server = await asyncio.start_server(
|
||||
sd.handle_echo,
|
||||
config["Daemon"]["ListeningIP"],
|
||||
config["Daemon"]["ListeningPort"])
|
||||
config["Daemon"]["ListeningPort"],
|
||||
)
|
||||
addr = server.sockets[0].getsockname()
|
||||
logging.warning("Serving on {} port {}".format(addr[0], addr[1]))
|
||||
logging.warning(
|
||||
logging.info("Serving on {} port {}".format(addr[0], addr[1]))
|
||||
logging.info(
|
||||
"Proxying to {} (Baudrate: {}, Timeout: {})".format(
|
||||
config["Serial"]["Port"],
|
||||
config["Serial"]["Baudrate"],
|
||||
config["Serial"]["Timeout"]))
|
||||
logging.warning("Initializing board")
|
||||
logging.warning("Board {} ready".format(
|
||||
await sd.return_board()))
|
||||
config["Serial"]["Timeout"],
|
||||
)
|
||||
)
|
||||
logging.info("Initializing board")
|
||||
logging.info("Board {} ready".format(await sd.return_board()))
|
||||
|
||||
async with server:
|
||||
await server.serve_forever()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
|
BIN
daemons/simulator/CommandStation-EX-uno-7311f2c.elf
Executable file
BIN
daemons/simulator/CommandStation-EX-uno-7311f2c.elf
Executable file
Binary file not shown.
Binary file not shown.
26
ram/metadata/migrations/0010_alter_manufacturer_category.py
Normal file
26
ram/metadata/migrations/0010_alter_manufacturer_category.py
Normal file
@@ -0,0 +1,26 @@
|
||||
# Generated by Django 4.1.5 on 2023-01-06 00:52
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("metadata", "0009_alter_company_logo_alter_decoder_image_and_more"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="manufacturer",
|
||||
name="category",
|
||||
field=models.CharField(
|
||||
choices=[
|
||||
("model", "Model"),
|
||||
("real", "Real"),
|
||||
("accessory", "Accessory"),
|
||||
("other", "Other"),
|
||||
],
|
||||
max_length=64,
|
||||
),
|
||||
),
|
||||
]
|
93
ram/metadata/migrations/0011_company_slug_and_more.py
Normal file
93
ram/metadata/migrations/0011_company_slug_and_more.py
Normal file
@@ -0,0 +1,93 @@
|
||||
# Generated by Django 4.1.5 on 2023-01-09 11:22
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
from ram.utils import slugify
|
||||
|
||||
|
||||
def create_slug(apps, schema_editor):
|
||||
fields = ["Company", "Manufacturer", "RollingStockType", "Scale"]
|
||||
|
||||
for m in fields:
|
||||
model = apps.get_model("metadata", m)
|
||||
|
||||
for row in model.objects.all():
|
||||
if hasattr(row, "type"):
|
||||
row.slug = slugify("{} {}".format(row.type, row.category))
|
||||
elif hasattr(row, "scale"):
|
||||
row.slug = slugify(row.scale)
|
||||
else:
|
||||
row.slug = slugify(row.name)
|
||||
|
||||
row.save(update_fields=["slug"])
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("metadata", "0010_alter_manufacturer_category"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="company",
|
||||
name="slug",
|
||||
field=models.CharField(
|
||||
editable=False, max_length=64, blank=True
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="manufacturer",
|
||||
name="slug",
|
||||
field=models.CharField(
|
||||
editable=False, max_length=128, blank=True
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="rollingstocktype",
|
||||
name="slug",
|
||||
field=models.CharField(
|
||||
editable=False, max_length=128, blank=True
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="scale",
|
||||
name="slug",
|
||||
field=models.CharField(
|
||||
editable=False, max_length=32, blank=True
|
||||
),
|
||||
),
|
||||
migrations.RunPython(
|
||||
create_slug,
|
||||
reverse_code=migrations.RunPython.noop
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="company",
|
||||
name="slug",
|
||||
field=models.CharField(
|
||||
editable=False, max_length=64, unique=True
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="manufacturer",
|
||||
name="slug",
|
||||
field=models.CharField(
|
||||
editable=False, max_length=128, unique=True
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="rollingstocktype",
|
||||
name="slug",
|
||||
field=models.CharField(
|
||||
editable=False, max_length=128, unique=True
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="scale",
|
||||
name="slug",
|
||||
field=models.CharField(
|
||||
editable=False, max_length=32, unique=True
|
||||
),
|
||||
),
|
||||
]
|
@@ -1,4 +1,7 @@
|
||||
from urllib.parse import quote
|
||||
|
||||
from django.db import models
|
||||
from django.urls import reverse
|
||||
from django.conf import settings
|
||||
from django.dispatch.dispatcher import receiver
|
||||
from django_countries.fields import CountryField
|
||||
@@ -20,6 +23,7 @@ class Property(models.Model):
|
||||
|
||||
class Manufacturer(models.Model):
|
||||
name = models.CharField(max_length=128, unique=True)
|
||||
slug = models.CharField(max_length=128, unique=True, editable=False)
|
||||
category = models.CharField(
|
||||
max_length=64, choices=settings.MANUFACTURER_TYPES
|
||||
)
|
||||
@@ -34,6 +38,14 @@ class Manufacturer(models.Model):
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse(
|
||||
"filtered", kwargs={
|
||||
"_filter": "manufacturer",
|
||||
"search": self.slug,
|
||||
}
|
||||
)
|
||||
|
||||
def logo_thumbnail(self):
|
||||
return get_image_preview(self.logo.url)
|
||||
|
||||
@@ -42,6 +54,7 @@ class Manufacturer(models.Model):
|
||||
|
||||
class Company(models.Model):
|
||||
name = models.CharField(max_length=64, unique=True)
|
||||
slug = models.CharField(max_length=64, unique=True, editable=False)
|
||||
extended_name = models.CharField(max_length=128, blank=True)
|
||||
country = CountryField()
|
||||
freelance = models.BooleanField(default=False)
|
||||
@@ -56,6 +69,14 @@ class Company(models.Model):
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse(
|
||||
"filtered", kwargs={
|
||||
"_filter": "company",
|
||||
"search": self.slug,
|
||||
}
|
||||
)
|
||||
|
||||
def logo_thumbnail(self):
|
||||
return get_image_preview(self.logo.url)
|
||||
|
||||
@@ -86,6 +107,7 @@ class Decoder(models.Model):
|
||||
|
||||
class Scale(models.Model):
|
||||
scale = models.CharField(max_length=32, unique=True)
|
||||
slug = models.CharField(max_length=32, unique=True, editable=False)
|
||||
ratio = models.CharField(max_length=16, blank=True)
|
||||
gauge = models.CharField(max_length=16, blank=True)
|
||||
tracks = models.CharField(max_length=16, blank=True)
|
||||
@@ -93,10 +115,42 @@ class Scale(models.Model):
|
||||
class Meta:
|
||||
ordering = ["scale"]
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse(
|
||||
"filtered", kwargs={
|
||||
"_filter": "scale",
|
||||
"search": self.slug,
|
||||
}
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
return str(self.scale)
|
||||
|
||||
|
||||
class RollingStockType(models.Model):
|
||||
type = models.CharField(max_length=64)
|
||||
order = models.PositiveSmallIntegerField()
|
||||
category = models.CharField(
|
||||
max_length=64, choices=settings.ROLLING_STOCK_TYPES
|
||||
)
|
||||
slug = models.CharField(max_length=128, unique=True, editable=False)
|
||||
|
||||
class Meta(object):
|
||||
unique_together = ("category", "type")
|
||||
ordering = ["order"]
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse(
|
||||
"filtered", kwargs={
|
||||
"_filter": "type",
|
||||
"search": self.slug,
|
||||
}
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
return "{0} {1}".format(self.type, self.category)
|
||||
|
||||
|
||||
class Tag(models.Model):
|
||||
name = models.CharField(max_length=128, unique=True)
|
||||
slug = models.CharField(max_length=128, unique=True)
|
||||
@@ -104,22 +158,20 @@ class Tag(models.Model):
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse(
|
||||
"filtered", kwargs={
|
||||
"_filter": "tag",
|
||||
"search": self.slug,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
|
||||
@receiver(models.signals.pre_save, sender=Manufacturer)
|
||||
@receiver(models.signals.pre_save, sender=Company)
|
||||
@receiver(models.signals.pre_save, sender=Scale)
|
||||
@receiver(models.signals.pre_save, sender=RollingStockType)
|
||||
@receiver(models.signals.pre_save, sender=Tag)
|
||||
def tag_pre_save(sender, instance, **kwargs):
|
||||
instance.slug = slugify(instance.name)
|
||||
|
||||
|
||||
class RollingStockType(models.Model):
|
||||
type = models.CharField(max_length=64)
|
||||
order = models.PositiveSmallIntegerField()
|
||||
category = models.CharField(
|
||||
max_length=64, choices=settings.ROLLING_STOCK_TYPES
|
||||
)
|
||||
|
||||
class Meta(object):
|
||||
unique_together = ("category", "type")
|
||||
ordering = ["order"]
|
||||
|
||||
def __str__(self):
|
||||
return "{0} {1}".format(self.type, self.category)
|
||||
def slug_pre_save(sender, instance, **kwargs):
|
||||
instance.slug = slugify(instance.__str__())
|
||||
|
Binary file not shown.
@@ -1,8 +1,14 @@
|
||||
/*!
|
||||
* Bootstrap Icons v1.11.1 (https://icons.getbootstrap.com/)
|
||||
* Copyright 2019-2023 The Bootstrap Authors
|
||||
* Licensed under MIT (https://github.com/twbs/icons/blob/main/LICENSE)
|
||||
*/
|
||||
|
||||
@font-face {
|
||||
font-display: block;
|
||||
font-family: "bootstrap-icons";
|
||||
src: url("./fonts/bootstrap-icons.woff2?24e3eb84d0bcaf83d77f904c78ac1f47") format("woff2"),
|
||||
url("./fonts/bootstrap-icons.woff?24e3eb84d0bcaf83d77f904c78ac1f47") format("woff");
|
||||
src: url("./fonts/bootstrap-icons.woff2?2820a3852bdb9a5832199cc61cec4e65") format("woff2"),
|
||||
url("./fonts/bootstrap-icons.woff?2820a3852bdb9a5832199cc61cec4e65") format("woff");
|
||||
}
|
||||
|
||||
.bi::before,
|
||||
@@ -441,7 +447,6 @@ url("./fonts/bootstrap-icons.woff?24e3eb84d0bcaf83d77f904c78ac1f47") format("wof
|
||||
.bi-cloud-fog2::before { content: "\f2a2"; }
|
||||
.bi-cloud-hail-fill::before { content: "\f2a3"; }
|
||||
.bi-cloud-hail::before { content: "\f2a4"; }
|
||||
.bi-cloud-haze-1::before { content: "\f2a5"; }
|
||||
.bi-cloud-haze-fill::before { content: "\f2a6"; }
|
||||
.bi-cloud-haze::before { content: "\f2a7"; }
|
||||
.bi-cloud-haze2-fill::before { content: "\f2a8"; }
|
||||
@@ -1437,21 +1442,16 @@ url("./fonts/bootstrap-icons.woff?24e3eb84d0bcaf83d77f904c78ac1f47") format("wof
|
||||
.bi-dpad::before { content: "\f687"; }
|
||||
.bi-ear-fill::before { content: "\f688"; }
|
||||
.bi-ear::before { content: "\f689"; }
|
||||
.bi-envelope-check-1::before { content: "\f68a"; }
|
||||
.bi-envelope-check-fill::before { content: "\f68b"; }
|
||||
.bi-envelope-check::before { content: "\f68c"; }
|
||||
.bi-envelope-dash-1::before { content: "\f68d"; }
|
||||
.bi-envelope-dash-fill::before { content: "\f68e"; }
|
||||
.bi-envelope-dash::before { content: "\f68f"; }
|
||||
.bi-envelope-exclamation-1::before { content: "\f690"; }
|
||||
.bi-envelope-exclamation-fill::before { content: "\f691"; }
|
||||
.bi-envelope-exclamation::before { content: "\f692"; }
|
||||
.bi-envelope-plus-fill::before { content: "\f693"; }
|
||||
.bi-envelope-plus::before { content: "\f694"; }
|
||||
.bi-envelope-slash-1::before { content: "\f695"; }
|
||||
.bi-envelope-slash-fill::before { content: "\f696"; }
|
||||
.bi-envelope-slash::before { content: "\f697"; }
|
||||
.bi-envelope-x-1::before { content: "\f698"; }
|
||||
.bi-envelope-x-fill::before { content: "\f699"; }
|
||||
.bi-envelope-x::before { content: "\f69a"; }
|
||||
.bi-explicit-fill::before { content: "\f69b"; }
|
||||
@@ -1461,8 +1461,6 @@ url("./fonts/bootstrap-icons.woff?24e3eb84d0bcaf83d77f904c78ac1f47") format("wof
|
||||
.bi-list-columns-reverse::before { content: "\f69f"; }
|
||||
.bi-list-columns::before { content: "\f6a0"; }
|
||||
.bi-meta::before { content: "\f6a1"; }
|
||||
.bi-mortorboard-fill::before { content: "\f6a2"; }
|
||||
.bi-mortorboard::before { content: "\f6a3"; }
|
||||
.bi-nintendo-switch::before { content: "\f6a4"; }
|
||||
.bi-pc-display-horizontal::before { content: "\f6a5"; }
|
||||
.bi-pc-display::before { content: "\f6a6"; }
|
||||
@@ -1481,7 +1479,6 @@ url("./fonts/bootstrap-icons.woff?24e3eb84d0bcaf83d77f904c78ac1f47") format("wof
|
||||
.bi-send-check::before { content: "\f6b3"; }
|
||||
.bi-send-dash-fill::before { content: "\f6b4"; }
|
||||
.bi-send-dash::before { content: "\f6b5"; }
|
||||
.bi-send-exclamation-1::before { content: "\f6b6"; }
|
||||
.bi-send-exclamation-fill::before { content: "\f6b7"; }
|
||||
.bi-send-exclamation::before { content: "\f6b8"; }
|
||||
.bi-send-fill::before { content: "\f6b9"; }
|
||||
@@ -1493,7 +1490,6 @@ url("./fonts/bootstrap-icons.woff?24e3eb84d0bcaf83d77f904c78ac1f47") format("wof
|
||||
.bi-send-x::before { content: "\f6bf"; }
|
||||
.bi-send::before { content: "\f6c0"; }
|
||||
.bi-steam::before { content: "\f6c1"; }
|
||||
.bi-terminal-dash-1::before { content: "\f6c2"; }
|
||||
.bi-terminal-dash::before { content: "\f6c3"; }
|
||||
.bi-terminal-plus::before { content: "\f6c4"; }
|
||||
.bi-terminal-split::before { content: "\f6c5"; }
|
||||
@@ -1523,7 +1519,6 @@ url("./fonts/bootstrap-icons.woff?24e3eb84d0bcaf83d77f904c78ac1f47") format("wof
|
||||
.bi-usb-symbol::before { content: "\f6dd"; }
|
||||
.bi-usb::before { content: "\f6de"; }
|
||||
.bi-boombox-fill::before { content: "\f6df"; }
|
||||
.bi-displayport-1::before { content: "\f6e0"; }
|
||||
.bi-displayport::before { content: "\f6e1"; }
|
||||
.bi-gpu-card::before { content: "\f6e2"; }
|
||||
.bi-memory::before { content: "\f6e3"; }
|
||||
@@ -1536,8 +1531,6 @@ url("./fonts/bootstrap-icons.woff?24e3eb84d0bcaf83d77f904c78ac1f47") format("wof
|
||||
.bi-pci-card::before { content: "\f6ea"; }
|
||||
.bi-router-fill::before { content: "\f6eb"; }
|
||||
.bi-router::before { content: "\f6ec"; }
|
||||
.bi-ssd-fill::before { content: "\f6ed"; }
|
||||
.bi-ssd::before { content: "\f6ee"; }
|
||||
.bi-thunderbolt-fill::before { content: "\f6ef"; }
|
||||
.bi-thunderbolt::before { content: "\f6f0"; }
|
||||
.bi-usb-drive-fill::before { content: "\f6f1"; }
|
||||
@@ -1644,7 +1637,6 @@ url("./fonts/bootstrap-icons.woff?24e3eb84d0bcaf83d77f904c78ac1f47") format("wof
|
||||
.bi-filetype-pdf::before { content: "\f756"; }
|
||||
.bi-filetype-php::before { content: "\f757"; }
|
||||
.bi-filetype-png::before { content: "\f758"; }
|
||||
.bi-filetype-ppt-1::before { content: "\f759"; }
|
||||
.bi-filetype-ppt::before { content: "\f75a"; }
|
||||
.bi-filetype-psd::before { content: "\f75b"; }
|
||||
.bi-filetype-py::before { content: "\f75c"; }
|
||||
@@ -1660,7 +1652,6 @@ url("./fonts/bootstrap-icons.woff?24e3eb84d0bcaf83d77f904c78ac1f47") format("wof
|
||||
.bi-filetype-txt::before { content: "\f766"; }
|
||||
.bi-filetype-wav::before { content: "\f767"; }
|
||||
.bi-filetype-woff::before { content: "\f768"; }
|
||||
.bi-filetype-xls-1::before { content: "\f769"; }
|
||||
.bi-filetype-xls::before { content: "\f76a"; }
|
||||
.bi-filetype-xml::before { content: "\f76b"; }
|
||||
.bi-filetype-yml::before { content: "\f76c"; }
|
||||
@@ -1703,56 +1694,38 @@ url("./fonts/bootstrap-icons.woff?24e3eb84d0bcaf83d77f904c78ac1f47") format("wof
|
||||
.bi-filetype-json::before { content: "\f791"; }
|
||||
.bi-filetype-pptx::before { content: "\f792"; }
|
||||
.bi-filetype-xlsx::before { content: "\f793"; }
|
||||
.bi-1-circle-1::before { content: "\f794"; }
|
||||
.bi-1-circle-fill-1::before { content: "\f795"; }
|
||||
.bi-1-circle-fill::before { content: "\f796"; }
|
||||
.bi-1-circle::before { content: "\f797"; }
|
||||
.bi-1-square-fill::before { content: "\f798"; }
|
||||
.bi-1-square::before { content: "\f799"; }
|
||||
.bi-2-circle-1::before { content: "\f79a"; }
|
||||
.bi-2-circle-fill-1::before { content: "\f79b"; }
|
||||
.bi-2-circle-fill::before { content: "\f79c"; }
|
||||
.bi-2-circle::before { content: "\f79d"; }
|
||||
.bi-2-square-fill::before { content: "\f79e"; }
|
||||
.bi-2-square::before { content: "\f79f"; }
|
||||
.bi-3-circle-1::before { content: "\f7a0"; }
|
||||
.bi-3-circle-fill-1::before { content: "\f7a1"; }
|
||||
.bi-3-circle-fill::before { content: "\f7a2"; }
|
||||
.bi-3-circle::before { content: "\f7a3"; }
|
||||
.bi-3-square-fill::before { content: "\f7a4"; }
|
||||
.bi-3-square::before { content: "\f7a5"; }
|
||||
.bi-4-circle-1::before { content: "\f7a6"; }
|
||||
.bi-4-circle-fill-1::before { content: "\f7a7"; }
|
||||
.bi-4-circle-fill::before { content: "\f7a8"; }
|
||||
.bi-4-circle::before { content: "\f7a9"; }
|
||||
.bi-4-square-fill::before { content: "\f7aa"; }
|
||||
.bi-4-square::before { content: "\f7ab"; }
|
||||
.bi-5-circle-1::before { content: "\f7ac"; }
|
||||
.bi-5-circle-fill-1::before { content: "\f7ad"; }
|
||||
.bi-5-circle-fill::before { content: "\f7ae"; }
|
||||
.bi-5-circle::before { content: "\f7af"; }
|
||||
.bi-5-square-fill::before { content: "\f7b0"; }
|
||||
.bi-5-square::before { content: "\f7b1"; }
|
||||
.bi-6-circle-1::before { content: "\f7b2"; }
|
||||
.bi-6-circle-fill-1::before { content: "\f7b3"; }
|
||||
.bi-6-circle-fill::before { content: "\f7b4"; }
|
||||
.bi-6-circle::before { content: "\f7b5"; }
|
||||
.bi-6-square-fill::before { content: "\f7b6"; }
|
||||
.bi-6-square::before { content: "\f7b7"; }
|
||||
.bi-7-circle-1::before { content: "\f7b8"; }
|
||||
.bi-7-circle-fill-1::before { content: "\f7b9"; }
|
||||
.bi-7-circle-fill::before { content: "\f7ba"; }
|
||||
.bi-7-circle::before { content: "\f7bb"; }
|
||||
.bi-7-square-fill::before { content: "\f7bc"; }
|
||||
.bi-7-square::before { content: "\f7bd"; }
|
||||
.bi-8-circle-1::before { content: "\f7be"; }
|
||||
.bi-8-circle-fill-1::before { content: "\f7bf"; }
|
||||
.bi-8-circle-fill::before { content: "\f7c0"; }
|
||||
.bi-8-circle::before { content: "\f7c1"; }
|
||||
.bi-8-square-fill::before { content: "\f7c2"; }
|
||||
.bi-8-square::before { content: "\f7c3"; }
|
||||
.bi-9-circle-1::before { content: "\f7c4"; }
|
||||
.bi-9-circle-fill-1::before { content: "\f7c5"; }
|
||||
.bi-9-circle-fill::before { content: "\f7c6"; }
|
||||
.bi-9-circle::before { content: "\f7c7"; }
|
||||
.bi-9-square-fill::before { content: "\f7c8"; }
|
||||
@@ -1771,8 +1744,6 @@ url("./fonts/bootstrap-icons.woff?24e3eb84d0bcaf83d77f904c78ac1f47") format("wof
|
||||
.bi-browser-edge::before { content: "\f7d5"; }
|
||||
.bi-browser-firefox::before { content: "\f7d6"; }
|
||||
.bi-browser-safari::before { content: "\f7d7"; }
|
||||
.bi-c-circle-1::before { content: "\f7d8"; }
|
||||
.bi-c-circle-fill-1::before { content: "\f7d9"; }
|
||||
.bi-c-circle-fill::before { content: "\f7da"; }
|
||||
.bi-c-circle::before { content: "\f7db"; }
|
||||
.bi-c-square-fill::before { content: "\f7dc"; }
|
||||
@@ -1783,8 +1754,6 @@ url("./fonts/bootstrap-icons.woff?24e3eb84d0bcaf83d77f904c78ac1f47") format("wof
|
||||
.bi-car-front::before { content: "\f7e1"; }
|
||||
.bi-cassette-fill::before { content: "\f7e2"; }
|
||||
.bi-cassette::before { content: "\f7e3"; }
|
||||
.bi-cc-circle-1::before { content: "\f7e4"; }
|
||||
.bi-cc-circle-fill-1::before { content: "\f7e5"; }
|
||||
.bi-cc-circle-fill::before { content: "\f7e6"; }
|
||||
.bi-cc-circle::before { content: "\f7e7"; }
|
||||
.bi-cc-square-fill::before { content: "\f7e8"; }
|
||||
@@ -1803,8 +1772,6 @@ url("./fonts/bootstrap-icons.woff?24e3eb84d0bcaf83d77f904c78ac1f47") format("wof
|
||||
.bi-filetype-sql::before { content: "\f7f5"; }
|
||||
.bi-fire::before { content: "\f7f6"; }
|
||||
.bi-google-play::before { content: "\f7f7"; }
|
||||
.bi-h-circle-1::before { content: "\f7f8"; }
|
||||
.bi-h-circle-fill-1::before { content: "\f7f9"; }
|
||||
.bi-h-circle-fill::before { content: "\f7fa"; }
|
||||
.bi-h-circle::before { content: "\f7fb"; }
|
||||
.bi-h-square-fill::before { content: "\f7fc"; }
|
||||
@@ -1813,8 +1780,6 @@ url("./fonts/bootstrap-icons.woff?24e3eb84d0bcaf83d77f904c78ac1f47") format("wof
|
||||
.bi-lungs-fill::before { content: "\f7ff"; }
|
||||
.bi-lungs::before { content: "\f800"; }
|
||||
.bi-microsoft-teams::before { content: "\f801"; }
|
||||
.bi-p-circle-1::before { content: "\f802"; }
|
||||
.bi-p-circle-fill-1::before { content: "\f803"; }
|
||||
.bi-p-circle-fill::before { content: "\f804"; }
|
||||
.bi-p-circle::before { content: "\f805"; }
|
||||
.bi-p-square-fill::before { content: "\f806"; }
|
||||
@@ -1823,8 +1788,6 @@ url("./fonts/bootstrap-icons.woff?24e3eb84d0bcaf83d77f904c78ac1f47") format("wof
|
||||
.bi-pass::before { content: "\f809"; }
|
||||
.bi-prescription::before { content: "\f80a"; }
|
||||
.bi-prescription2::before { content: "\f80b"; }
|
||||
.bi-r-circle-1::before { content: "\f80c"; }
|
||||
.bi-r-circle-fill-1::before { content: "\f80d"; }
|
||||
.bi-r-circle-fill::before { content: "\f80e"; }
|
||||
.bi-r-circle::before { content: "\f80f"; }
|
||||
.bi-r-square-fill::before { content: "\f810"; }
|
||||
@@ -2016,3 +1979,100 @@ url("./fonts/bootstrap-icons.woff?24e3eb84d0bcaf83d77f904c78ac1f47") format("wof
|
||||
.bi-sina-weibo::before { content: "\f8ca"; }
|
||||
.bi-tencent-qq::before { content: "\f8cb"; }
|
||||
.bi-wikipedia::before { content: "\f8cc"; }
|
||||
.bi-alphabet-uppercase::before { content: "\f2a5"; }
|
||||
.bi-alphabet::before { content: "\f68a"; }
|
||||
.bi-amazon::before { content: "\f68d"; }
|
||||
.bi-arrows-collapse-vertical::before { content: "\f690"; }
|
||||
.bi-arrows-expand-vertical::before { content: "\f695"; }
|
||||
.bi-arrows-vertical::before { content: "\f698"; }
|
||||
.bi-arrows::before { content: "\f6a2"; }
|
||||
.bi-ban-fill::before { content: "\f6a3"; }
|
||||
.bi-ban::before { content: "\f6b6"; }
|
||||
.bi-bing::before { content: "\f6c2"; }
|
||||
.bi-cake::before { content: "\f6e0"; }
|
||||
.bi-cake2::before { content: "\f6ed"; }
|
||||
.bi-cookie::before { content: "\f6ee"; }
|
||||
.bi-copy::before { content: "\f759"; }
|
||||
.bi-crosshair::before { content: "\f769"; }
|
||||
.bi-crosshair2::before { content: "\f794"; }
|
||||
.bi-emoji-astonished-fill::before { content: "\f795"; }
|
||||
.bi-emoji-astonished::before { content: "\f79a"; }
|
||||
.bi-emoji-grimace-fill::before { content: "\f79b"; }
|
||||
.bi-emoji-grimace::before { content: "\f7a0"; }
|
||||
.bi-emoji-grin-fill::before { content: "\f7a1"; }
|
||||
.bi-emoji-grin::before { content: "\f7a6"; }
|
||||
.bi-emoji-surprise-fill::before { content: "\f7a7"; }
|
||||
.bi-emoji-surprise::before { content: "\f7ac"; }
|
||||
.bi-emoji-tear-fill::before { content: "\f7ad"; }
|
||||
.bi-emoji-tear::before { content: "\f7b2"; }
|
||||
.bi-envelope-arrow-down-fill::before { content: "\f7b3"; }
|
||||
.bi-envelope-arrow-down::before { content: "\f7b8"; }
|
||||
.bi-envelope-arrow-up-fill::before { content: "\f7b9"; }
|
||||
.bi-envelope-arrow-up::before { content: "\f7be"; }
|
||||
.bi-feather::before { content: "\f7bf"; }
|
||||
.bi-feather2::before { content: "\f7c4"; }
|
||||
.bi-floppy-fill::before { content: "\f7c5"; }
|
||||
.bi-floppy::before { content: "\f7d8"; }
|
||||
.bi-floppy2-fill::before { content: "\f7d9"; }
|
||||
.bi-floppy2::before { content: "\f7e4"; }
|
||||
.bi-gitlab::before { content: "\f7e5"; }
|
||||
.bi-highlighter::before { content: "\f7f8"; }
|
||||
.bi-marker-tip::before { content: "\f802"; }
|
||||
.bi-nvme-fill::before { content: "\f803"; }
|
||||
.bi-nvme::before { content: "\f80c"; }
|
||||
.bi-opencollective::before { content: "\f80d"; }
|
||||
.bi-pci-card-network::before { content: "\f8cd"; }
|
||||
.bi-pci-card-sound::before { content: "\f8ce"; }
|
||||
.bi-radar::before { content: "\f8cf"; }
|
||||
.bi-send-arrow-down-fill::before { content: "\f8d0"; }
|
||||
.bi-send-arrow-down::before { content: "\f8d1"; }
|
||||
.bi-send-arrow-up-fill::before { content: "\f8d2"; }
|
||||
.bi-send-arrow-up::before { content: "\f8d3"; }
|
||||
.bi-sim-slash-fill::before { content: "\f8d4"; }
|
||||
.bi-sim-slash::before { content: "\f8d5"; }
|
||||
.bi-sourceforge::before { content: "\f8d6"; }
|
||||
.bi-substack::before { content: "\f8d7"; }
|
||||
.bi-threads-fill::before { content: "\f8d8"; }
|
||||
.bi-threads::before { content: "\f8d9"; }
|
||||
.bi-transparency::before { content: "\f8da"; }
|
||||
.bi-twitter-x::before { content: "\f8db"; }
|
||||
.bi-type-h4::before { content: "\f8dc"; }
|
||||
.bi-type-h5::before { content: "\f8dd"; }
|
||||
.bi-type-h6::before { content: "\f8de"; }
|
||||
.bi-backpack-fill::before { content: "\f8df"; }
|
||||
.bi-backpack::before { content: "\f8e0"; }
|
||||
.bi-backpack2-fill::before { content: "\f8e1"; }
|
||||
.bi-backpack2::before { content: "\f8e2"; }
|
||||
.bi-backpack3-fill::before { content: "\f8e3"; }
|
||||
.bi-backpack3::before { content: "\f8e4"; }
|
||||
.bi-backpack4-fill::before { content: "\f8e5"; }
|
||||
.bi-backpack4::before { content: "\f8e6"; }
|
||||
.bi-brilliance::before { content: "\f8e7"; }
|
||||
.bi-cake-fill::before { content: "\f8e8"; }
|
||||
.bi-cake2-fill::before { content: "\f8e9"; }
|
||||
.bi-duffle-fill::before { content: "\f8ea"; }
|
||||
.bi-duffle::before { content: "\f8eb"; }
|
||||
.bi-exposure::before { content: "\f8ec"; }
|
||||
.bi-gender-neuter::before { content: "\f8ed"; }
|
||||
.bi-highlights::before { content: "\f8ee"; }
|
||||
.bi-luggage-fill::before { content: "\f8ef"; }
|
||||
.bi-luggage::before { content: "\f8f0"; }
|
||||
.bi-mailbox-flag::before { content: "\f8f1"; }
|
||||
.bi-mailbox2-flag::before { content: "\f8f2"; }
|
||||
.bi-noise-reduction::before { content: "\f8f3"; }
|
||||
.bi-passport-fill::before { content: "\f8f4"; }
|
||||
.bi-passport::before { content: "\f8f5"; }
|
||||
.bi-person-arms-up::before { content: "\f8f6"; }
|
||||
.bi-person-raised-hand::before { content: "\f8f7"; }
|
||||
.bi-person-standing-dress::before { content: "\f8f8"; }
|
||||
.bi-person-standing::before { content: "\f8f9"; }
|
||||
.bi-person-walking::before { content: "\f8fa"; }
|
||||
.bi-person-wheelchair::before { content: "\f8fb"; }
|
||||
.bi-shadows::before { content: "\f8fc"; }
|
||||
.bi-suitcase-fill::before { content: "\f8fd"; }
|
||||
.bi-suitcase-lg-fill::before { content: "\f8fe"; }
|
||||
.bi-suitcase-lg::before { content: "\f8ff"; }
|
||||
.bi-suitcase::before { content: "\f900"; }
|
||||
.bi-suitcase2-fill::before { content: "\f901"; }
|
||||
.bi-suitcase2::before { content: "\f902"; }
|
||||
.bi-vignette::before { content: "\f903"; }
|
Binary file not shown.
@@ -1,5 +1,5 @@
|
||||
/* Switch SVG logo to white on dark mode */
|
||||
html.dark .navbar-light svg {
|
||||
html[data-bs-theme='dark'] .navbar svg {
|
||||
fill: #fff;
|
||||
}
|
||||
|
||||
|
@@ -4,7 +4,7 @@
|
||||
{% get_solo 'portal.SiteConfiguration' as site_conf %}
|
||||
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<html lang="en" data-bs-theme="auto">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
@@ -16,11 +16,11 @@
|
||||
<link rel="icon" href="{% static "favicon.png" %}" sizes="any">
|
||||
<link rel="icon" href="{% static "favicon.svg" %}" type="image/svg+xml">
|
||||
{% if site_conf.use_cdn %}
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap-dark-5@1.1.3/dist/css/bootstrap-nightshade.min.css" rel="stylesheet">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.3/font/bootstrap-icons.css" rel="stylesheet">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css" rel="stylesheet">
|
||||
{% else %}
|
||||
<link href="{% static "bootstrap-dark-5@1.1.3/dist/css/bootstrap-nightshade.min.css" %}" rel="stylesheet">
|
||||
<link href="{% static "bootstrap-icons@1.10.3/font/bootstrap-icons.css" %}" rel="stylesheet">
|
||||
<link href="{% static "bootstrap@5.3.2/dist/css/bootstrap.min.css" %}" rel="stylesheet">
|
||||
<link href="{% static "bootstrap-icons@1.11.1/font/bootstrap-icons.css" %}" rel="stylesheet">
|
||||
{% endif %}
|
||||
<link href="{% static "css/main.css" %}?v={{ site_conf.version }}" rel="stylesheet">
|
||||
<style>
|
||||
@@ -36,57 +36,140 @@
|
||||
font-size: 3.5rem;
|
||||
}
|
||||
}
|
||||
.d-light-inline { display: inline !important; }
|
||||
.d-dark-inline { display: none !important; }
|
||||
html.dark .d-light-inline { display: none !important; }
|
||||
html.dark .d-dark-inline { display: inline !important; }
|
||||
</style>
|
||||
<script>
|
||||
/*!
|
||||
* Color mode toggler for Bootstrap's docs (https://getbootstrap.com/)
|
||||
* Copyright 2011-2023 The Bootstrap Authors
|
||||
* Licensed under the Creative Commons Attribution 3.0 Unported License.
|
||||
*/
|
||||
|
||||
(() => {
|
||||
'use strict'
|
||||
|
||||
const getStoredTheme = () => localStorage.getItem('theme')
|
||||
const setStoredTheme = theme => localStorage.setItem('theme', theme)
|
||||
|
||||
const getPreferredTheme = () => {
|
||||
const storedTheme = getStoredTheme()
|
||||
if (storedTheme) {
|
||||
return storedTheme
|
||||
}
|
||||
|
||||
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
|
||||
}
|
||||
|
||||
const setTheme = theme => {
|
||||
if (theme === 'auto' && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
||||
document.documentElement.setAttribute('data-bs-theme', 'dark')
|
||||
} else {
|
||||
document.documentElement.setAttribute('data-bs-theme', theme)
|
||||
}
|
||||
}
|
||||
|
||||
setTheme(getPreferredTheme())
|
||||
|
||||
const showActiveTheme = (theme, focus = false) => {
|
||||
const themeSwitcher = document.querySelector('#bd-theme')
|
||||
|
||||
if (!themeSwitcher) {
|
||||
return
|
||||
}
|
||||
|
||||
const activeThemeIcon = document.querySelector('.theme-icon-active i')
|
||||
const btnToActive = document.querySelector(`[data-bs-theme-value="${theme}"]`)
|
||||
const biOfActiveBtn = btnToActive.querySelector('.theme-icon i').getAttribute('class')
|
||||
|
||||
document.querySelectorAll('[data-bs-theme-value]').forEach(element => {
|
||||
element.classList.remove('active')
|
||||
element.setAttribute('aria-pressed', 'false')
|
||||
})
|
||||
|
||||
btnToActive.classList.add('active')
|
||||
btnToActive.setAttribute('aria-pressed', 'true')
|
||||
activeThemeIcon.setAttribute('class', biOfActiveBtn)
|
||||
|
||||
if (focus) {
|
||||
themeSwitcher.focus()
|
||||
}
|
||||
}
|
||||
|
||||
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => {
|
||||
const storedTheme = getStoredTheme()
|
||||
if (storedTheme !== 'light' && storedTheme !== 'dark') {
|
||||
setTheme(getPreferredTheme())
|
||||
}
|
||||
})
|
||||
|
||||
window.addEventListener('DOMContentLoaded', () => {
|
||||
showActiveTheme(getPreferredTheme())
|
||||
document.querySelectorAll('[data-bs-theme-value]')
|
||||
.forEach(toggle => {
|
||||
toggle.addEventListener('click', () => {
|
||||
const theme = toggle.getAttribute('data-bs-theme-value')
|
||||
setStoredTheme(theme)
|
||||
setTheme(theme)
|
||||
showActiveTheme(theme, true)
|
||||
})
|
||||
})
|
||||
})
|
||||
})()
|
||||
</script>
|
||||
{% block extra_head %}
|
||||
{{ site_conf.extra_head | safe }}
|
||||
{% endblock %}
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<div class="navbar navbar-light bg-light shadow-sm">
|
||||
<div class="container">
|
||||
<a href="{% url 'index' %}" class="navbar-brand d-flex align-items-center">
|
||||
<svg class="me-2" width="26" height="16" enable-background="new 0 0 26 26" version="1" viewBox="0 0 26 16" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="m2.8125 0.0010991a1.0001 1.0001 0 0 0-0.8125 1c0 0.55455-0.44545 1-1 1a1.0001 1.0001 0 0 0-1 1v10a1.0001 1.0001 0 0 0 1 1c0.55455 0 1 0.44546 1 1a1.0001 1.0001 0 0 0 1 1h20a1.0001 1.0001 0 0 0 1-1c0-0.55454 0.44546-1 1-1a1.0001 1.0001 0 0 0 1-1v-10a1.0001 1.0001 0 0 0-1-1c-0.55454 0-1-0.44545-1-1a1.0001 1.0001 0 0 0-1-1h-20a1.0001 1.0001 0 0 0-0.09375 0 1.0001 1.0001 0 0 0-0.09375 0zm0.78125 2h14.406v1h2v-1h2.4062c0.30628 0.76906 0.82469 1.2875 1.5938 1.5938v8.8125c-0.76906 0.30628-1.2875 0.82469-1.5938 1.5938h-2.4062v-1h-2v1h-14.406c-0.30628-0.76906-0.82469-1.2875-1.5938-1.5938v-8.8125c0.76906-0.30628 1.2875-0.82469 1.5938-1.5938zm14.406 2v2h2v-2zm0 3v2h2v-2zm0 3v2h2v-2z" enable-background="accumulate" overflow="visible" stroke-width="2" />
|
||||
<style>
|
||||
path {
|
||||
text-indent:0;
|
||||
text-transform:none;
|
||||
}
|
||||
</style>
|
||||
</svg>
|
||||
<strong>{{ site_conf.site_name }}</strong>
|
||||
</a>
|
||||
<div class="btn-group" role="group" aria-label="Login menu">
|
||||
{% include 'includes/login.html' %}
|
||||
<a id="darkmode-button" class="btn btn-sm btn-outline-dark"><i class="bi bi-moon d-none d-light-inline" title="Switch to dark mode"></i><i class="bi bi-sun d-none d-dark-inline" title="Switch to light mode"></i></a>
|
||||
<nav class="navbar navbar-expand-lg bg-body-tertiary shadow-sm">
|
||||
<div class="container d-flex">
|
||||
<div class="me-auto">
|
||||
<a href="{% url 'index' %}" class="navbar-brand d-flex align-items-center">
|
||||
<svg class="me-2" width="26" height="16" enable-background="new 0 0 26 26" version="1" viewBox="0 0 26 16" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="m2.8125 0.0010991a1.0001 1.0001 0 0 0-0.8125 1c0 0.55455-0.44545 1-1 1a1.0001 1.0001 0 0 0-1 1v10a1.0001 1.0001 0 0 0 1 1c0.55455 0 1 0.44546 1 1a1.0001 1.0001 0 0 0 1 1h20a1.0001 1.0001 0 0 0 1-1c0-0.55454 0.44546-1 1-1a1.0001 1.0001 0 0 0 1-1v-10a1.0001 1.0001 0 0 0-1-1c-0.55454 0-1-0.44545-1-1a1.0001 1.0001 0 0 0-1-1h-20a1.0001 1.0001 0 0 0-0.09375 0 1.0001 1.0001 0 0 0-0.09375 0zm0.78125 2h14.406v1h2v-1h2.4062c0.30628 0.76906 0.82469 1.2875 1.5938 1.5938v8.8125c-0.76906 0.30628-1.2875 0.82469-1.5938 1.5938h-2.4062v-1h-2v1h-14.406c-0.30628-0.76906-0.82469-1.2875-1.5938-1.5938v-8.8125c0.76906-0.30628 1.2875-0.82469 1.5938-1.5938zm14.406 2v2h2v-2zm0 3v2h2v-2zm0 3v2h2v-2z" enable-background="accumulate" overflow="visible" stroke-width="2" />
|
||||
<style>
|
||||
path {
|
||||
text-indent:0;
|
||||
text-transform:none;
|
||||
}
|
||||
</style>
|
||||
</svg>
|
||||
<strong>{{ site_conf.site_name }}</strong>
|
||||
</a>
|
||||
</div>
|
||||
{% include 'includes/login.html' %}
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
<main>
|
||||
<div class="container py-2">
|
||||
<nav class="navbar navbar-expand-lg navbar-light">
|
||||
<nav class="navbar navbar-expand-lg">
|
||||
<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">
|
||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{% url 'index' %}">Roster</a>
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
Roster
|
||||
</a>
|
||||
<ul class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
|
||||
<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 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 class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
Manufacturers
|
||||
</a>
|
||||
<ul class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
|
||||
<li><a class="dropdown-item" href="{% url 'manufacturers' category='model' %}">Models</a></li>
|
||||
<li><a class="dropdown-item" href="{% url 'manufacturers' category='real' %}">Real</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
{% show_menu %}
|
||||
</ul>
|
||||
@@ -104,7 +187,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<div class="album py-4 bg-light">
|
||||
<div class="album py-4 bg-body-tertiary">
|
||||
<div class="container">
|
||||
{% block carousel %}
|
||||
{% endblock %}
|
||||
@@ -118,17 +201,9 @@
|
||||
</main>
|
||||
{% include 'includes/footer.html' %}
|
||||
{% if site_conf.use_cdn %}
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap-dark-5@1.1.3/dist/js/darkmode.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||
{% else %}
|
||||
<script src="{% static "bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" %}"></script>
|
||||
<script src="{% static "bootstrap-dark-5@1.1.3/dist/js/darkmode.min.js" %}"></script>
|
||||
<script src="{% static "bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" %}"></script>
|
||||
{% endif %}
|
||||
<!-- script src="https://cdn.jsdelivr.net/npm/masonry-layout@4.2.2/dist/masonry.pkgd.min.js" integrity="sha384-GNFwBvfVxBkLMJpYMOABq3c+d3KnQxudP/mGPkzpZSTYykLBNsZEnG2D9G/X/+7D" crossorigin="anonymous" async></script -->
|
||||
<script>
|
||||
document.querySelector("#darkmode-button").onclick = function(e){
|
||||
darkmode.toggleDarkMode();
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
@@ -1,22 +1,25 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block header %}
|
||||
<p class="lead text-muted">Results found: {{ matches }}</p>
|
||||
{% endblock %}
|
||||
{% block cards_layout %}
|
||||
<div class="row row-cols-1 row-cols-sm-2 row-cols-md-3 g-3">
|
||||
{% block cards %}
|
||||
{% for r in rolling_stock %}
|
||||
{% for d in data %}
|
||||
<div class="col">
|
||||
<div class="card shadow-sm">
|
||||
{% for i in r.image.all %}
|
||||
{% if forloop.first %}<a href="{{r.get_absolute_url}}"><img src="{{ i.image.url }}" alt="Card image cap"></a>{% endif %}
|
||||
{% for i in d.image.all %}
|
||||
{% if forloop.first %}<a href="{{d.get_absolute_url}}"><img class="card-img-top" src="{{ i.image.url }}" alt="Card image cap"></a>{% endif %}
|
||||
{% endfor %}
|
||||
<div class="card-body">
|
||||
<p class="card-text" style="position: relative;">
|
||||
<strong>{{ r }}</strong>
|
||||
<a class="stretched-link" href="{{ r.get_absolute_url }}"></a>
|
||||
<strong>{{ d }}</strong>
|
||||
<a class="stretched-link" href="{{ d.get_absolute_url }}"></a>
|
||||
</p>
|
||||
{% if r.tags.all %}
|
||||
{% if d.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">
|
||||
{% for t in d.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>
|
||||
@@ -30,41 +33,43 @@
|
||||
<tbody>
|
||||
<tr>
|
||||
<th width="35%" scope="row">Type</th>
|
||||
<td>{{ r.rolling_class.type }}</td>
|
||||
<td>{{ d.rolling_class.type }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Company</th>
|
||||
<td>
|
||||
<a href="{% url 'filtered' _filter="company" search=r.rolling_class.company %}"><abbr title="{{ r.rolling_class.company.extended_name }}">{{ r.rolling_class.company }}</abbr></a>
|
||||
<a href="{% url 'filtered' _filter="company" search=d.rolling_class.company.slug %}"><abbr title="{{ d.rolling_class.company.extended_name }}">{{ d.rolling_class.company }}</abbr></a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Class</th>
|
||||
<td>{{ r.rolling_class.identifier }}</td>
|
||||
<td>{{ d.rolling_class.identifier }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Road number</th>
|
||||
<td>{{ r.road_number }}</td>
|
||||
<td>{{ d.road_number }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Era</th>
|
||||
<td>{{ r.era }}</td>
|
||||
<td>{{ d.era }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th width="35%" scope="row">Manufacturer</th>
|
||||
<td>{{ r.manufacturer|default_if_none:"" }}{% if r.manufacturer.website %} <a href="{{ r.manufacturer.website }}" target="_blank"><i class="bi bi-box-arrow-up-right"></i></a>{% endif %}</td>
|
||||
<td>{%if d.manufacturer %}
|
||||
<a href="{% url 'filtered' _filter="manufacturer" search=d.manufacturer.slug %}">{{ d.manufacturer }}{% if d.manufacturer.website %}</a> <a href="{{ d.manufacturer.website }}" target="_blank"><i class="bi bi-box-arrow-up-right"></i></a>{% endif %}
|
||||
{% endif %}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Scale</th>
|
||||
<td><a href="{% url 'filtered' _filter="scale" search=r.scale %}"><abbr title="{{ r.scale.ratio }} - {{ r.scale.tracks }}">{{ r.scale }}</abbr></a></td>
|
||||
<td><a href="{% url 'filtered' _filter="scale" search=d.scale.slug %}"><abbr title="{{ d.scale.ratio }} - {{ d.scale.tracks }}">{{ d.scale }}</abbr></a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">SKU</th>
|
||||
<td>{{ r.sku }}</td>
|
||||
<td>{{ d.sku }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
{% if r.decoder %}
|
||||
{% if d.decoder %}
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -74,18 +79,18 @@
|
||||
<tbody>
|
||||
<tr>
|
||||
<th width="35%" scope="row">Decoder</th>
|
||||
<td>{{ r.decoder }}</td>
|
||||
<td>{{ d.decoder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Address</th>
|
||||
<td>{{ r.address }}</td>
|
||||
<td>{{ d.address }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
{% endif %}
|
||||
<div class="d-grid gap-2 mb-1 d-md-block">
|
||||
<a class="btn btn-sm btn-outline-primary" href="{{r.get_absolute_url}}">Show all data</a>
|
||||
{% if request.user.is_staff %}<a class="btn btn-sm btn-outline-danger" href="{% url 'admin:roster_rollingstock_change' r.pk %}">Edit</a>{% endif %}
|
||||
<a class="btn btn-sm btn-outline-primary" href="{{d.get_absolute_url}}">Show all data</a>
|
||||
{% if request.user.is_staff %}<a class="btn btn-sm btn-outline-danger" href="{% url 'admin:roster_rollingstock_change' d.pk %}">Edit</a>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -1,12 +1,12 @@
|
||||
{% extends "cards.html" %}
|
||||
|
||||
{% block cards %}
|
||||
{% for c in company %}
|
||||
{% for d in data %}
|
||||
<div class="col">
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-body">
|
||||
<p class="card-text" style="position: relative;">
|
||||
<strong>{{ c.name }}</strong>
|
||||
<strong>{{ d.name }}</strong>
|
||||
</p>
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
@@ -15,25 +15,25 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% if c.logo %}
|
||||
{% if d.logo %}
|
||||
<tr>
|
||||
<th width="35%" scope="row">Logo</th>
|
||||
<td><img style="max-height: 48px" src="{{ c.logo.url }}" /></td>
|
||||
<td><img style="max-height: 48px" src="{{ d.logo.url }}" /></td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
<tr>
|
||||
<th width="35%" scope="row">Name</th>
|
||||
<td>{{ c.extended_name }}</td>
|
||||
<td>{{ d.extended_name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th width="35%" scope="row">Abbreviation</th>
|
||||
<td>{{ c }}</td>
|
||||
<td>{{ d.name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th width="35%" scope="row">Country</th>
|
||||
<td>{{ c.country.name }} <img src="{{ c.country.flag }}" alt="{{ c.country }}" />
|
||||
<td>{{ d.country.name }} <img src="{{ d.country.flag }}" alt="{{ d.country }}" />
|
||||
</tr>
|
||||
{% if c.freelance %}
|
||||
{% if d.freelance %}
|
||||
<tr>
|
||||
<th width="35%" scope="row">Notes</th>
|
||||
<td>A <em>freelance</em> company</td>
|
||||
@@ -42,8 +42,8 @@
|
||||
</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="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 %}
|
||||
<a class="btn btn-sm btn-outline-primary" href="{% url 'filtered' _filter="company" search=d.slug %}">Show all rolling stock</a>
|
||||
{% if request.user.is_staff %}<a class="btn btn-sm btn-outline-danger" href="{% url 'admin:metadata_company_change' d.pk %}">Edit</a>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -51,12 +51,12 @@
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
{% block pagination %}
|
||||
{% if company.has_other_pages %}
|
||||
{% if data.has_other_pages %}
|
||||
<nav aria-label="Page navigation example">
|
||||
<ul class="pagination justify-content-center mt-4 mb-0">
|
||||
{% if company.has_previous %}
|
||||
{% if data.has_previous %}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="{% url 'companies_pagination' page=company.previous_page_number %}#rolling-stock" tabindex="-1">Previous</a>
|
||||
<a class="page-link" href="{% url 'companies_pagination' page=data.previous_page_number %}#rolling-stock" tabindex="-1">Previous</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="page-item disabled">
|
||||
@@ -64,21 +64,21 @@
|
||||
</li>
|
||||
{% endif %}
|
||||
{% for i in page_range %}
|
||||
{% if company.number == i %}
|
||||
{% if data.number == i %}
|
||||
<li class="page-item active">
|
||||
<span class="page-link">{{ i }}</span></span>
|
||||
</li>
|
||||
{% else %}
|
||||
{% if i == company.paginator.ELLIPSIS %}
|
||||
{% if i == data.paginator.ELLIPSIS %}
|
||||
<li class="page-item"><span class="page-link">{{ i }}</span></li>
|
||||
{% else %}
|
||||
<li class="page-item"><a class="page-link" href="{% url 'companies_pagination' page=i %}#rolling-stock">{{ i }}</a></li>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if company.has_next %}
|
||||
{% if data.has_next %}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="{% url 'companies_pagination' page=company.next_page_number %}#rolling-stock" tabindex="-1">Next</a>
|
||||
<a class="page-link" href="{% url 'companies_pagination' page=data.next_page_number %}#rolling-stock" tabindex="-1">Next</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="page-item disabled">
|
||||
|
@@ -23,103 +23,13 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
{% block cards %}
|
||||
{% for r in rolling_stock %}
|
||||
<div class="col">
|
||||
<div class="card shadow-sm">
|
||||
{% for i in r.rolling_stock.image.all %}
|
||||
{% if forloop.first %}<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" 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 %}<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 %}
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2" scope="row">Data</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th width="35%" scope="row">Type</th>
|
||||
<td>{{ r.rolling_stock.rolling_class.type }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Company</th>
|
||||
<td>
|
||||
<a href="{% url 'filtered' _filter="company" search=r.rolling_stock.rolling_class.company %}"><abbr title="{{ r.rolling_stock.rolling_class.company.extended_name }}">{{ r.rolling_stock.rolling_class.company }}</abbr></a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Class</th>
|
||||
<td>{{ r.rolling_stock.rolling_class.identifier }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Road number</th>
|
||||
<td>{{ r.rolling_stock.road_number }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Era</th>
|
||||
<td>{{ r.rolling_stock.era }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th width="35%" scope="row">Manufacturer</th>
|
||||
<td>{{ r.rolling_stock.manufacturer|default_if_none:"" }}{% if r.rolling_stock.manufacturer.website %} <a href="{{ r.rolling_stock.manufacturer.website }}" target="_blank"><i class="bi bi-box-arrow-up-right"></i></a>{% endif %}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Scale</th>
|
||||
<td><a href="{% url 'filtered' _filter="scale" search=r.rolling_stock.scale %}"><abbr title="{{ r.rolling_stock.scale.ratio }} - {{ r.rolling_stock.scale.tracks }}">{{ r.rolling_stock.scale }}</abbr></a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">SKU</th>
|
||||
<td>{{ r.rolling_stock.sku }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
{% if r.rolling_stock.decoder %}
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2" scope="row">DCC data</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th width="35%" scope="row">Decoder</th>
|
||||
<td>{{ r.rolling_stock.decoder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Address</th>
|
||||
<td>{{ r.rolling_stock.address }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
{% endif %}
|
||||
<div class="d-grid gap-2 mb-1 d-md-block">
|
||||
<a class="btn btn-sm btn-outline-primary" href="{{r.rolling_stock.get_absolute_url}}">Show all data</a>
|
||||
{% if request.user.is_staff %}<a class="btn btn-sm btn-outline-danger" href="{% url 'admin:roster_rollingstock_change' r.rolling_stock.pk %}">Edit</a>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
{% block pagination %}
|
||||
{% if rolling_stock.has_other_pages %}
|
||||
{% if data.has_other_pages %}
|
||||
<nav aria-label="Page navigation example">
|
||||
<ul class="pagination justify-content-center mt-4 mb-0">
|
||||
{% if rolling_stock.has_previous %}
|
||||
{% if data.has_previous %}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="{% url 'consist_pagination' uuid=consist.uuid page=rolling_stock.previous_page_number %}#rolling-stock" tabindex="-1">Previous</a>
|
||||
<a class="page-link" href="{% url 'consist_pagination' uuid=consist.uuid page=data.previous_page_number %}#rolling-stock" tabindex="-1">Previous</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="page-item disabled">
|
||||
@@ -127,21 +37,21 @@
|
||||
</li>
|
||||
{% endif %}
|
||||
{% for i in page_range %}
|
||||
{% if rolling_stock.number == i %}
|
||||
{% if data.number == i %}
|
||||
<li class="page-item active">
|
||||
<span class="page-link">{{ i }}</span></span>
|
||||
</li>
|
||||
{% else %}
|
||||
{% if i == rolling_stock.paginator.ELLIPSIS %}
|
||||
{% if i == data.paginator.ELLIPSIS %}
|
||||
<li class="page-item"><span class="page-link">{{ i }}</span></li>
|
||||
{% else %}
|
||||
<li class="page-item"><a class="page-link" href="{% url 'consist_pagination' uuid=consist.uuid page=i %}#rolling-stock">{{ i }}</a></li>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if rolling_stock.has_next %}
|
||||
{% if data.has_next %}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="{% url 'consist_pagination' uuid=consist.uuid page=rolling_stock.next_page_number %}#rolling-stock" tabindex="-1">Next</a>
|
||||
<a class="page-link" href="{% url 'consist_pagination' uuid=consist.uuid page=data.next_page_number %}#rolling-stock" tabindex="-1">Next</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="page-item disabled">
|
||||
@@ -181,7 +91,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Length</th>
|
||||
<td>{{ rolling_stock | length }}</td>
|
||||
<td>{{ data | length }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
@@ -1,14 +1,14 @@
|
||||
{% extends "cards.html" %}
|
||||
|
||||
{% block cards %}
|
||||
{% for c in consist %}
|
||||
{% for d in data %}
|
||||
<div class="col">
|
||||
<div class="card shadow-sm">
|
||||
<a href="{{ c.get_absolute_url }}">
|
||||
{% if c.image %}
|
||||
<img src="{{ c.image.url }}" alt="Card image cap">
|
||||
<a href="{{ d.get_absolute_url }}">
|
||||
{% if d.image %}
|
||||
<img src="{{ d.image.url }}" alt="Card image cap">
|
||||
{% else %}
|
||||
{% with c.consist_item.first.rolling_stock as r %}
|
||||
{% with d.consist_item.first.rolling_stock as r %}
|
||||
{% for i in r.image.all %}
|
||||
{% if forloop.first %}<img src="{{ i.image.url }}" alt="Card image cap">{% endif %}
|
||||
{% endfor %}
|
||||
@@ -17,12 +17,12 @@
|
||||
</a>
|
||||
<div class="card-body">
|
||||
<p class="card-text" style="position: relative;">
|
||||
<strong>{{ c }}</strong>
|
||||
<a class="stretched-link" href="{{ c.get_absolute_url }}"></a>
|
||||
<strong>{{ d }}</strong>
|
||||
<a class="stretched-link" href="{{ d.get_absolute_url }}"></a>
|
||||
</p>
|
||||
{% if c.tags.all %}
|
||||
{% if d.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">
|
||||
{% for t in d.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>
|
||||
@@ -34,29 +34,29 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% if c.address %}
|
||||
{% if d.address %}
|
||||
<tr>
|
||||
<th width="35%" scope="row">Address</th>
|
||||
<td>{{ c.address }}</td>
|
||||
<td>{{ d.address }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
<tr>
|
||||
<th width="35%" scope="row">Company</th>
|
||||
<td><abbr title="{{ c.company.extended_name }}">{{ c.company }}</abbr></td>
|
||||
<td><abbr title="{{ d.company.extended_name }}">{{ d.company }}</abbr></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Era</th>
|
||||
<td>{{ c.era }}</td>
|
||||
<td>{{ d.era }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Length</th>
|
||||
<td>{{ c.consist_item.all | length }}</td>
|
||||
<td>{{ d.consist_item.all | length }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="d-grid gap-2 mb-1 d-md-block">
|
||||
<a class="btn btn-sm btn-outline-primary" href="{{ c.get_absolute_url }}">Show all data</a>
|
||||
{% if request.user.is_staff %}<a class="btn btn-sm btn-outline-danger" href="{% url 'admin:consist_consist_change' c.pk %}">Edit</a>{% endif %}
|
||||
<a class="btn btn-sm btn-outline-primary" href="{{ d.get_absolute_url }}">Show all data</a>
|
||||
{% if request.user.is_staff %}<a class="btn btn-sm btn-outline-danger" href="{% url 'admin:consist_consist_change' d.pk %}">Edit</a>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -64,12 +64,12 @@
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
{% block pagination %}
|
||||
{% if consist.has_other_pages %}
|
||||
{% if data.has_other_pages %}
|
||||
<nav aria-label="Page navigation example">
|
||||
<ul class="pagination justify-content-center mt-4 mb-0">
|
||||
{% if consist.has_previous %}
|
||||
{% if data.has_previous %}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="{% url 'consists_pagination' page=consist.previous_page_number %}#rolling-stock" tabindex="-1">Previous</a>
|
||||
<a class="page-link" href="{% url 'consists_pagination' page=data.previous_page_number %}#rolling-stock" tabindex="-1">Previous</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="page-item disabled">
|
||||
@@ -77,21 +77,21 @@
|
||||
</li>
|
||||
{% endif %}
|
||||
{% for i in page_range %}
|
||||
{% if consist.number == i %}
|
||||
{% if data.number == i %}
|
||||
<li class="page-item active">
|
||||
<span class="page-link">{{ i }}</span></span>
|
||||
</li>
|
||||
{% else %}
|
||||
{% if i == consist.paginator.ELLIPSIS %}
|
||||
{% if i == data.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>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if consist.has_next %}
|
||||
{% if data.has_next %}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="{% url 'consists_pagination' page=consist.next_page_number %}#rolling-stock" tabindex="-1">Next</a>
|
||||
<a class="page-link" href="{% url 'consists_pagination' page=data.next_page_number %}#rolling-stock" tabindex="-1">Next</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="page-item disabled">
|
||||
|
41
ram/portal/templates/filter.html
Normal file
41
ram/portal/templates/filter.html
Normal file
@@ -0,0 +1,41 @@
|
||||
{% extends "cards.html" %}
|
||||
|
||||
{% block pagination %}
|
||||
{% if data.has_other_pages %}
|
||||
<nav aria-label="Page navigation example">
|
||||
<ul class="pagination justify-content-center mt-4 mb-0">
|
||||
{% if data.has_previous %}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="{% url 'filtered_pagination' _filter=filter search=search page=data.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 data.number == i %}
|
||||
<li class="page-item active">
|
||||
<span class="page-link">{{ i }}</span></span>
|
||||
</li>
|
||||
{% else %}
|
||||
{% if i == data.paginator.ELLIPSIS %}
|
||||
<li class="page-item"><span class="page-link">{{ i }}</span></li>
|
||||
{% else %}
|
||||
<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 data.has_next %}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="{% url 'filtered_pagination' _filter=filter search=search page=data.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 %}
|
@@ -1,7 +1,7 @@
|
||||
{% if menu %}
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
More ...
|
||||
Articles
|
||||
</a>
|
||||
<ul class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
|
||||
{% for m in menu %}
|
||||
|
@@ -1,44 +1,5 @@
|
||||
{% extends "cards.html" %}
|
||||
{% extends "roster.html" %}
|
||||
|
||||
{% block header %}
|
||||
<p class="lead text-muted">{{ site_conf.about | safe }}</p>
|
||||
{% endblock %}
|
||||
{% block pagination %}
|
||||
{% if rolling_stock.has_other_pages %}
|
||||
<nav aria-label="Page navigation example">
|
||||
<ul class="pagination justify-content-center mt-4 mb-0">
|
||||
{% if rolling_stock.has_previous %}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="{% url 'index_pagination' page=rolling_stock.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 rolling_stock.number == i %}
|
||||
<li class="page-item active">
|
||||
<span class="page-link">{{ i }}</span></span>
|
||||
</li>
|
||||
{% else %}
|
||||
{% 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>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if rolling_stock.has_next %}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="{% url 'index_pagination' page=rolling_stock.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 %}
|
||||
|
@@ -1,19 +1,47 @@
|
||||
{% if request.user.is_staff %}
|
||||
<button class="btn btn-sm btn-outline-dark dropdown-toggle" type="button" id="dropdownMenu2" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
Welcome back, <strong>{{ request.user }}</strong>
|
||||
</button>
|
||||
<ul class="dropdown-menu" aria-labelledby="dropdownMenu2">
|
||||
<li><a class="dropdown-item" href="{% url 'admin:roster_rollingstock_changelist' %}">Rolling stock</a></li>
|
||||
<li><a class="dropdown-item" href="{% url 'admin:consist_consist_changelist' %}">Consists</a></li>
|
||||
<li><a class="dropdown-item" href="{% url 'admin:app_list' 'metadata' %}">Metadata</a></li>
|
||||
<li><a class="dropdown-item" href="{% url 'admin:portal_flatpage_changelist' %}">Pages</a></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: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><a class="dropdown-item text-danger" href="{% url 'admin:logout' %}?next={{ request.path }}">Logout</a></li>
|
||||
</ul>
|
||||
{% else %}
|
||||
<a class="btn btn-sm btn-outline-dark" href="{% url 'admin:login' %}?next={{ request.path }}">Log in</a>
|
||||
{% endif %}
|
||||
<div class="navbar-collapse justify-content-end" id="loginNavbar">
|
||||
<ul class="navbar-nav">
|
||||
<li class="nav-item dropdown">
|
||||
{% if request.user.is_staff %}
|
||||
<a class="nav-link dropdown-toggle" href="#" role="button" id="dropdownLogin" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
Welcome back, <strong>{{ request.user }}</strong>
|
||||
</a>
|
||||
<ul class="dropdown-menu" aria-labelledby="dropdownLogin">
|
||||
<li><a class="dropdown-item" href="{% url 'admin:roster_rollingstock_changelist' %}">Rolling stock</a></li>
|
||||
<li><a class="dropdown-item" href="{% url 'admin:consist_consist_changelist' %}">Consists</a></li>
|
||||
<li><a class="dropdown-item" href="{% url 'admin:app_list' 'metadata' %}">Metadata</a></li>
|
||||
<li><a class="dropdown-item" href="{% url 'admin:portal_flatpage_changelist' %}">Pages</a></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: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><a class="dropdown-item text-danger" href="{% url 'admin:logout' %}?next={{ request.path }}">Logout</a></li>
|
||||
</ul>
|
||||
{% else %}
|
||||
<a class="nav-link" href="{% url 'admin:login' %}?next={{ request.path }}">Log in</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
<li class="nav-item dropdown">
|
||||
<a class="theme-icon-active nav-link dropdown-toggle" href="#" type="button" id="bd-theme" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<i class="bi bi-circle-half"></i>
|
||||
</a>
|
||||
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="bd-theme">
|
||||
<li>
|
||||
<button class="theme-icon dropdown-item" data-bs-theme-value="light" aria-pressed="false">
|
||||
<span class="me-2"><i class="bi bi-sun-fill"></i></span> Light
|
||||
</button>
|
||||
</li>
|
||||
<li>
|
||||
<button class="theme-icon dropdown-item" data-bs-theme-value="dark" aria-pressed="false">
|
||||
<span class="me-2"><i class="bi bi-moon-stars-fill"></i></span> Dark
|
||||
</button>
|
||||
</li>
|
||||
<li>
|
||||
<button class="theme-icon dropdown-item" data-bs-theme-value="auto" aria-pressed="false">
|
||||
<span class="me-2"><i class="bi bi-circle-half"></i></span> Auto
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
@@ -1,6 +1,12 @@
|
||||
<form class="d-flex needs-validation" action="{% url 'search' %}" method="post" novalidate>
|
||||
<div class="input-group has-validation">
|
||||
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search" name="search" id="searchValidation" required>
|
||||
<input class="form-control" type="search" list="datalistOptions" placeholder="Search" aria-label="Search" name="search" id="searchValidation" required>
|
||||
<datalist id="datalistOptions">
|
||||
<option value="company: ">
|
||||
<option value="manufacturer: ">
|
||||
<option value="scale: ">
|
||||
<option value="type: ">
|
||||
</datalist>
|
||||
<button class="btn btn-outline-primary" type="submit">Search</button>
|
||||
</div>
|
||||
</form>
|
||||
|
85
ram/portal/templates/manufacturers.html
Normal file
85
ram/portal/templates/manufacturers.html
Normal file
@@ -0,0 +1,85 @@
|
||||
{% extends "cards.html" %}
|
||||
|
||||
{% block cards %}
|
||||
{% for d in data %}
|
||||
<div class="col">
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-body">
|
||||
<p class="card-text" style="position: relative;">
|
||||
<strong>{{ d.name }}</strong>
|
||||
</p>
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2" scope="row">Manufacturer</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% if d.logo %}
|
||||
<tr>
|
||||
<th width="35%" scope="row">Logo</th>
|
||||
<td><img style="max-height: 48px" src="{{ d.logo.url }}" /></td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if d.website %}
|
||||
<tr>
|
||||
<th width="35%" scope="row">Website</th>
|
||||
<td><a href="{{ d.website }}" target="_blank"><i class="bi bi-box-arrow-up-right"></i></a></td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
<tr>
|
||||
<th width="35%" scope="row">Category</th>
|
||||
<td>{{ d.category | title }}</td>
|
||||
</tr>
|
||||
</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="manufacturer" search=d.slug %}">Show all rolling stock</a>
|
||||
{% if request.user.is_staff %}<a class="btn btn-sm btn-outline-danger" href="{% url 'admin:metadata_manufacturer_change' d.pk %}">Edit</a>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
{% block pagination %}
|
||||
{% if data.has_other_pages %}
|
||||
{% with data.0.category as c %}
|
||||
<nav aria-label="Page navigation example">
|
||||
<ul class="pagination justify-content-center mt-4 mb-0">
|
||||
{% if data.has_previous %}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="{% url 'manufacturers_pagination' category=c page=data.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 data.number == i %}
|
||||
<li class="page-item active">
|
||||
<span class="page-link">{{ i }}</span></span>
|
||||
</li>
|
||||
{% else %}
|
||||
{% if i == data.paginator.ELLIPSIS %}
|
||||
<li class="page-item"><span class="page-link">{{ i }}</span></li>
|
||||
{% else %}
|
||||
<li class="page-item"><a class="page-link" href="{% url 'manufacturers_pagination' category=c page=i %}#rolling-stock">{{ i }}</a></li>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if data.has_next %}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="{% url 'manufacturers_pagination' category=c page=data.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>
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
@@ -70,7 +70,7 @@
|
||||
<tr>
|
||||
<th scope="row">Company</th>
|
||||
<td>
|
||||
<a href="{% url 'filtered' _filter="company" search=rolling_stock.rolling_class.company %}"><abbr title="{{ rolling_stock.rolling_class.company.extended_name }}">{{ rolling_stock.rolling_class.company }}</abbr></a>
|
||||
<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>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -96,7 +96,9 @@
|
||||
<tbody>
|
||||
<tr>
|
||||
<th width="35%" scope="row">Manufacturer</th>
|
||||
<td>{{ rolling_stock.manufacturer|default_if_none:"" }}{% if rolling_stock.manufacturer.website %} <a href="{{ rolling_stock.manufacturer.website }}" target="_blank"><i class="bi bi-box-arrow-up-right"></i></a>{% endif %}</td>
|
||||
<td>{%if rolling_stock.manufacturer %}
|
||||
<a href="{% url 'filtered' _filter="manufacturer" search=rolling_stock.manufacturer.slug %}">{{ rolling_stock.manufacturer }}{% if rolling_stock.manufacturer.website %}</a> <a href="{{ rolling_stock.manufacturer.website }}" target="_blank"><i class="bi bi-box-arrow-up-right"></i></a>{% endif %}
|
||||
{% endif %}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Scale</th>
|
||||
@@ -144,11 +146,13 @@
|
||||
<tbody>
|
||||
<tr>
|
||||
<th width="35%" scope="row">Manufacturer</th>
|
||||
<td>{{ rolling_stock.manufacturer|default_if_none:"" }}{% if rolling_stock.manufacturer.website %} <a href="{{ rolling_stock.manufacturer.website }}" target="_blank"><i class="bi bi-box-arrow-up-right"></i></a>{% endif %}</td>
|
||||
<td>{%if rolling_stock.manufacturer %}
|
||||
<a href="{% url 'filtered' _filter="manufacturer" search=rolling_stock.manufacturer.slug %}">{{ rolling_stock.manufacturer }}{% if rolling_stock.manufacturer.website %}</a> <a href="{{ rolling_stock.manufacturer.website }}" target="_blank"><i class="bi bi-box-arrow-up-right"></i></a>{% endif %}
|
||||
{% endif %}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Scale</th>
|
||||
<td><abbr title="{{ rolling_stock.scale.ratio }} - {{ rolling_stock.scale.tracks }}">{{ 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.tracks }}">{{ rolling_stock.scale }}</abbr></a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">SKU</th>
|
||||
@@ -204,7 +208,9 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Company</th>
|
||||
<td>{{ rolling_stock.rolling_class.company }} ({{ rolling_stock.rolling_class.company.extended_name }})</td>
|
||||
<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>
|
||||
@@ -212,7 +218,9 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Manufacturer</th>
|
||||
<td>{{ rolling_stock.rolling_class.manufacturer|default_if_none:"" }}</td>
|
||||
<td>{%if rolling_stock.rolling_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 %}
|
||||
{% endif %}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
41
ram/portal/templates/roster.html
Normal file
41
ram/portal/templates/roster.html
Normal file
@@ -0,0 +1,41 @@
|
||||
{% extends "cards.html" %}
|
||||
|
||||
{% block pagination %}
|
||||
{% if data.has_other_pages %}
|
||||
<nav aria-label="Page navigation example">
|
||||
<ul class="pagination justify-content-center mt-4 mb-0">
|
||||
{% if data.has_previous %}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="{% url 'roster_pagination' page=data.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 data.number == i %}
|
||||
<li class="page-item active">
|
||||
<span class="page-link">{{ i }}</span></span>
|
||||
</li>
|
||||
{% else %}
|
||||
{% if i == data.paginator.ELLIPSIS %}
|
||||
<li class="page-item"><span class="page-link">{{ i }}</span></li>
|
||||
{% else %}
|
||||
<li class="page-item"><a class="page-link" href="{% url 'roster_pagination' page=i %}#rolling-stock">{{ i }}</a></li>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if data.has_next %}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="{% url 'roster_pagination' page=data.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 %}
|
@@ -1,11 +1,11 @@
|
||||
{% extends "cards.html" %}
|
||||
|
||||
{% block cards %}
|
||||
{% for s in scale %}
|
||||
{% for d in data %}
|
||||
<div class="col">
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-body">
|
||||
<p class="card-text"><strong>{{ s }}</strong></p>
|
||||
<p class="card-text"><strong>{{ d }}</strong></p>
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -15,25 +15,25 @@
|
||||
<tbody>
|
||||
<tr>
|
||||
<th width="35%" scope="row">Name</th>
|
||||
<td>{{ s.scale }}</td>
|
||||
<td>{{ d.scale }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th width="35%" scope="row">Ratio</th>
|
||||
<td>{{ s.ratio }}</td>
|
||||
<td>{{ d.ratio }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th width="35%" scope="row">Gauge</th>
|
||||
<td>{{ s.gauge }}</td>
|
||||
<td>{{ d.gauge }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th width="35%" scope="row">Tracks</th>
|
||||
<td>{{ s.tracks }}</td>
|
||||
<td>{{ d.tracks }}</td>
|
||||
</tr>
|
||||
</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=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 %}
|
||||
<a class="btn btn-sm btn-outline-primary" href="{% url 'filtered' _filter="scale" search=d.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.pk %}">Edit</a>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -41,12 +41,12 @@
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
{% block pagination %}
|
||||
{% if scale.has_other_pages %}
|
||||
{% if data.has_other_pages %}
|
||||
<nav aria-label="Page navigation example">
|
||||
<ul class="pagination justify-content-center mt-4 mb-0">
|
||||
{% if scale.has_previous %}
|
||||
{% if data.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>
|
||||
<a class="page-link" href="{% url 'scales_pagination' page=data.previous_page_number %}#rolling-stock" tabindex="-1">Previous</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="page-item disabled">
|
||||
@@ -54,21 +54,21 @@
|
||||
</li>
|
||||
{% endif %}
|
||||
{% for i in page_range %}
|
||||
{% if scale.number == i %}
|
||||
{% if data.number == i %}
|
||||
<li class="page-item active">
|
||||
<span class="page-link">{{ i }}</span></span>
|
||||
</li>
|
||||
{% else %}
|
||||
{% if i == scale.paginator.ELLIPSIS %}
|
||||
{% if i == data.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>
|
||||
<li class="page-item"><a class="page-link" href="{% url 'scales_pagination' page=i %}#rolling-stock">{{ i }}</a></li>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if scale.has_next %}
|
||||
{% if data.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>
|
||||
<a class="page-link" href="{% url 'scales_pagination' page=data.next_page_number %}#rolling-stock" tabindex="-1">Next</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="page-item disabled">
|
||||
|
@@ -1,15 +1,12 @@
|
||||
{% extends "cards.html" %}
|
||||
|
||||
{% block header %}
|
||||
<p class="lead text-muted">Results found: {{ matches }}</p>
|
||||
{% endblock %}
|
||||
{% block pagination %}
|
||||
{% if rolling_stock.has_other_pages %}
|
||||
{% if data.has_other_pages %}
|
||||
<nav aria-label="Page navigation example">
|
||||
<ul class="pagination justify-content-center mt-4 mb-0">
|
||||
{% if rolling_stock.has_previous %}
|
||||
{% if data.has_previous %}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="{% url 'filtered_pagination' _filter=filter search=search page=rolling_stock.previous_page_number %}#rolling-stock" tabindex="-1">Previous</a>
|
||||
<a class="page-link" href="{% url 'search_pagination' search=encoded_search page=data.previous_page_number %}#rolling-stock" tabindex="-1">Previous</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="page-item disabled">
|
||||
@@ -17,21 +14,21 @@
|
||||
</li>
|
||||
{% endif %}
|
||||
{% for i in page_range %}
|
||||
{% if rolling_stock.number == i %}
|
||||
{% if data.number == i %}
|
||||
<li class="page-item active">
|
||||
<span class="page-link">{{ i }}</span></span>
|
||||
</li>
|
||||
{% else %}
|
||||
{% if i == rolling_stock.paginator.ELLIPSIS %}
|
||||
{% if i == data.paginator.ELLIPSIS %}
|
||||
<li class="page-item"><span class="page-link">{{ i }}</span></li>
|
||||
{% else %}
|
||||
<li class="page-item"><a class="page-link" href="{% url 'filtered_pagination' _filter=filter search=search page=i %}#rolling-stock">{{ i }}</a></li>
|
||||
<li class="page-item"><a class="page-link" href="{% url 'search_pagination' search=encoded_search page=i %}#rolling-stock">{{ i }}</a></li>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if rolling_stock.has_next %}
|
||||
{% if data.has_next %}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="{% url 'filtered_pagination' _filter=filter search=search page=rolling_stock.next_page_number %}#rolling-stock" tabindex="-1">Next</a>
|
||||
<a class="page-link" href="{% url 'search_pagination' search=encoded_search page=data.next_page_number %}#rolling-stock" tabindex="-1">Next</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="page-item disabled">
|
||||
|
73
ram/portal/templates/types.html
Normal file
73
ram/portal/templates/types.html
Normal file
@@ -0,0 +1,73 @@
|
||||
{% extends "cards.html" %}
|
||||
|
||||
{% block cards %}
|
||||
{% for d in data %}
|
||||
<div class="col">
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-body">
|
||||
<p class="card-text"><strong>{{ d }}</strong></p>
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2" scope="row">Type</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th width="35%" scope="row">Type</th>
|
||||
<td>{{ d.type }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th width="35%" scope="row">Category</th>
|
||||
<td>{{ d.category | title}}</td>
|
||||
</tr>
|
||||
</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="type" search=d.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.pk %}">Edit</a>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
{% block pagination %}
|
||||
{% if data.has_other_pages %}
|
||||
<nav aria-label="Page navigation example">
|
||||
<ul class="pagination justify-content-center mt-4 mb-0">
|
||||
{% if data.has_previous %}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="{% url 'scales_pagination' page=data.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 data.number == i %}
|
||||
<li class="page-item active">
|
||||
<span class="page-link">{{ i }}</span></span>
|
||||
</li>
|
||||
{% else %}
|
||||
{% if i == data.paginator.ELLIPSIS %}
|
||||
<li class="page-item"><span class="page-link">{{ i }}</span></li>
|
||||
{% else %}
|
||||
<li class="page-item"><a class="page-link" href="{% url 'scales_pagination' page=i %}#rolling-stock">{{ i }}</a></li>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if data.has_next %}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="{% url 'scales_pagination' page=data.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 %}
|
@@ -1,29 +1,29 @@
|
||||
from django.urls import path
|
||||
|
||||
from portal.views import (
|
||||
GetHome,
|
||||
GetHomeFiltered,
|
||||
GetData,
|
||||
GetRoster,
|
||||
GetRosterFiltered,
|
||||
GetFlatpage,
|
||||
GetRollingStock,
|
||||
GetConsist,
|
||||
Consists,
|
||||
Companies,
|
||||
Manufacturers,
|
||||
Scales,
|
||||
Types,
|
||||
SearchRoster,
|
||||
)
|
||||
|
||||
urlpatterns = [
|
||||
path("", GetHome.as_view(), name="index"),
|
||||
path("<int:page>", GetHome.as_view(), name="index_pagination"),
|
||||
path("", GetData.as_view(), name="index"),
|
||||
path("roster", GetRoster.as_view(), name="roster"),
|
||||
path("roster/<int:page>", GetRoster.as_view(), name="roster_pagination"),
|
||||
path(
|
||||
"page/<str:flatpage>",
|
||||
GetFlatpage.as_view(),
|
||||
name="flatpage",
|
||||
),
|
||||
path(
|
||||
"search",
|
||||
GetHomeFiltered.as_view(http_method_names=["post"]),
|
||||
name="search",
|
||||
),
|
||||
path("consists", Consists.as_view(), name="consists"),
|
||||
path(
|
||||
"consists/<int:page>", Consists.as_view(), name="consists_pagination"
|
||||
@@ -40,16 +40,38 @@ urlpatterns = [
|
||||
Companies.as_view(),
|
||||
name="companies_pagination",
|
||||
),
|
||||
path(
|
||||
"manufacturers/<str:category>",
|
||||
Manufacturers.as_view(),
|
||||
name="manufacturers"
|
||||
),
|
||||
path(
|
||||
"manufacturers/<str:category>/<int:page>",
|
||||
Manufacturers.as_view(),
|
||||
name="manufacturers_pagination",
|
||||
),
|
||||
path("scales", Scales.as_view(), name="scales"),
|
||||
path("scales/<int:page>", Scales.as_view(), name="scales_pagination"),
|
||||
path("scales/<int:page>", Types.as_view(), name="scales_pagination"),
|
||||
path("types", Types.as_view(), name="types"),
|
||||
path("types/<int:page>", Types.as_view(), name="types_pagination"),
|
||||
path(
|
||||
"search",
|
||||
SearchRoster.as_view(http_method_names=["post"]),
|
||||
name="search",
|
||||
),
|
||||
path(
|
||||
"search/<str:search>/<int:page>",
|
||||
SearchRoster.as_view(),
|
||||
name="search_pagination",
|
||||
),
|
||||
path(
|
||||
"<str:_filter>/<str:search>",
|
||||
GetHomeFiltered.as_view(),
|
||||
GetRosterFiltered.as_view(),
|
||||
name="filtered",
|
||||
),
|
||||
path(
|
||||
"<str:_filter>/<str:search>/<int:page>",
|
||||
GetHomeFiltered.as_view(),
|
||||
GetRosterFiltered.as_view(),
|
||||
name="filtered_pagination",
|
||||
),
|
||||
path("<uuid:uuid>", GetRollingStock.as_view(), name="rolling_stock"),
|
||||
|
@@ -1,18 +1,20 @@
|
||||
import base64
|
||||
import operator
|
||||
from functools import reduce
|
||||
from urllib.parse import unquote
|
||||
|
||||
from django.views import View
|
||||
from django.http import Http404
|
||||
from django.http import Http404, HttpResponseBadRequest
|
||||
from django.db.models import Q
|
||||
from django.shortcuts import render
|
||||
from django.shortcuts import render, get_object_or_404
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.core.paginator import Paginator, PageNotAnInteger
|
||||
from django.core.paginator import Paginator
|
||||
|
||||
from portal.utils import get_site_conf
|
||||
from portal.models import Flatpage
|
||||
from roster.models import RollingStock
|
||||
from consist.models import Consist
|
||||
from metadata.models import Company, Scale
|
||||
from metadata.models import Company, Manufacturer, Scale, RollingStockType, Tag
|
||||
|
||||
|
||||
def order_by_fields():
|
||||
@@ -32,32 +34,44 @@ def order_by_fields():
|
||||
return (fields[2], fields[0], fields[1], fields[3])
|
||||
|
||||
|
||||
class GetHome(View):
|
||||
class GetData(View):
|
||||
def __init__(self):
|
||||
self.title = "Home"
|
||||
self.template = "home.html"
|
||||
self.data = RollingStock.objects.order_by(*order_by_fields())
|
||||
|
||||
def get(self, request, page=1):
|
||||
site_conf = get_site_conf()
|
||||
rolling_stock = RollingStock.objects.order_by(*order_by_fields())
|
||||
|
||||
paginator = Paginator(rolling_stock, site_conf.items_per_page)
|
||||
rolling_stock = paginator.get_page(page)
|
||||
paginator = Paginator(self.data, site_conf.items_per_page)
|
||||
data = paginator.get_page(page)
|
||||
page_range = paginator.get_elided_page_range(
|
||||
rolling_stock.number, on_each_side=2, on_ends=1
|
||||
data.number, on_each_side=2, on_ends=1
|
||||
)
|
||||
|
||||
return render(
|
||||
request,
|
||||
"home.html",
|
||||
self.template,
|
||||
{
|
||||
"title": "Home",
|
||||
"rolling_stock": rolling_stock,
|
||||
"title": self.title,
|
||||
"data": data,
|
||||
"matches": paginator.count,
|
||||
"page_range": page_range,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
class GetHomeFiltered(View):
|
||||
class GetRoster(GetData):
|
||||
def __init__(self):
|
||||
self.title = "Rolling stock"
|
||||
self.template = "roster.html"
|
||||
self.data = RollingStock.objects.order_by(*order_by_fields())
|
||||
|
||||
|
||||
class SearchRoster(View):
|
||||
def run_search(self, request, search, _filter, page=1):
|
||||
site_conf = get_site_conf()
|
||||
if _filter == "search":
|
||||
if _filter is None:
|
||||
query = reduce(
|
||||
operator.or_,
|
||||
(
|
||||
@@ -76,23 +90,32 @@ class GetHomeFiltered(View):
|
||||
for s in search.split()
|
||||
),
|
||||
)
|
||||
elif _filter == "type":
|
||||
query = Q(
|
||||
Q(rolling_class__type__type__icontains=search)
|
||||
| Q(rolling_class__type__category__icontains=search)
|
||||
)
|
||||
elif _filter == "company":
|
||||
query = Q(
|
||||
Q(rolling_class__company__name__icontains=search)
|
||||
| Q(rolling_class__company__extended_name__icontains=search)
|
||||
)
|
||||
elif _filter == "manufacturer":
|
||||
query = Q(
|
||||
Q(manufacturer__name__icontains=search)
|
||||
| Q(rolling_class__manufacturer__name__icontains=search)
|
||||
)
|
||||
elif _filter == "scale":
|
||||
query = Q(scale__scale__iexact=search)
|
||||
elif _filter == "tag":
|
||||
query = Q(tags__slug__iexact=search)
|
||||
query = Q(scale__scale__icontains=search)
|
||||
else:
|
||||
raise Http404
|
||||
|
||||
rolling_stock = (
|
||||
RollingStock.objects.filter(query)
|
||||
.distinct()
|
||||
.order_by(*order_by_fields())
|
||||
)
|
||||
matches = len(rolling_stock)
|
||||
matches = rolling_stock.count()
|
||||
|
||||
paginator = Paginator(rolling_stock, site_conf.items_per_page)
|
||||
rolling_stock = paginator.get_page(page)
|
||||
@@ -102,41 +125,105 @@ class GetHomeFiltered(View):
|
||||
|
||||
return rolling_stock, matches, page_range
|
||||
|
||||
def get(self, request, search, _filter="search", page=1):
|
||||
def split_search(self, search):
|
||||
search = search.strip().split(":")
|
||||
if not search:
|
||||
raise Http404
|
||||
elif len(search) == 1: # no filter
|
||||
_filter = None
|
||||
search = search[0].strip()
|
||||
elif len(search) == 2: # filter: search
|
||||
_filter = search[0].strip().lower()
|
||||
search = search[1].strip()
|
||||
else:
|
||||
return HttpResponseBadRequest
|
||||
|
||||
return _filter, search
|
||||
|
||||
def get(self, request, search, page=1):
|
||||
try:
|
||||
encoded_search = search
|
||||
search = base64.b64decode(search.encode()).decode()
|
||||
except Exception:
|
||||
encoded_search = base64.b64encode(
|
||||
search.encode()).decode()
|
||||
_filter, keyword = self.split_search(search)
|
||||
rolling_stock, matches, page_range = self.run_search(
|
||||
request, search, _filter, page
|
||||
request, keyword, _filter, page
|
||||
)
|
||||
|
||||
return render(
|
||||
request,
|
||||
"search.html",
|
||||
{
|
||||
"title": "{0}: {1}".format(_filter.capitalize(), search),
|
||||
"title": "Search: \"{}\"".format(search),
|
||||
"search": search,
|
||||
"filter": _filter,
|
||||
"encoded_search": encoded_search,
|
||||
"matches": matches,
|
||||
"rolling_stock": rolling_stock,
|
||||
"data": rolling_stock,
|
||||
"page_range": page_range,
|
||||
},
|
||||
)
|
||||
|
||||
def post(self, request, _filter="search", page=1):
|
||||
def post(self, request, page=1):
|
||||
search = request.POST.get("search")
|
||||
if not search:
|
||||
return self.get(request, search, page)
|
||||
|
||||
|
||||
class GetRosterFiltered(View):
|
||||
def run_filter(self, request, search, _filter, page=1):
|
||||
site_conf = get_site_conf()
|
||||
if _filter == "type":
|
||||
title = RollingStockType.objects.get(slug__iexact=search)
|
||||
query = Q(rolling_class__type__slug__iexact=search)
|
||||
elif _filter == "company":
|
||||
title = get_object_or_404(Company, slug__iexact=search)
|
||||
query = Q(rolling_class__company__slug__iexact=search)
|
||||
elif _filter == "manufacturer":
|
||||
title = get_object_or_404(Manufacturer, slug__iexact=search)
|
||||
query = Q(
|
||||
Q(rolling_class__manufacturer__slug__iexact=search)
|
||||
| Q(manufacturer__slug__iexact=search)
|
||||
)
|
||||
elif _filter == "scale":
|
||||
title = get_object_or_404(Scale, slug__iexact=search)
|
||||
query = Q(scale__slug__iexact=search)
|
||||
elif _filter == "tag":
|
||||
title = get_object_or_404(Tag, slug__iexact=search)
|
||||
query = Q(tags__slug__iexact=search)
|
||||
else:
|
||||
raise Http404
|
||||
rolling_stock, matches, page_range = self.run_search(
|
||||
request, search, _filter, page
|
||||
|
||||
rolling_stock = (
|
||||
RollingStock.objects.filter(query)
|
||||
.distinct()
|
||||
.order_by(*order_by_fields())
|
||||
)
|
||||
matches = rolling_stock.count()
|
||||
|
||||
paginator = Paginator(rolling_stock, site_conf.items_per_page)
|
||||
rolling_stock = paginator.get_page(page)
|
||||
page_range = paginator.get_elided_page_range(
|
||||
rolling_stock.number, on_each_side=2, on_ends=1
|
||||
)
|
||||
|
||||
return rolling_stock, title, matches, page_range
|
||||
|
||||
def get(self, request, search, _filter, page=1):
|
||||
data, title, matches, page_range = self.run_filter(
|
||||
request, unquote(search), _filter, page
|
||||
)
|
||||
|
||||
return render(
|
||||
request,
|
||||
"search.html",
|
||||
"filter.html",
|
||||
{
|
||||
"title": "{0}: {1}".format(_filter.capitalize(), search),
|
||||
"title": "{0}: {1}".format(
|
||||
_filter.capitalize(), title),
|
||||
"search": search,
|
||||
"filter": _filter,
|
||||
"matches": matches,
|
||||
"rolling_stock": rolling_stock,
|
||||
"data": data,
|
||||
"page_range": page_range,
|
||||
},
|
||||
)
|
||||
@@ -181,26 +268,11 @@ class GetRollingStock(View):
|
||||
)
|
||||
|
||||
|
||||
class Consists(View):
|
||||
def get(self, request, page=1):
|
||||
site_conf = get_site_conf()
|
||||
consist = Consist.objects.all()
|
||||
|
||||
paginator = Paginator(consist, site_conf.items_per_page)
|
||||
consist = paginator.get_page(page)
|
||||
page_range = paginator.get_elided_page_range(
|
||||
consist.number, on_each_side=2, on_ends=1
|
||||
)
|
||||
|
||||
return render(
|
||||
request,
|
||||
"consists.html",
|
||||
{
|
||||
"title": "Consists",
|
||||
"consist": consist,
|
||||
"page_range": page_range,
|
||||
},
|
||||
)
|
||||
class Consists(GetData):
|
||||
def __init__(self):
|
||||
self.title = "Consists"
|
||||
self.template = "consists.html"
|
||||
self.data = Consist.objects.all()
|
||||
|
||||
|
||||
class GetConsist(View):
|
||||
@@ -210,7 +282,10 @@ class GetConsist(View):
|
||||
consist = Consist.objects.get(uuid=uuid)
|
||||
except ObjectDoesNotExist:
|
||||
raise Http404
|
||||
rolling_stock = consist.consist_item.all()
|
||||
rolling_stock = [
|
||||
RollingStock.objects.get(uuid=r.rolling_stock_id) for r in
|
||||
consist.consist_item.all()
|
||||
]
|
||||
|
||||
paginator = Paginator(rolling_stock, site_conf.items_per_page)
|
||||
rolling_stock = paginator.get_page(page)
|
||||
@@ -224,50 +299,45 @@ class GetConsist(View):
|
||||
{
|
||||
"title": consist,
|
||||
"consist": consist,
|
||||
"rolling_stock": rolling_stock,
|
||||
"data": rolling_stock,
|
||||
"page_range": page_range,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
class Companies(View):
|
||||
def get(self, request, page=1):
|
||||
site_conf = get_site_conf()
|
||||
company = Company.objects.all()
|
||||
class Manufacturers(GetData):
|
||||
def __init__(self):
|
||||
self.title = "Manufacturers"
|
||||
self.template = "manufacturers.html"
|
||||
self.data = None # Set via method get
|
||||
|
||||
paginator = Paginator(company, site_conf.items_per_page)
|
||||
company = paginator.get_page(page)
|
||||
page_range = paginator.get_elided_page_range(
|
||||
company.number, on_each_side=2, on_ends=1
|
||||
)
|
||||
|
||||
return render(
|
||||
request,
|
||||
"companies.html",
|
||||
{
|
||||
"title": "Companies",
|
||||
"company": company,
|
||||
"page_range": page_range,
|
||||
},
|
||||
)
|
||||
# overload get method to filter by category
|
||||
def get(self, request, category, page=1):
|
||||
if category not in ("real", "model"):
|
||||
raise Http404
|
||||
self.data = Manufacturer.objects.filter(category=category)
|
||||
return super().get(request, page)
|
||||
|
||||
|
||||
class Scales(View):
|
||||
def get(self, request, page=1):
|
||||
site_conf = get_site_conf()
|
||||
scale = Scale.objects.all()
|
||||
class Companies(GetData):
|
||||
def __init__(self):
|
||||
self.title = "Companies"
|
||||
self.template = "companies.html"
|
||||
self.data = Company.objects.all()
|
||||
|
||||
paginator = Paginator(scale, site_conf.items_per_page)
|
||||
scale = paginator.get_page(page)
|
||||
page_range = paginator.get_elided_page_range(
|
||||
scale.number, on_each_side=2, on_ends=1
|
||||
)
|
||||
|
||||
return render(
|
||||
request,
|
||||
"scales.html",
|
||||
{"title": "Scales", "scale": scale, "page_range": page_range},
|
||||
)
|
||||
class Scales(GetData):
|
||||
def __init__(self):
|
||||
self.title = "Scales"
|
||||
self.template = "scales.html"
|
||||
self.data = Scale.objects.all()
|
||||
|
||||
|
||||
class Types(GetData):
|
||||
def __init__(self):
|
||||
self.title = "Types"
|
||||
self.template = "types.html"
|
||||
self.data = RollingStockType.objects.all()
|
||||
|
||||
|
||||
class GetFlatpage(View):
|
||||
|
@@ -1,4 +1,4 @@
|
||||
from ram.utils import git_suffix
|
||||
|
||||
__version__ = "0.0.29"
|
||||
__version__ = "0.3.1"
|
||||
__version__ += git_suffix(__file__)
|
||||
|
@@ -156,7 +156,12 @@ DECODER_INTERFACES = [
|
||||
(5, "Next18/Next18S"),
|
||||
]
|
||||
|
||||
MANUFACTURER_TYPES = [("model", "Model"), ("real", "Real")]
|
||||
MANUFACTURER_TYPES = [
|
||||
("model", "Model"),
|
||||
("real", "Real"),
|
||||
("accessory", "Accessory"),
|
||||
("other", "Other")
|
||||
]
|
||||
|
||||
ROLLING_STOCK_TYPES = [
|
||||
("engine", "Engine"),
|
||||
|
1
requirements-prod.txt
Normal file
1
requirements-prod.txt
Normal file
@@ -0,0 +1 @@
|
||||
gunicorn
|
Reference in New Issue
Block a user