mirror of
https://github.com/daniviga/django-ram.git
synced 2025-08-07 14:47:49 +02:00
Compare commits
42 Commits
Author | SHA1 | Date | |
---|---|---|---|
9b8ec6ba6b
|
|||
c0b1b0b37b
|
|||
169763e237 | |||
bbe0758c6b
|
|||
c73305fd85
|
|||
4a3fbda3dc
|
|||
295965710f | |||
c152f43aa6
|
|||
8ed92dc5f0
|
|||
b70aa27a13
|
|||
3860ed70fd
|
|||
68a18fcf58 | |||
e45d11d4b1
|
|||
32b5522a1e | |||
89b666dab2 | |||
ffad964373
|
|||
538dc0bd80
|
|||
8bd2635c28
|
|||
feda1f6cb4
|
|||
2c851b2822
|
|||
e5ba2cfaec | |||
091f426242
|
|||
f603fd3e2d
|
|||
a3b2112e03
|
|||
055b0bab59
|
|||
3aea2ae340 | |||
242fe6814d
|
|||
90ffadb2ab
|
|||
21bf09687a
|
|||
c1a45ad4c9
|
|||
29180572c1
|
|||
d30d9fc9ed
|
|||
4ed95d0edf
|
|||
24bd2aa53c
|
|||
5ef51cb9b7
|
|||
65493ba068 | |||
ca459c467b
|
|||
7cc917d9f7
|
|||
0fe0644d1b
|
|||
f7987f06d5
|
|||
602c8359e9
|
|||
46477c4576
|
2
.github/workflows/django.yml
vendored
2
.github/workflows/django.yml
vendored
@@ -13,7 +13,7 @@ jobs:
|
||||
strategy:
|
||||
max-parallel: 2
|
||||
matrix:
|
||||
python-version: ['3.9', '3.10']
|
||||
python-version: ['3.9', '3.10', '3.11']
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
@@ -21,7 +21,7 @@ it has been developed with a commitment of few minutes a day;
|
||||
it lacks any kind of documentation, code review, architectural review,
|
||||
security assesment, pentest, ISO certification, etc.
|
||||
|
||||
This project probably doesn't match you needs nor expectations. Be aware.
|
||||
This project probably doesn't match your needs nor expectations. Be aware.
|
||||
|
||||
Your model train may also catch fire while using this software.
|
||||
|
||||
@@ -49,7 +49,7 @@ It has been developed with:
|
||||
|
||||
## Requirements
|
||||
|
||||
- Python 3.8+
|
||||
- Python 3.9+
|
||||
- A USB port when running Arduino hardware (and adaptors if you have a Mac)
|
||||
|
||||
## Web portal installation
|
||||
|
Submodule arduino/CommandStation-EX updated: c47dd101a5...aca9c9c941
Submodule arduino/WebThrottle-EX updated: ca33f6a1e3...c67e4080d0
Submodule arduino/arduino-cli updated: c1b10f562f...76251df924
Submodule arduino/dcc-ex.github.io updated: a4367c9df0...d1e5c92c7b
Submodule arduino/vim-arduino updated: bf371b9690...4651b71223
@@ -21,6 +21,7 @@ class ConsistAdmin(SortableAdminBase, admin.ModelAdmin):
|
||||
list_display = ("identifier", "company", "era")
|
||||
list_filter = list_display
|
||||
search_fields = list_display
|
||||
save_as = True
|
||||
|
||||
fieldsets = (
|
||||
(
|
||||
|
19
ram/consist/migrations/0005_alter_consist_notes.py
Normal file
19
ram/consist/migrations/0005_alter_consist_notes.py
Normal file
@@ -0,0 +1,19 @@
|
||||
# Generated by Django 4.1 on 2022-08-23 15:54
|
||||
|
||||
import ckeditor_uploader.fields
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("consist", "0004_alter_consist_company"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="consist",
|
||||
name="notes",
|
||||
field=ckeditor_uploader.fields.RichTextUploadingField(blank=True),
|
||||
),
|
||||
]
|
34
ram/consist/migrations/0006_md_to_html.py
Normal file
34
ram/consist/migrations/0006_md_to_html.py
Normal file
@@ -0,0 +1,34 @@
|
||||
# Generated by Django 4.1 on 2022-08-24 15:30
|
||||
|
||||
import markdown
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def md_to_html(apps, schema_editor):
|
||||
fields = {
|
||||
"Consist": ["notes"],
|
||||
}
|
||||
|
||||
for m in fields.items():
|
||||
model = apps.get_model("consist", m[0])
|
||||
|
||||
for row in model.objects.all():
|
||||
for field in m[1]:
|
||||
html = markdown.markdown(getattr(row, field))
|
||||
row.__dict__[field] = html
|
||||
|
||||
row.save(update_fields=m[1])
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("consist", "0005_alter_consist_notes"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(
|
||||
md_to_html,
|
||||
reverse_code=migrations.RunPython.noop
|
||||
),
|
||||
]
|
24
ram/consist/migrations/0007_alter_consist_image.py
Normal file
24
ram/consist/migrations/0007_alter_consist_image.py
Normal file
@@ -0,0 +1,24 @@
|
||||
# Generated by Django 4.1.2 on 2022-11-27 00:10
|
||||
|
||||
from django.db import migrations, models
|
||||
import ram.utils
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("consist", "0006_md_to_html"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="consist",
|
||||
name="image",
|
||||
field=models.ImageField(
|
||||
blank=True,
|
||||
null=True,
|
||||
storage=ram.utils.DeduplicatedStorage,
|
||||
upload_to="images/",
|
||||
),
|
||||
),
|
||||
]
|
17
ram/consist/migrations/0008_alter_consist_options.py
Normal file
17
ram/consist/migrations/0008_alter_consist_options.py
Normal file
@@ -0,0 +1,17 @@
|
||||
# Generated by Django 4.1.3 on 2023-01-02 15:03
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("consist", "0007_alter_consist_image"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name="consist",
|
||||
options={"ordering": ["company", "-creation_time"]},
|
||||
),
|
||||
]
|
@@ -2,6 +2,9 @@ from uuid import uuid4
|
||||
from django.db import models
|
||||
from django.urls import reverse
|
||||
|
||||
from ckeditor_uploader.fields import RichTextUploadingField
|
||||
|
||||
from ram.utils import DeduplicatedStorage
|
||||
from metadata.models import Company, Tag
|
||||
from roster.models import RollingStock
|
||||
|
||||
@@ -15,8 +18,10 @@ class Consist(models.Model):
|
||||
)
|
||||
company = models.ForeignKey(Company, on_delete=models.CASCADE)
|
||||
era = models.CharField(max_length=32, blank=True)
|
||||
image = models.ImageField(upload_to="images/", null=True, blank=True)
|
||||
notes = models.TextField(blank=True)
|
||||
image = models.ImageField(
|
||||
upload_to="images/", storage=DeduplicatedStorage, null=True, blank=True
|
||||
)
|
||||
notes = RichTextUploadingField(blank=True)
|
||||
creation_time = models.DateTimeField(auto_now_add=True)
|
||||
updated_time = models.DateTimeField(auto_now=True)
|
||||
|
||||
@@ -27,7 +32,7 @@ class Consist(models.Model):
|
||||
return reverse("consist", kwargs={"uuid": self.uuid})
|
||||
|
||||
class Meta:
|
||||
ordering = ["creation_time"]
|
||||
ordering = ["company", "-creation_time"]
|
||||
|
||||
|
||||
class ConsistItem(models.Model):
|
||||
|
@@ -20,8 +20,8 @@ class PropertyAdmin(admin.ModelAdmin):
|
||||
@admin.register(Decoder)
|
||||
class DecoderAdmin(admin.ModelAdmin):
|
||||
readonly_fields = ("image_thumbnail",)
|
||||
list_display = ("__str__", "interface")
|
||||
list_filter = ("manufacturer", "interface")
|
||||
list_display = ("__str__", "sound")
|
||||
list_filter = ("manufacturer", "sound")
|
||||
search_fields = ("name", "manufacturer__name")
|
||||
|
||||
|
||||
|
18
ram/metadata/migrations/0008_remove_decoder_interface.py
Normal file
18
ram/metadata/migrations/0008_remove_decoder_interface.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 4.1.2 on 2022-10-31 23:01
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("metadata", "0007_rename_track_scale_tracks"),
|
||||
("roster", "0013_rollingstock_decoder_interface"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name="decoder",
|
||||
name="interface",
|
||||
),
|
||||
]
|
@@ -0,0 +1,44 @@
|
||||
# Generated by Django 4.1.2 on 2022-11-27 00:10
|
||||
|
||||
from django.db import migrations, models
|
||||
import ram.utils
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("metadata", "0008_remove_decoder_interface"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="company",
|
||||
name="logo",
|
||||
field=models.ImageField(
|
||||
blank=True,
|
||||
null=True,
|
||||
storage=ram.utils.DeduplicatedStorage,
|
||||
upload_to="images/",
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="decoder",
|
||||
name="image",
|
||||
field=models.ImageField(
|
||||
blank=True,
|
||||
null=True,
|
||||
storage=ram.utils.DeduplicatedStorage,
|
||||
upload_to="images/",
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="manufacturer",
|
||||
name="logo",
|
||||
field=models.ImageField(
|
||||
blank=True,
|
||||
null=True,
|
||||
storage=ram.utils.DeduplicatedStorage,
|
||||
upload_to="images/",
|
||||
),
|
||||
),
|
||||
]
|
@@ -3,7 +3,7 @@ from django.conf import settings
|
||||
from django.dispatch.dispatcher import receiver
|
||||
from django_countries.fields import CountryField
|
||||
|
||||
from ram.utils import get_image_preview, slugify
|
||||
from ram.utils import DeduplicatedStorage, get_image_preview, slugify
|
||||
|
||||
|
||||
class Property(models.Model):
|
||||
@@ -24,7 +24,9 @@ class Manufacturer(models.Model):
|
||||
max_length=64, choices=settings.MANUFACTURER_TYPES
|
||||
)
|
||||
website = models.URLField(blank=True)
|
||||
logo = models.ImageField(upload_to="images/", null=True, blank=True)
|
||||
logo = models.ImageField(
|
||||
upload_to="images/", storage=DeduplicatedStorage, null=True, blank=True
|
||||
)
|
||||
|
||||
class Meta:
|
||||
ordering = ["category", "name"]
|
||||
@@ -43,7 +45,9 @@ class Company(models.Model):
|
||||
extended_name = models.CharField(max_length=128, blank=True)
|
||||
country = CountryField()
|
||||
freelance = models.BooleanField(default=False)
|
||||
logo = models.ImageField(upload_to="images/", null=True, blank=True)
|
||||
logo = models.ImageField(
|
||||
upload_to="images/", storage=DeduplicatedStorage, null=True, blank=True
|
||||
)
|
||||
|
||||
class Meta:
|
||||
verbose_name_plural = "Companies"
|
||||
@@ -66,11 +70,10 @@ class Decoder(models.Model):
|
||||
limit_choices_to={"category": "model"},
|
||||
)
|
||||
version = models.CharField(max_length=64, blank=True)
|
||||
interface = models.PositiveSmallIntegerField(
|
||||
choices=settings.DECODER_INTERFACES, null=True, blank=True
|
||||
)
|
||||
sound = models.BooleanField(default=False)
|
||||
image = models.ImageField(upload_to="images/", null=True, blank=True)
|
||||
image = models.ImageField(
|
||||
upload_to="images/", storage=DeduplicatedStorage, null=True, blank=True
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
return "{0} - {1}".format(self.manufacturer, self.name)
|
||||
|
@@ -1,6 +1,66 @@
|
||||
from django.contrib import admin
|
||||
from solo.admin import SingletonModelAdmin
|
||||
|
||||
from portal.models import SiteConfiguration
|
||||
from portal.models import SiteConfiguration, Flatpage
|
||||
|
||||
admin.site.register(SiteConfiguration, SingletonModelAdmin)
|
||||
@admin.register(SiteConfiguration)
|
||||
class SiteConfigurationAdmin(SingletonModelAdmin):
|
||||
fieldsets = (
|
||||
(
|
||||
None,
|
||||
{
|
||||
"fields": (
|
||||
"site_name",
|
||||
"site_author",
|
||||
"about",
|
||||
"items_per_page",
|
||||
"items_ordering",
|
||||
"footer",
|
||||
"footer_extended",
|
||||
)
|
||||
},
|
||||
),
|
||||
(
|
||||
"Advanced",
|
||||
{
|
||||
"classes": ("collapse",),
|
||||
"fields": (
|
||||
"show_version",
|
||||
"use_cdn",
|
||||
"extra_head",
|
||||
),
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@admin.register(Flatpage)
|
||||
class FlatpageAdmin(admin.ModelAdmin):
|
||||
readonly_fields = ("path", "creation_time", "updated_time")
|
||||
list_display = ("name", "path", "published", "get_link")
|
||||
list_filter = ("published",)
|
||||
search_fields = ("name",)
|
||||
|
||||
fieldsets = (
|
||||
(
|
||||
None,
|
||||
{
|
||||
"fields": (
|
||||
"name",
|
||||
"path",
|
||||
"content",
|
||||
"published",
|
||||
)
|
||||
},
|
||||
),
|
||||
(
|
||||
"Audit",
|
||||
{
|
||||
"classes": ("collapse",),
|
||||
"fields": (
|
||||
"creation_time",
|
||||
"updated_time",
|
||||
),
|
||||
},
|
||||
),
|
||||
)
|
||||
|
22
ram/portal/migrations/0008_flatpage.py
Normal file
22
ram/portal/migrations/0008_flatpage.py
Normal file
@@ -0,0 +1,22 @@
|
||||
# Generated by Django 4.0.6 on 2022-08-07 15:01
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('portal', '0007_siteconfiguration_items_ordering'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Flatpage',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=256, unique=True)),
|
||||
('draft', models.BooleanField(default=True)),
|
||||
('content', models.TextField(blank=True)),
|
||||
],
|
||||
),
|
||||
]
|
19
ram/portal/migrations/0009_flatpage_path.py
Normal file
19
ram/portal/migrations/0009_flatpage_path.py
Normal file
@@ -0,0 +1,19 @@
|
||||
# Generated by Django 4.0.6 on 2022-08-07 15:19
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('portal', '0008_flatpage'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='flatpage',
|
||||
name='path',
|
||||
field=models.CharField(default='', max_length=256, unique=True),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
@@ -0,0 +1,25 @@
|
||||
# Generated by Django 4.0.6 on 2022-08-07 15:46
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.utils.timezone
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('portal', '0009_flatpage_path'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='flatpage',
|
||||
name='creation_time',
|
||||
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
|
||||
preserve_default=False,
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='flatpage',
|
||||
name='updated_time',
|
||||
field=models.DateTimeField(auto_now=True),
|
||||
),
|
||||
]
|
@@ -0,0 +1,35 @@
|
||||
# Generated by Django 4.1 on 2022-08-23 15:54
|
||||
|
||||
import ckeditor.fields
|
||||
import ckeditor_uploader.fields
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("portal", "0010_flatpage_creation_time_flatpage_updated_time"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="flatpage",
|
||||
name="content",
|
||||
field=ckeditor_uploader.fields.RichTextUploadingField(),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="siteconfiguration",
|
||||
name="about",
|
||||
field=ckeditor.fields.RichTextField(blank=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="siteconfiguration",
|
||||
name="footer",
|
||||
field=ckeditor.fields.RichTextField(blank=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="siteconfiguration",
|
||||
name="footer_extended",
|
||||
field=ckeditor.fields.RichTextField(blank=True),
|
||||
),
|
||||
]
|
38
ram/portal/migrations/0012_md_to_html.py
Normal file
38
ram/portal/migrations/0012_md_to_html.py
Normal file
@@ -0,0 +1,38 @@
|
||||
# Generated by Django 4.1 on 2022-08-24 15:00
|
||||
|
||||
import markdown
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def md_to_html(apps, schema_editor):
|
||||
fields = {
|
||||
"SiteConfiguration": ["about", "footer", "footer_extended"],
|
||||
"Flatpage": ["content"]
|
||||
}
|
||||
|
||||
for m in fields.items():
|
||||
model = apps.get_model("portal", m[0])
|
||||
|
||||
for row in model.objects.all():
|
||||
for field in m[1]:
|
||||
html = markdown.markdown(getattr(row, field))
|
||||
row.__dict__[field] = html
|
||||
|
||||
row.save(update_fields=m[1])
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
(
|
||||
"portal",
|
||||
"0011_alter_flatpage_content_alter_siteconfiguration_about_and_more",
|
||||
),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(
|
||||
md_to_html,
|
||||
reverse_code=migrations.RunPython.noop
|
||||
),
|
||||
]
|
@@ -0,0 +1,42 @@
|
||||
# Generated by Django 4.1 on 2022-08-25 10:18
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
def reverse_bool(apps, schema_editor):
|
||||
model = apps.get_model("portal", "Flatpage")
|
||||
|
||||
for row in model.objects.all():
|
||||
row.published = not row.draft
|
||||
row.save(update_fields=["published"])
|
||||
|
||||
|
||||
def reverse_bool_back(apps, schema_editor):
|
||||
model = apps.get_model("portal", "Flatpage")
|
||||
|
||||
for row in model.objects.all():
|
||||
row.draft = not row.published
|
||||
row.save(update_fields=["draft"])
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("portal", "0012_md_to_html"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="flatpage",
|
||||
name="published",
|
||||
field=models.BooleanField(default=False),
|
||||
),
|
||||
migrations.RunPython(
|
||||
reverse_bool,
|
||||
reverse_code=reverse_bool_back
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name="flatpage",
|
||||
name="draft",
|
||||
),
|
||||
]
|
18
ram/portal/migrations/0014_siteconfiguration_extra_head.py
Normal file
18
ram/portal/migrations/0014_siteconfiguration_extra_head.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 4.1.3 on 2022-12-28 22:43
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("portal", "0013_remove_flatpage_draft_flatpage_published"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="siteconfiguration",
|
||||
name="extra_head",
|
||||
field=models.TextField(blank=True),
|
||||
),
|
||||
]
|
18
ram/portal/migrations/0015_siteconfiguration_use_cdn.py
Normal file
18
ram/portal/migrations/0015_siteconfiguration_use_cdn.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 4.1.5 on 2023-01-03 15:01
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("portal", "0014_siteconfiguration_extra_head"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="siteconfiguration",
|
||||
name="use_cdn",
|
||||
field=models.BooleanField(default=True),
|
||||
),
|
||||
]
|
@@ -1,8 +1,15 @@
|
||||
import django
|
||||
from django.db import models
|
||||
from django.urls import reverse
|
||||
from django.dispatch.dispatcher import receiver
|
||||
from django.utils.safestring import mark_safe
|
||||
from solo.models import SingletonModel
|
||||
|
||||
from ckeditor.fields import RichTextField
|
||||
from ckeditor_uploader.fields import RichTextUploadingField
|
||||
|
||||
from ram import __version__ as app_version
|
||||
from solo.models import SingletonModel
|
||||
from ram.utils import slugify
|
||||
|
||||
|
||||
class SiteConfiguration(SingletonModel):
|
||||
@@ -10,7 +17,7 @@ class SiteConfiguration(SingletonModel):
|
||||
max_length=256, default="Railroad Assets Manager"
|
||||
)
|
||||
site_author = models.CharField(max_length=256, blank=True)
|
||||
about = models.TextField(blank=True)
|
||||
about = RichTextField(blank=True)
|
||||
items_per_page = models.CharField(
|
||||
max_length=2,
|
||||
choices=[(str(x * 3), str(x * 3)) for x in range(2, 11)],
|
||||
@@ -25,9 +32,11 @@ class SiteConfiguration(SingletonModel):
|
||||
],
|
||||
default="type",
|
||||
)
|
||||
footer = models.TextField(blank=True)
|
||||
footer_extended = models.TextField(blank=True)
|
||||
footer = RichTextField(blank=True)
|
||||
footer_extended = RichTextField(blank=True)
|
||||
show_version = models.BooleanField(default=True)
|
||||
use_cdn = models.BooleanField(default=True)
|
||||
extra_head = models.TextField(blank=True)
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Site Configuration"
|
||||
@@ -40,3 +49,31 @@ class SiteConfiguration(SingletonModel):
|
||||
|
||||
def django_version(self):
|
||||
return django.get_version()
|
||||
|
||||
|
||||
class Flatpage(models.Model):
|
||||
name = models.CharField(max_length=256, unique=True)
|
||||
path = models.CharField(max_length=256, unique=True)
|
||||
published = models.BooleanField(default=False)
|
||||
content = RichTextUploadingField()
|
||||
creation_time = models.DateTimeField(auto_now_add=True)
|
||||
updated_time = models.DateTimeField(auto_now=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse("flatpage", kwargs={"flatpage": self.path})
|
||||
|
||||
def get_link(self):
|
||||
if self.published:
|
||||
return mark_safe(
|
||||
'<a href="{0}" target="_blank">Link</a>'.format(
|
||||
self.get_absolute_url()
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@receiver(models.signals.pre_save, sender=Flatpage)
|
||||
def tag_pre_save(sender, instance, **kwargs):
|
||||
instance.path = slugify(instance.name)
|
||||
|
2018
ram/portal/static/bootstrap-icons@1.10.3/font/bootstrap-icons.css
vendored
Normal file
2018
ram/portal/static/bootstrap-icons@1.10.3/font/bootstrap-icons.css
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -1,3 +1,8 @@
|
||||
/* Switch SVG logo to white on dark mode */
|
||||
html.dark .navbar-light svg {
|
||||
fill: #fff;
|
||||
}
|
||||
|
||||
.card > a > img {
|
||||
width: 100%;
|
||||
}
|
||||
@@ -11,10 +16,6 @@ a.badge, a.badge:hover {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.tab-pane {
|
||||
min-height: 300px;
|
||||
}
|
||||
|
||||
.img-thumbnail {
|
||||
padding: 0;
|
||||
}
|
||||
@@ -23,6 +24,15 @@ a.badge, a.badge:hover {
|
||||
padding: .5rem;
|
||||
}
|
||||
|
||||
#nav-journal ul, #nav-journal ol {
|
||||
margin: 0;
|
||||
padding-left: 1rem;
|
||||
}
|
||||
|
||||
#nav-journal p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#footer > p {
|
||||
display: inline;
|
||||
}
|
||||
|
BIN
ram/portal/static/favicon.png
Normal file
BIN
ram/portal/static/favicon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
9
ram/portal/static/favicon.svg
Normal file
9
ram/portal/static/favicon.svg
Normal file
@@ -0,0 +1,9 @@
|
||||
<svg 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>
|
After Width: | Height: | Size: 1.1 KiB |
@@ -1,6 +1,6 @@
|
||||
{% load static %}
|
||||
{% load solo_tags %}
|
||||
{% load markdown %}
|
||||
{% load show_menu %}
|
||||
{% get_solo 'portal.SiteConfiguration' as site_conf %}
|
||||
|
||||
<!doctype html>
|
||||
@@ -12,10 +12,17 @@
|
||||
<meta name="description" content="{{ site_conf.about}}">
|
||||
<meta name="author" content="{{ site_conf.site_author }}">
|
||||
<meta name="generator" content="Django Framework">
|
||||
<title>{{ site_conf.site_name }}</title>
|
||||
<title>{% block title %}{{ title }}{% endblock %} - {{ site_conf.site_name }}</title>
|
||||
<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="{% static "css/main.css" %}" rel="stylesheet">
|
||||
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.3/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">
|
||||
{% endif %}
|
||||
<link href="{% static "css/main.css" %}?v={{ site_conf.version }}" rel="stylesheet">
|
||||
<style>
|
||||
.bd-placeholder-img {
|
||||
font-size: 1.125rem;
|
||||
@@ -34,6 +41,10 @@
|
||||
html.dark .d-light-inline { display: none !important; }
|
||||
html.dark .d-dark-inline { display: inline !important; }
|
||||
</style>
|
||||
{% block extra_head %}
|
||||
{{ site_conf.extra_head | safe }}
|
||||
{% endblock %}
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
@@ -41,13 +52,19 @@
|
||||
<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" fill="#000" overflow="visible" stroke-width="2" style="text-indent:0;text-transform:none"/>
|
||||
<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="Basic example">
|
||||
<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="fa fa-moon-o fa-fw d-none d-light-inline" title="Switch to dark mode"></i><i class="fa fa-sun-o fa-fw d-none d-dark-inline" title="Switch to light mode"></i></a>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -71,6 +88,7 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{% url 'scales' %}">Scales</a>
|
||||
</li>
|
||||
{% show_menu %}
|
||||
</ul>
|
||||
{% include 'includes/search.html' %}
|
||||
</div>
|
||||
@@ -80,111 +98,32 @@
|
||||
<section class="py-4 text-center container">
|
||||
<div class="row">
|
||||
<div class="mx-auto">
|
||||
{% block header %}{% endblock %}
|
||||
<h1 class="fw-light">{{ title }}</h1>
|
||||
{% block header %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<div class="album py-5 bg-light">
|
||||
<div class="album py-4 bg-light">
|
||||
<div class="container">
|
||||
<a id="rolling-stock"></a>
|
||||
<div class="row row-cols-1 row-cols-sm-2 row-cols-md-3 g-3">
|
||||
{% block cards %}
|
||||
{% for r in rolling_stock %}
|
||||
<div class="col">
|
||||
<div class="card shadow-sm">
|
||||
{% for i in r.image.all %}
|
||||
{% if i.is_thumbnail %}<a href="{{r.get_absolute_url}}"><img src="{{ i.image.url }}" alt="Card image cap"></a>{% endif %}
|
||||
{% endfor %}
|
||||
<div class="card-body">
|
||||
<p class="card-text" style="position: relative;">
|
||||
<strong>{{ r }}</strong>
|
||||
<a class="stretched-link" href="{{ r.get_absolute_url }}"></a>
|
||||
</p>
|
||||
{% if r.tags.all %}
|
||||
<p class="card-text"><small>Tags:</small>
|
||||
{% for t in r.tags.all %}<a href="{% url 'filtered' _filter="tag" search=t.slug %}" class="badge rounded-pill bg-primary">
|
||||
{{ 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_class.type }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Company</th>
|
||||
<td><abbr title="{{ r.rolling_class.company.extended_name }}">{{ r.rolling_class.company }}</abbr></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Class</th>
|
||||
<td>{{ r.rolling_class.identifier }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Road number</th>
|
||||
<td>{{ r.road_number }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Era</th>
|
||||
<td>{{ r.era }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th width="35%" scope="row">Manufacturer</th>
|
||||
<td>{% if r.manufacturer.website %}<a href="{{ r.manufacturer.website }}">{% endif %}{{ r.manufacturer }}{% if r.manufacturer.website %}</a>{% endif %}</th>
|
||||
</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>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">SKU</th>
|
||||
<td>{{ r.sku }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
{% if r.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.decoder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Address</th>
|
||||
<td>{{ r.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 %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% block carousel %}
|
||||
{% endblock %}
|
||||
<a id="rolling-stock"></a>
|
||||
{% block cards_layout %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">{% block pagination %}{% endblock %}</div>
|
||||
</div>
|
||||
{% block extra_content %}{% endblock %}
|
||||
</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>
|
||||
{% 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>
|
||||
{% 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){
|
||||
|
96
ram/portal/templates/cards.html
Normal file
96
ram/portal/templates/cards.html
Normal file
@@ -0,0 +1,96 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% 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 %}
|
||||
<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 %}
|
||||
{% 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>
|
||||
</p>
|
||||
{% if r.tags.all %}
|
||||
<p class="card-text"><small>Tags:</small>
|
||||
{% for t in r.tags.all %}<a href="{% url 'filtered' _filter="tag" search=t.slug %}" class="badge rounded-pill bg-primary">
|
||||
{{ 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_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>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Class</th>
|
||||
<td>{{ r.rolling_class.identifier }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Road number</th>
|
||||
<td>{{ r.road_number }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Era</th>
|
||||
<td>{{ r.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>
|
||||
</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>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">SKU</th>
|
||||
<td>{{ r.sku }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
{% if r.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.decoder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Address</th>
|
||||
<td>{{ r.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 %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
{% endblock %}
|
@@ -1,9 +1,5 @@
|
||||
{% extends "base.html" %}
|
||||
{% load markdown %}
|
||||
{% extends "cards.html" %}
|
||||
|
||||
{% block header %}
|
||||
<h1 class="fw-light">Companies</h1>
|
||||
{% endblock %}
|
||||
{% block cards %}
|
||||
{% for c in company %}
|
||||
<div class="col">
|
||||
@@ -57,10 +53,10 @@
|
||||
{% block pagination %}
|
||||
{% if company.has_other_pages %}
|
||||
<nav aria-label="Page navigation example">
|
||||
<ul class="pagination justify-content-center mt-4">
|
||||
<ul class="pagination justify-content-center mt-4 mb-0">
|
||||
{% if company.has_previous %}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="{% url 'company_pagination' page=company.previous_page_number %}#rolling-stock" tabindex="-1">Previous</a>
|
||||
<a class="page-link" href="{% url 'companies_pagination' page=company.previous_page_number %}#rolling-stock" tabindex="-1">Previous</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="page-item disabled">
|
||||
@@ -76,13 +72,13 @@
|
||||
{% if i == company.paginator.ELLIPSIS %}
|
||||
<li class="page-item"><span class="page-link">{{ i }}</span></li>
|
||||
{% else %}
|
||||
<li class="page-item"><a class="page-link" href="{% url 'company_pagination' page=i %}#rolling-stock">{{ i }}</a></li>
|
||||
<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 %}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="{% url 'company_pagination' page=company.next_page_number %}#rolling-stock" tabindex="-1">Next</a>
|
||||
<a class="page-link" href="{% url 'companies_pagination' page=company.next_page_number %}#rolling-stock" tabindex="-1">Next</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="page-item disabled">
|
||||
|
@@ -1,8 +1,6 @@
|
||||
{% extends "base.html" %}
|
||||
{% load markdown %}
|
||||
{% extends "cards.html" %}
|
||||
|
||||
{% block header %}
|
||||
<h1 class="fw-light">{{ consist }}</h1>
|
||||
{% if consist.tags.all %}
|
||||
<p><small>Tags:</small>
|
||||
{% for t in consist.tags.all %}<a href="{% url 'filtered' _filter="tag" search=t.slug %}" class="badge rounded-pill bg-primary">
|
||||
@@ -12,12 +10,25 @@
|
||||
<small class="text-muted">Updated {{ consist.updated_time | date:"M d, Y H:i" }}</small>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
{% block carousel %}
|
||||
{% if consist.image %}
|
||||
<div class="row pb-4">
|
||||
<div id="carouselControls" class="carousel carousel-dark slide" data-bs-ride="carousel">
|
||||
<div class="carousel-inner">
|
||||
<div class="carousel-item active">
|
||||
<img src="{{ consist.image.url }}" class="d-block w-100 rounded img-thumbnail" alt="...">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</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 i.is_thumbnail %}<a href="{{r.rolling_stock.get_absolute_url}}"><img src="{{ i.image.url }}" alt="Card image cap"></a>{% endif %}
|
||||
{% 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;">
|
||||
@@ -44,7 +55,9 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Company</th>
|
||||
<td><abbr title="{{ r.rolling_stock.rolling_class.company.extended_name }}">{{ r.rolling_stock.rolling_class.company }}</abbr></td>
|
||||
<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>
|
||||
@@ -60,7 +73,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<th width="35%" scope="row">Manufacturer</th>
|
||||
<td>{% if r.rolling_stock.manufacturer.website %}<a href="{{ r.rolling_stock.manufacturer.website }}">{% endif %}{{ r.rolling_stock.manufacturer }}{% if r.rolling_stock.manufacturer.website %}</a>{% endif %}</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>
|
||||
@@ -103,7 +116,7 @@
|
||||
{% block pagination %}
|
||||
{% if rolling_stock.has_other_pages %}
|
||||
<nav aria-label="Page navigation example">
|
||||
<ul class="pagination justify-content-center mt-4">
|
||||
<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 'consist_pagination' uuid=consist.uuid page=rolling_stock.previous_page_number %}#rolling-stock" tabindex="-1">Previous</a>
|
||||
@@ -143,6 +156,51 @@
|
||||
<section class="py-4 text-start container">
|
||||
<div class="row">
|
||||
<div class="mx-auto">
|
||||
<nav>
|
||||
<div class="nav nav-tabs" id="nav-tab" role="tablist">
|
||||
<button class="nav-link active" id="nav-summary-tab" data-bs-toggle="tab" data-bs-target="#nav-summary" type="button" role="tab" aria-controls="nav-summary" aria-selected="true">Summary</button>
|
||||
{% if consist.notes %}<button class="nav-link" id="nav-notes-tab" data-bs-toggle="tab" data-bs-target="#nav-notes" type="button" role="tab" aria-controls="nav-notes" aria-selected="false">Notes</button>{% endif %}
|
||||
</div>
|
||||
</nav>
|
||||
<div class="tab-content" id="nav-tabContent">
|
||||
<div class="tab-pane fade show active" id="nav-summary" role="tabpanel" aria-labelledby="nav-summary-tab">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2" scope="row">Data</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th width="35%" scope="row">Company</th>
|
||||
<td><abbr title="{{ consist.company.extended_name }}">{{ consist.company }}</abbr></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Era</th>
|
||||
<td>{{ consist.era }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Length</th>
|
||||
<td>{{ rolling_stock | length }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="tab-pane fade" id="nav-notes" role="tabpanel" aria-labelledby="nav-notes-tab">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="row">Notes</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>{{ consist.notes | safe }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-grid gap-2 d-md-flex justify-content-md-end">
|
||||
{% if request.user.is_staff %}<a class="btn btn-sm btn-outline-danger" href="{% url 'admin:consist_consist_change' consist.pk %}">Edit</a>{% endif %}
|
||||
</div>
|
||||
|
@@ -1,9 +1,5 @@
|
||||
{% extends "base.html" %}
|
||||
{% load markdown %}
|
||||
{% extends "cards.html" %}
|
||||
|
||||
{% block header %}
|
||||
<h1 class="fw-light">Consists</h1>
|
||||
{% endblock %}
|
||||
{% block cards %}
|
||||
{% for c in consist %}
|
||||
<div class="col">
|
||||
@@ -14,7 +10,7 @@
|
||||
{% else %}
|
||||
{% with c.consist_item.first.rolling_stock as r %}
|
||||
{% for i in r.image.all %}
|
||||
{% if i.is_thumbnail %}<img src="{{ i.image.url }}" alt="Card image cap">{% endif %}
|
||||
{% if forloop.first %}<img src="{{ i.image.url }}" alt="Card image cap">{% endif %}
|
||||
{% endfor %}
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
@@ -70,7 +66,7 @@
|
||||
{% block pagination %}
|
||||
{% if consist.has_other_pages %}
|
||||
<nav aria-label="Page navigation example">
|
||||
<ul class="pagination justify-content-center mt-4">
|
||||
<ul class="pagination justify-content-center mt-4 mb-0">
|
||||
{% if consist.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>
|
||||
|
17
ram/portal/templates/flatpage.html
Normal file
17
ram/portal/templates/flatpage.html
Normal file
@@ -0,0 +1,17 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block header %}
|
||||
<small class="text-muted">Updated {{ flatpage.updated_time | date:"M d, Y H:i" }}</small>
|
||||
{% endblock %}
|
||||
{% block extra_content %}
|
||||
<section class="py-4 text-start container">
|
||||
<div class="row">
|
||||
<div class="mx-auto">
|
||||
<div>{{ flatpage.content | safe }} </div>
|
||||
<div class="d-grid gap-2 d-md-flex justify-content-md-end">
|
||||
{% if request.user.is_staff %}<a class="btn btn-sm btn-outline-danger" href="{% url 'admin:portal_flatpage_change' flatpage.pk %}">Edit</a>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
{% endblock %}
|
12
ram/portal/templates/flatpage_menu.html
Normal file
12
ram/portal/templates/flatpage_menu.html
Normal file
@@ -0,0 +1,12 @@
|
||||
{% 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 ...
|
||||
</a>
|
||||
<ul class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
|
||||
{% for m in menu %}
|
||||
<li><a class="dropdown-item" href="{{ m.get_absolute_url }}">{{ m.name }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</li>
|
||||
{% endif %}
|
@@ -1,15 +1,12 @@
|
||||
{% extends "base.html" %}
|
||||
{% load markdown %}
|
||||
{% extends "cards.html" %}
|
||||
|
||||
{% block header %}
|
||||
{% if site_conf.about %}<h1 class="fw-light">About</h1>{% endif %}
|
||||
<p class="lead text-muted">{{ site_conf.about | markdown | safe }}</p>
|
||||
<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">
|
||||
<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>
|
||||
|
@@ -1,15 +1,13 @@
|
||||
{% load markdown %}
|
||||
|
||||
<footer class="text-muted py-4">
|
||||
<div class="container">
|
||||
<p class="float-end mb-1">
|
||||
<a href="#">Back to top</a>
|
||||
</p>
|
||||
<div id="footer" class="mb-1">
|
||||
<p>© {% now "Y" %}</p> {{ site_conf.footer | markdown | safe }}
|
||||
<p>© {% now "Y" %}</p> {{ site_conf.footer | safe }}
|
||||
</div>
|
||||
<div id="footer_extended" class="mb-0">
|
||||
{{ site_conf.footer_extended | markdown | safe }}
|
||||
{{ site_conf.footer_extended | safe }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@@ -1,12 +1,12 @@
|
||||
{% if request.user.is_staff %}
|
||||
<div class="dropdown">
|
||||
<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 dropdown-menu-end" aria-labelledby="dropdownMenu2">
|
||||
<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>
|
||||
@@ -14,7 +14,6 @@
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li><a class="dropdown-item text-danger" href="{% url 'admin:logout' %}?next={{ request.path }}">Logout</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
{% else %}
|
||||
<a class="btn btn-sm btn-outline-dark" href="{% url 'admin:login' %}?next={{ request.path }}">Log in</a>
|
||||
{% endif %}
|
||||
|
@@ -1,8 +1,6 @@
|
||||
{% extends 'base.html' %}
|
||||
{% load markdown %}
|
||||
|
||||
{% block header %}
|
||||
<h1 class="fw-light">{{ rolling_stock }}</h1>
|
||||
{% if rolling_stock.tags.all %}
|
||||
<p><small>Tags:</small>
|
||||
{% for t in rolling_stock.tags.all %}<a href="{% url 'filtered' _filter="tag" search=t.slug %}" class="badge rounded-pill bg-primary">
|
||||
@@ -12,29 +10,34 @@
|
||||
{% endif %}
|
||||
<small class="text-muted">Updated {{ rolling_stock.updated_time | date:"M d, Y H:i" }}</small>
|
||||
{% endblock %}
|
||||
{% block cards %}
|
||||
{% block carousel %}
|
||||
<div class="row">
|
||||
<div id="carouselControls" class="carousel carousel-dark slide" data-bs-ride="carousel" data-bs-interval="10000">
|
||||
<div class="carousel-inner">
|
||||
{% for t in rolling_stock.image.all %}
|
||||
<div class="col">
|
||||
<a href="" data-bs-toggle="modal" data-bs-target="#pictureModal{{ forloop.counter }}"><img class="img-thumbnail" src="{{ t.image.url }}" alt="Rolling stock image"></a>
|
||||
</div>
|
||||
<!-- Modal -->
|
||||
<div class="modal fade" id="pictureModal{{ forloop.counter }}" tabindex="-1" aria-labelledby="pictureModalLabel{{ forloop.counter }}" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="pictureModalLabel{{ forloop.counter }}">{{ rolling_stock }}</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body text-center">
|
||||
<img class="rounded img-fluid" src="{{ t.image.url }}" alt="Rolling stock image">
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% if forloop.first %}
|
||||
<div class="carousel-item active">
|
||||
{% else %}
|
||||
<div class="carousel-item">
|
||||
{% endif %}
|
||||
<img src="{{ t.image.url }}" class="d-block w-100 rounded img-thumbnail" alt="...">
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% if rolling_stock.image.count > 1 %}
|
||||
<button class="carousel-control-prev" type="button" data-bs-target="#carouselControls" data-bs-slide="prev">
|
||||
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
|
||||
<span class="visually-hidden">Previous</span>
|
||||
</button>
|
||||
<button class="carousel-control-next" type="button" data-bs-target="#carouselControls" data-bs-slide="next">
|
||||
<span class="carousel-control-next-icon" aria-hidden="true"></span>
|
||||
<span class="visually-hidden">Next</span>
|
||||
</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% block cards %}
|
||||
{% endblock %}
|
||||
{% block extra_content %}
|
||||
<section class="py-4 text-start container">
|
||||
@@ -48,6 +51,7 @@
|
||||
{% if rolling_stock.decoder %}<button class="nav-link" id="nav-dcc-tab" data-bs-toggle="tab" data-bs-target="#nav-dcc" type="button" role="tab" aria-controls="nav-dcc" aria-selected="false">DCC</button>{% endif %}
|
||||
{% if rolling_stock.notes %}<button class="nav-link" id="nav-notes-tab" data-bs-toggle="tab" data-bs-target="#nav-notes" type="button" role="tab" aria-controls="nav-notes" aria-selected="false">Notes</button>{% endif %}
|
||||
{% if rolling_stock.document.count > 0 %}<button class="nav-link" id="nav-documents-tab" data-bs-toggle="tab" data-bs-target="#nav-documents" type="button" role="tab" aria-controls="nav-documents" aria-selected="false">Documents</button>{% endif %}
|
||||
{% if rolling_stock_journal.count > 0 %}<button class="nav-link" id="nav-journal-tab" data-bs-toggle="tab" data-bs-target="#nav-journal" type="button" role="tab" aria-controls="nav-journal" aria-selected="false">Journal</button>{% endif %}
|
||||
</div>
|
||||
</nav>
|
||||
<div class="tab-content" id="nav-tabContent">
|
||||
@@ -65,7 +69,9 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Company</th>
|
||||
<td><abbr title="{{ rolling_stock.rolling_class.company.extended_name }}">{{ rolling_stock.rolling_class.company }}</abbr></td>
|
||||
<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>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Class</th>
|
||||
@@ -90,7 +96,7 @@
|
||||
<tbody>
|
||||
<tr>
|
||||
<th width="35%" scope="row">Manufacturer</th>
|
||||
<td>{% if rolling_stock.manufacturer.website %}<a href="{{ rolling_stock.manufacturer.website }}">{% endif %}{{ rolling_stock.manufacturer|default_if_none:"" }}{% if rolling_stock.manufacturer.website %}</a>{% endif %}</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>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Scale</th>
|
||||
@@ -102,7 +108,7 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
{% if rolling_stock.decoder %}
|
||||
{% if rolling_stock.decoder or rolling_stock.decoder_interface %}
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -111,13 +117,19 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th width="35%" scope="row">Decoder</th>
|
||||
<th width="35%" scope="row">Interface</th>
|
||||
<td>{{ rolling_stock.get_decoder_interface_display }}</td>
|
||||
</tr>
|
||||
{% if rolling_stock.decoder %}
|
||||
<tr>
|
||||
<th scope="row">Decoder</th>
|
||||
<td>{{ rolling_stock.decoder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Address</th>
|
||||
<td>{{ rolling_stock.address }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endif %}
|
||||
@@ -132,7 +144,7 @@
|
||||
<tbody>
|
||||
<tr>
|
||||
<th width="35%" scope="row">Manufacturer</th>
|
||||
<td>{% if rolling_stock.manufacturer.website %}<a href="{{ rolling_stock.manufacturer.website }}">{% endif %}{{ rolling_stock.manufacturer|default_if_none:"" }}{% if rolling_stock.manufacturer.website %}</a>{% endif %}</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>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Scale</th>
|
||||
@@ -230,6 +242,10 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row">Interface</th>
|
||||
<td>{{ rolling_stock.get_decoder_interface_display }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th width="35%" scope="row">Address</th>
|
||||
<td>{{ rolling_stock.address }}</td>
|
||||
@@ -246,10 +262,6 @@
|
||||
<th scope="row">Version</th>
|
||||
<td>{{ rolling_stock.decoder.version }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Interface</th>
|
||||
<td>{{ rolling_stock.decoder.get_interface_display }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Sound</th>
|
||||
<td>{{ rolling_stock.decoder.sound | yesno:"Yes,No" }}</td>
|
||||
@@ -258,7 +270,18 @@
|
||||
</table>
|
||||
</div>
|
||||
<div class="tab-pane fade" id="nav-notes" role="tabpanel" aria-labelledby="nav-notes-tab">
|
||||
{{ rolling_stock.notes | markdown | safe }}
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="row">Notes</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>{{ rolling_stock.notes | safe }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="tab-pane fade" id="nav-documents" role="tabpanel" aria-labelledby="nav-documents-tab">
|
||||
<table class="table table-striped">
|
||||
@@ -271,13 +294,30 @@
|
||||
{% for d in rolling_stock.document.all %}
|
||||
<tr>
|
||||
<td>{{ d.description }}</td>
|
||||
<td><a href="{{ d.file.url }}">{{ d.filename }}</a></td>
|
||||
<td><a href="{{ d.file.url }}" target="_blank">{{ d.filename }}</a></td>
|
||||
<td class="text-end">{{ d.file.size | filesizeformat }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="tab-pane fade" id="nav-journal" role="tabpanel" aria-labelledby="nav-journal-tab">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="3" scope="row">Journal</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for j in rolling_stock_journal %}
|
||||
<tr>
|
||||
<th width="35%" scope="row">{{ j.date }}</th>
|
||||
<td>{{ j.log | safe }}</a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-grid gap-2 d-md-flex justify-content-md-end">
|
||||
{% if request.user.is_staff %}<a class="btn btn-sm btn-outline-danger" href="{% url 'admin:roster_rollingstock_change' rolling_stock.pk %}">Edit</a>{% endif %}
|
@@ -1,9 +1,5 @@
|
||||
{% extends "base.html" %}
|
||||
{% load markdown %}
|
||||
{% extends "cards.html" %}
|
||||
|
||||
{% block header %}
|
||||
<h1 class="fw-light">Scales</h1>
|
||||
{% endblock %}
|
||||
{% block cards %}
|
||||
{% for s in scale %}
|
||||
<div class="col">
|
||||
@@ -47,7 +43,7 @@
|
||||
{% block pagination %}
|
||||
{% if scale.has_other_pages %}
|
||||
<nav aria-label="Page navigation example">
|
||||
<ul class="pagination justify-content-center mt-4">
|
||||
<ul class="pagination justify-content-center mt-4 mb-0">
|
||||
{% if scale.has_previous %}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="{% url 'scale_pagination' page=scale.previous_page_number %}#rolling-stock" tabindex="-1">Previous</a>
|
||||
|
@@ -1,13 +1,12 @@
|
||||
{% extends "base.html" %}
|
||||
{% extends "cards.html" %}
|
||||
|
||||
{% block header %}
|
||||
<h1 class="fw-light">{{ filter | default_if_none:"Search" | title }}: {{ search }}</h1>
|
||||
<p class="lead text-muted">Results found: {{ matches }}</p>
|
||||
{% endblock %}
|
||||
{% block pagination %}
|
||||
{% if rolling_stock.has_other_pages %}
|
||||
<nav aria-label="Page navigation example">
|
||||
<ul class="pagination justify-content-center mt-4">
|
||||
<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 'filtered_pagination' _filter=filter search=search page=rolling_stock.previous_page_number %}#rolling-stock" tabindex="-1">Previous</a>
|
||||
|
10
ram/portal/templatetags/show_menu.py
Normal file
10
ram/portal/templatetags/show_menu.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from django import template
|
||||
from portal.views import Flatpage
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
||||
@register.inclusion_tag('flatpage_menu.html')
|
||||
def show_menu():
|
||||
menu = Flatpage.objects.filter(published=True).order_by("name")
|
||||
return {"menu": menu}
|
@@ -3,6 +3,7 @@ from django.urls import path
|
||||
from portal.views import (
|
||||
GetHome,
|
||||
GetHomeFiltered,
|
||||
GetFlatpage,
|
||||
GetRollingStock,
|
||||
GetConsist,
|
||||
Consists,
|
||||
@@ -13,6 +14,11 @@ from portal.views import (
|
||||
urlpatterns = [
|
||||
path("", GetHome.as_view(), name="index"),
|
||||
path("<int:page>", GetHome.as_view(), name="index_pagination"),
|
||||
path(
|
||||
"page/<str:flatpage>",
|
||||
GetFlatpage.as_view(),
|
||||
name="flatpage",
|
||||
),
|
||||
path(
|
||||
"search",
|
||||
GetHomeFiltered.as_view(http_method_names=["post"]),
|
||||
@@ -32,14 +38,10 @@ urlpatterns = [
|
||||
path(
|
||||
"companies/<int:page>",
|
||||
Companies.as_view(),
|
||||
name="companies_pagination"
|
||||
name="companies_pagination",
|
||||
),
|
||||
path("scales", Scales.as_view(), name="scales"),
|
||||
path(
|
||||
"scales/<int:page>",
|
||||
Scales.as_view(),
|
||||
name="scales_pagination"
|
||||
),
|
||||
path("scales/<int:page>", Scales.as_view(), name="scales_pagination"),
|
||||
path(
|
||||
"<str:_filter>/<str:search>",
|
||||
GetHomeFiltered.as_view(),
|
||||
|
@@ -6,9 +6,10 @@ from django.http import Http404
|
||||
from django.db.models import Q
|
||||
from django.shortcuts import render
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
|
||||
from django.core.paginator import Paginator, PageNotAnInteger
|
||||
|
||||
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
|
||||
@@ -45,7 +46,11 @@ class GetHome(View):
|
||||
return render(
|
||||
request,
|
||||
"home.html",
|
||||
{"rolling_stock": rolling_stock, "page_range": page_range},
|
||||
{
|
||||
"title": "Home",
|
||||
"rolling_stock": rolling_stock,
|
||||
"page_range": page_range,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@@ -82,8 +87,10 @@ class GetHomeFiltered(View):
|
||||
query = Q(tags__slug__iexact=search)
|
||||
else:
|
||||
raise Http404
|
||||
rolling_stock = RollingStock.objects.filter(query).order_by(
|
||||
*order_by_fields()
|
||||
rolling_stock = (
|
||||
RollingStock.objects.filter(query)
|
||||
.distinct()
|
||||
.order_by(*order_by_fields())
|
||||
)
|
||||
matches = len(rolling_stock)
|
||||
|
||||
@@ -104,6 +111,7 @@ class GetHomeFiltered(View):
|
||||
request,
|
||||
"search.html",
|
||||
{
|
||||
"title": "{0}: {1}".format(_filter.capitalize(), search),
|
||||
"search": search,
|
||||
"filter": _filter,
|
||||
"matches": matches,
|
||||
@@ -124,6 +132,7 @@ class GetHomeFiltered(View):
|
||||
request,
|
||||
"search.html",
|
||||
{
|
||||
"title": "{0}: {1}".format(_filter.capitalize(), search),
|
||||
"search": search,
|
||||
"filter": _filter,
|
||||
"matches": matches,
|
||||
@@ -153,13 +162,21 @@ class GetRollingStock(View):
|
||||
else rolling_stock.property.filter(property__private=False)
|
||||
)
|
||||
|
||||
rolling_stock_journal = (
|
||||
rolling_stock.journal.all()
|
||||
if request.user.is_authenticated
|
||||
else rolling_stock.journal.filter(private=False)
|
||||
)
|
||||
|
||||
return render(
|
||||
request,
|
||||
"page.html",
|
||||
"rollingstock.html",
|
||||
{
|
||||
"title": rolling_stock,
|
||||
"rolling_stock": rolling_stock,
|
||||
"class_properties": class_properties,
|
||||
"rolling_stock_properties": rolling_stock_properties,
|
||||
"rolling_stock_journal": rolling_stock_journal,
|
||||
},
|
||||
)
|
||||
|
||||
@@ -178,7 +195,11 @@ class Consists(View):
|
||||
return render(
|
||||
request,
|
||||
"consists.html",
|
||||
{"consist": consist, "page_range": page_range},
|
||||
{
|
||||
"title": "Consists",
|
||||
"consist": consist,
|
||||
"page_range": page_range,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@@ -201,6 +222,7 @@ class GetConsist(View):
|
||||
request,
|
||||
"consist.html",
|
||||
{
|
||||
"title": consist,
|
||||
"consist": consist,
|
||||
"rolling_stock": rolling_stock,
|
||||
"page_range": page_range,
|
||||
@@ -222,7 +244,11 @@ class Companies(View):
|
||||
return render(
|
||||
request,
|
||||
"companies.html",
|
||||
{"company": company, "page_range": page_range},
|
||||
{
|
||||
"title": "Companies",
|
||||
"company": company,
|
||||
"page_range": page_range,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@@ -240,5 +266,21 @@ class Scales(View):
|
||||
return render(
|
||||
request,
|
||||
"scales.html",
|
||||
{"scale": scale, "page_range": page_range},
|
||||
{"title": "Scales", "scale": scale, "page_range": page_range},
|
||||
)
|
||||
|
||||
|
||||
class GetFlatpage(View):
|
||||
def get(self, request, flatpage):
|
||||
try:
|
||||
flatpage = Flatpage.objects.get(
|
||||
Q(Q(path=flatpage) & Q(published=True))
|
||||
)
|
||||
except ObjectDoesNotExist:
|
||||
raise Http404
|
||||
|
||||
return render(
|
||||
request,
|
||||
"flatpage.html",
|
||||
{"title": flatpage.name, "flatpage": flatpage},
|
||||
)
|
||||
|
@@ -1,4 +1,4 @@
|
||||
from ram.utils import git_suffix
|
||||
|
||||
__version__ = "0.0.14"
|
||||
__version__ = "0.0.29"
|
||||
__version__ += git_suffix(__file__)
|
||||
|
@@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/4.0/ref/settings/
|
||||
"""
|
||||
|
||||
import os
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||
@@ -45,6 +46,8 @@ INSTALLED_APPS = [
|
||||
"adminsortable2",
|
||||
"django_countries",
|
||||
"solo",
|
||||
"ckeditor",
|
||||
"ckeditor_uploader",
|
||||
"rest_framework",
|
||||
"ram",
|
||||
"portal",
|
||||
@@ -139,6 +142,7 @@ DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
||||
|
||||
MEDIA_URL = "media/"
|
||||
MEDIA_ROOT = STORAGE_DIR / "media"
|
||||
CKEDITOR_UPLOAD_PATH = "uploads/"
|
||||
|
||||
COUNTRIES_OVERRIDE = {
|
||||
"ZZ": "Freelance",
|
||||
|
@@ -21,6 +21,7 @@ from django.urls import include, path
|
||||
|
||||
urlpatterns = [
|
||||
path("", lambda r: redirect("portal/")),
|
||||
path("ckeditor/", include("ckeditor_uploader.urls")),
|
||||
path("portal/", include("portal.urls")),
|
||||
path("ht/", include("health_check.urls")),
|
||||
path("admin/", admin.site.urls),
|
||||
|
@@ -1,8 +1,29 @@
|
||||
import os
|
||||
import hashlib
|
||||
import subprocess
|
||||
|
||||
from django.utils.html import format_html
|
||||
from django.utils.text import slugify as django_slugify
|
||||
from django.core.files.storage import FileSystemStorage
|
||||
|
||||
|
||||
class DeduplicatedStorage(FileSystemStorage):
|
||||
"""
|
||||
A derived FileSystemStorage class that compares already existing files
|
||||
(with the same name) with new uploaded ones and stores new file only if
|
||||
sha256 hash on is content is different
|
||||
"""
|
||||
|
||||
def save(self, name, content, max_length=None):
|
||||
if super().exists(name):
|
||||
new = hashlib.sha256(content.file.getbuffer()).hexdigest()
|
||||
with open(super().path(name), "rb") as file:
|
||||
file_binary = file.read()
|
||||
old = hashlib.sha256(file_binary).hexdigest()
|
||||
if old == new:
|
||||
return name
|
||||
|
||||
return super().save(name, content, max_length)
|
||||
|
||||
|
||||
def git_suffix(fname):
|
||||
|
@@ -1,4 +1,6 @@
|
||||
from django.contrib import admin
|
||||
from adminsortable2.admin import SortableAdminBase, SortableInlineAdminMixin
|
||||
|
||||
from roster.models import (
|
||||
RollingClass,
|
||||
RollingClassProperty,
|
||||
@@ -6,6 +8,7 @@ from roster.models import (
|
||||
RollingStockImage,
|
||||
RollingStockDocument,
|
||||
RollingStockProperty,
|
||||
RollingStockJournal,
|
||||
)
|
||||
|
||||
|
||||
@@ -31,13 +34,15 @@ class RollingStockDocInline(admin.TabularInline):
|
||||
model = RollingStockDocument
|
||||
min_num = 0
|
||||
extra = 0
|
||||
classes = ["collapse"]
|
||||
|
||||
|
||||
class RollingStockImageInline(admin.TabularInline):
|
||||
class RollingStockImageInline(SortableInlineAdminMixin, admin.TabularInline):
|
||||
model = RollingStockImage
|
||||
min_num = 0
|
||||
extra = 0
|
||||
readonly_fields = ("image_thumbnail",)
|
||||
classes = ["collapse"]
|
||||
|
||||
|
||||
class RollingStockPropertyInline(admin.TabularInline):
|
||||
@@ -46,6 +51,13 @@ class RollingStockPropertyInline(admin.TabularInline):
|
||||
extra = 0
|
||||
|
||||
|
||||
class RollingStockJournalInline(admin.TabularInline):
|
||||
model = RollingStockJournal
|
||||
min_num = 0
|
||||
extra = 0
|
||||
classes = ["collapse"]
|
||||
|
||||
|
||||
@admin.register(RollingStockDocument)
|
||||
class RollingStockDocumentAdmin(admin.ModelAdmin):
|
||||
list_display = (
|
||||
@@ -62,12 +74,33 @@ class RollingStockDocumentAdmin(admin.ModelAdmin):
|
||||
)
|
||||
|
||||
|
||||
@admin.register(RollingStockJournal)
|
||||
class RollingJournalDocumentAdmin(admin.ModelAdmin):
|
||||
list_display = (
|
||||
"__str__",
|
||||
"date",
|
||||
"rolling_stock",
|
||||
"private",
|
||||
)
|
||||
list_filter = (
|
||||
"date",
|
||||
"private",
|
||||
)
|
||||
search_fields = (
|
||||
"rolling_stock__rolling_class__identifier",
|
||||
"rolling_stock__road_number",
|
||||
"rolling_stock__sku",
|
||||
"log",
|
||||
)
|
||||
|
||||
|
||||
@admin.register(RollingStock)
|
||||
class RollingStockAdmin(admin.ModelAdmin):
|
||||
class RollingStockAdmin(SortableAdminBase, admin.ModelAdmin):
|
||||
inlines = (
|
||||
RollingStockPropertyInline,
|
||||
RollingStockImageInline,
|
||||
RollingStockDocInline,
|
||||
RollingStockJournalInline,
|
||||
)
|
||||
readonly_fields = ("creation_time", "updated_time")
|
||||
list_display = (
|
||||
@@ -94,6 +127,7 @@ class RollingStockAdmin(admin.ModelAdmin):
|
||||
"address",
|
||||
"sku",
|
||||
)
|
||||
save_as = True
|
||||
|
||||
fieldsets = (
|
||||
(
|
||||
@@ -117,6 +151,7 @@ class RollingStockAdmin(admin.ModelAdmin):
|
||||
"DCC",
|
||||
{
|
||||
"fields": (
|
||||
"decoder_interface",
|
||||
"decoder",
|
||||
"address",
|
||||
)
|
||||
|
19
ram/roster/migrations/0010_alter_rollingstock_notes.py
Normal file
19
ram/roster/migrations/0010_alter_rollingstock_notes.py
Normal file
@@ -0,0 +1,19 @@
|
||||
# Generated by Django 4.1 on 2022-08-23 15:54
|
||||
|
||||
import ckeditor_uploader.fields
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("roster", "0009_alter_rollingstock_options_and_more"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="rollingstock",
|
||||
name="notes",
|
||||
field=ckeditor_uploader.fields.RichTextUploadingField(blank=True),
|
||||
),
|
||||
]
|
34
ram/roster/migrations/0011_md_to_html.py
Normal file
34
ram/roster/migrations/0011_md_to_html.py
Normal file
@@ -0,0 +1,34 @@
|
||||
# Generated by Django 4.1 on 2022-08-24 15:30
|
||||
|
||||
import markdown
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def md_to_html(apps, schema_editor):
|
||||
fields = {
|
||||
"RollingStock": ["notes"],
|
||||
}
|
||||
|
||||
for m in fields.items():
|
||||
model = apps.get_model("roster", m[0])
|
||||
|
||||
for row in model.objects.all():
|
||||
for field in m[1]:
|
||||
html = markdown.markdown(getattr(row, field))
|
||||
row.__dict__[field] = html
|
||||
|
||||
row.save(update_fields=m[1])
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("roster", "0010_alter_rollingstock_notes"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(
|
||||
md_to_html,
|
||||
reverse_code=migrations.RunPython.noop
|
||||
),
|
||||
]
|
45
ram/roster/migrations/0012_rollingstockjournal.py
Normal file
45
ram/roster/migrations/0012_rollingstockjournal.py
Normal file
@@ -0,0 +1,45 @@
|
||||
# Generated by Django 4.1 on 2022-08-27 12:43
|
||||
|
||||
import ckeditor_uploader.fields
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("roster", "0011_md_to_html"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name="RollingStockJournal",
|
||||
fields=[
|
||||
(
|
||||
"id",
|
||||
models.BigAutoField(
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
verbose_name="ID",
|
||||
),
|
||||
),
|
||||
("date", models.DateField()),
|
||||
("log", ckeditor_uploader.fields.RichTextUploadingField()),
|
||||
("private", models.BooleanField(default=False)),
|
||||
("creation_time", models.DateTimeField(auto_now_add=True)),
|
||||
("updated_time", models.DateTimeField(auto_now=True)),
|
||||
(
|
||||
"rolling_stock",
|
||||
models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
related_name="journal",
|
||||
to="roster.rollingstock",
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
"ordering": ["date", "rolling_stock"],
|
||||
},
|
||||
),
|
||||
]
|
42
ram/roster/migrations/0013_rollingstock_decoder_interface.py
Normal file
42
ram/roster/migrations/0013_rollingstock_decoder_interface.py
Normal file
@@ -0,0 +1,42 @@
|
||||
# Generated by Django 4.1 on 2022-10-31 22:27
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
def meta_to_roster(apps, schema_editor):
|
||||
model = apps.get_model("roster", "RollingStock")
|
||||
|
||||
for row in model.objects.all():
|
||||
if row.decoder:
|
||||
decoder_interface = row.decoder.interface
|
||||
row.__dict__["decoder_interface"] = decoder_interface
|
||||
row.save(update_fields=["decoder_interface"])
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("roster", "0012_rollingstockjournal"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="rollingstock",
|
||||
name="decoder_interface",
|
||||
field=models.PositiveSmallIntegerField(
|
||||
blank=True,
|
||||
choices=[
|
||||
(1, "NEM651"),
|
||||
(2, "NEM652"),
|
||||
(3, "PluX"),
|
||||
(4, "21MTC"),
|
||||
(5, "Next18/Next18S"),
|
||||
],
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
migrations.RunPython(
|
||||
meta_to_roster,
|
||||
reverse_code=migrations.RunPython.noop
|
||||
),
|
||||
]
|
@@ -0,0 +1,34 @@
|
||||
# Generated by Django 4.1.2 on 2022-11-27 00:10
|
||||
|
||||
from django.db import migrations, models
|
||||
import ram.utils
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("roster", "0013_rollingstock_decoder_interface"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="rollingstockdocument",
|
||||
name="file",
|
||||
field=models.FileField(
|
||||
blank=True,
|
||||
null=True,
|
||||
storage=ram.utils.DeduplicatedStorage(),
|
||||
upload_to="files/",
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="rollingstockimage",
|
||||
name="image",
|
||||
field=models.ImageField(
|
||||
blank=True,
|
||||
null=True,
|
||||
storage=ram.utils.DeduplicatedStorage,
|
||||
upload_to="images/",
|
||||
),
|
||||
),
|
||||
]
|
@@ -0,0 +1,17 @@
|
||||
# Generated by Django 4.1.3 on 2022-12-28 21:07
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("roster", "0014_alter_rollingstockdocument_file_and_more"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name="rollingstockimage",
|
||||
options={"ordering": ["-is_thumbnail"]},
|
||||
),
|
||||
]
|
@@ -0,0 +1,22 @@
|
||||
# Generated by Django 4.1.3 on 2023-01-02 12:34
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("roster", "0015_alter_rollingstockimage_options"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name="rollingstockimage",
|
||||
options={"ordering": ["order"]},
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="rollingstockimage",
|
||||
name="order",
|
||||
field=models.PositiveIntegerField(default=0),
|
||||
),
|
||||
]
|
@@ -0,0 +1,17 @@
|
||||
# Generated by Django 4.1.3 on 2023-01-02 15:02
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("roster", "0016_alter_rollingstockimage_options_and_more"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name="rollingstockimage",
|
||||
name="is_thumbnail",
|
||||
),
|
||||
]
|
@@ -3,12 +3,13 @@ import re
|
||||
from uuid import uuid4
|
||||
from django.db import models
|
||||
from django.urls import reverse
|
||||
from django.conf import settings
|
||||
from django.dispatch import receiver
|
||||
from django.utils.safestring import mark_safe
|
||||
|
||||
# from django.core.files.storage import FileSystemStorage
|
||||
from ckeditor_uploader.fields import RichTextUploadingField
|
||||
|
||||
from ram.utils import get_image_preview
|
||||
from ram.utils import DeduplicatedStorage, get_image_preview
|
||||
from metadata.models import (
|
||||
Property,
|
||||
Scale,
|
||||
@@ -19,11 +20,6 @@ from metadata.models import (
|
||||
RollingStockType,
|
||||
)
|
||||
|
||||
# class OverwriteMixin(FileSystemStorage):
|
||||
# def get_available_name(self, name, max_length):
|
||||
# self.delete(name)
|
||||
# return name
|
||||
|
||||
|
||||
class RollingClass(models.Model):
|
||||
identifier = models.CharField(max_length=128, unique=False)
|
||||
@@ -87,6 +83,9 @@ class RollingStock(models.Model):
|
||||
)
|
||||
scale = models.ForeignKey(Scale, on_delete=models.CASCADE)
|
||||
sku = models.CharField(max_length=32, blank=True)
|
||||
decoder_interface = models.PositiveSmallIntegerField(
|
||||
choices=settings.DECODER_INTERFACES, null=True, blank=True
|
||||
)
|
||||
decoder = models.ForeignKey(
|
||||
Decoder, on_delete=models.CASCADE, null=True, blank=True
|
||||
)
|
||||
@@ -94,7 +93,7 @@ class RollingStock(models.Model):
|
||||
era = models.CharField(max_length=32, blank=True)
|
||||
production_year = models.SmallIntegerField(null=True, blank=True)
|
||||
purchase_date = models.DateField(null=True, blank=True)
|
||||
notes = models.TextField(blank=True)
|
||||
notes = RichTextUploadingField(blank=True)
|
||||
tags = models.ManyToManyField(
|
||||
Tag, related_name="rolling_stock", blank=True
|
||||
)
|
||||
@@ -133,7 +132,12 @@ class RollingStockDocument(models.Model):
|
||||
RollingStock, on_delete=models.CASCADE, related_name="document"
|
||||
)
|
||||
description = models.CharField(max_length=128, blank=True)
|
||||
file = models.FileField(upload_to="files/", null=True, blank=True)
|
||||
file = models.FileField(
|
||||
upload_to="files/",
|
||||
storage=DeduplicatedStorage(),
|
||||
null=True,
|
||||
blank=True,
|
||||
)
|
||||
|
||||
class Meta(object):
|
||||
unique_together = ("rolling_stock", "file")
|
||||
@@ -151,11 +155,13 @@ class RollingStockDocument(models.Model):
|
||||
|
||||
|
||||
class RollingStockImage(models.Model):
|
||||
order = models.PositiveIntegerField(default=0, blank=False, null=False)
|
||||
rolling_stock = models.ForeignKey(
|
||||
RollingStock, on_delete=models.CASCADE, related_name="image"
|
||||
)
|
||||
image = models.ImageField(upload_to="images/", null=True, blank=True)
|
||||
is_thumbnail = models.BooleanField()
|
||||
image = models.ImageField(
|
||||
upload_to="images/", storage=DeduplicatedStorage, null=True, blank=True
|
||||
)
|
||||
|
||||
def image_thumbnail(self):
|
||||
return get_image_preview(self.image.url)
|
||||
@@ -165,12 +171,8 @@ class RollingStockImage(models.Model):
|
||||
def __str__(self):
|
||||
return "{0}".format(os.path.basename(self.image.name))
|
||||
|
||||
def save(self, **kwargs):
|
||||
if self.is_thumbnail:
|
||||
RollingStockImage.objects.filter(
|
||||
rolling_stock=self.rolling_stock
|
||||
).update(is_thumbnail=False)
|
||||
super().save(**kwargs)
|
||||
class Meta:
|
||||
ordering = ["order"]
|
||||
|
||||
|
||||
class RollingStockProperty(models.Model):
|
||||
@@ -191,6 +193,27 @@ class RollingStockProperty(models.Model):
|
||||
verbose_name_plural = "Properties"
|
||||
|
||||
|
||||
class RollingStockJournal(models.Model):
|
||||
rolling_stock = models.ForeignKey(
|
||||
RollingStock,
|
||||
on_delete=models.CASCADE,
|
||||
related_name="journal",
|
||||
null=False,
|
||||
blank=False,
|
||||
)
|
||||
date = models.DateField()
|
||||
log = RichTextUploadingField()
|
||||
private = models.BooleanField(default=False)
|
||||
creation_time = models.DateTimeField(auto_now_add=True)
|
||||
updated_time = models.DateTimeField(auto_now=True)
|
||||
|
||||
def __str__(self):
|
||||
return "{0} - {1}".format(self.rolling_stock, self.date)
|
||||
|
||||
class Meta:
|
||||
ordering = ["date", "rolling_stock"]
|
||||
|
||||
|
||||
# @receiver(models.signals.post_delete, sender=Cab)
|
||||
# def post_save_image(sender, instance, *args, **kwargs):
|
||||
# try:
|
||||
|
@@ -7,5 +7,6 @@ django-solo
|
||||
django-countries
|
||||
django-health-check
|
||||
django-admin-sortable2
|
||||
django-ckeditor
|
||||
# psycopg2-binary
|
||||
pySerial
|
||||
|
Reference in New Issue
Block a user