Add options for a disclaimer, fix html code and remove deprecations (#50)

* Add options for a disclaimer, fix html code and remove deprecations

* Update READMEs

* Minor improvement to portal admin [skip ci]
This commit is contained in:
2025-01-30 23:13:32 +01:00
committed by GitHub
parent 04757d868a
commit 5d89cb96d2
13 changed files with 106 additions and 30 deletions

View File

@@ -41,17 +41,25 @@ Project is based on the following technologies and components:
It has been developed with:
- [vim](https://www.vim.org/): because it rocks
- [neovim](https://neovim.io/): because `vim` rocks, `neovim` rocks more
- [arduino-cli](https://github.com/arduino/arduino-cli/): a mouse? What the heck?
- [vim-arduino](https://github.com/stevearc/vim-arduino): another IDE? No thanks
- [podman](https://podman.io/): because containers are fancy
- [QEMU (avr)](https://qemu-project.gitlab.io/qemu/system/target-avr.html): QEMU can even make toast!
- [QEMU (avr)](https://qemu-project.gitlab.io/qemu/system/target-avr.html): QEMU can even make toasts!
## Future developments
A bunch of random, probably useless, ideas:
### A bookshelf
✅DONE
Because books matter more than model trains themselves.
### Live assets KPI collection
Realtime data usage is collected via a daemon connected over TCP to the Commandstation-EX and recorded for every asset with a DCC address.
Realtime data usage is collected via a daemon connected over TCP to the EX-CommandStation and recorded for every asset with a DCC address.
### Asset lifecycle
@@ -61,6 +69,11 @@ Data is collected to compute the asset usage and then the wear level of its comp
Eventually data is used to "forecast" any required maintenance, like for example the replacement of carbon brushes, gear and motor oiling.
### Asset export to JMRI
Export assets (locomotives) into the JMRI format to be loaded in the JMRI
roster.
## Requirements
- Python 3.11+
@@ -97,6 +110,8 @@ $ python manage.py migrate
$ python manage.py createsuperuser
```
To load some sample metadata, see the [sample_data folder instructions](./sample_data/README.md).
Run Django
```bash

View File

@@ -1,6 +1,7 @@
from django.conf import settings
from django.contrib import admin
from solo.admin import SingletonModelAdmin
from tinymce.widgets import TinyMCE
from ram.admin import publish, unpublish
from portal.models import SiteConfiguration, Flatpage
@@ -8,7 +9,7 @@ from portal.models import SiteConfiguration, Flatpage
@admin.register(SiteConfiguration)
class SiteConfigurationAdmin(SingletonModelAdmin):
readonly_fields = ("site_name", "rest_api")
readonly_fields = ("site_name", "rest_api", "version")
fieldsets = (
(
None,
@@ -22,7 +23,7 @@ class SiteConfigurationAdmin(SingletonModelAdmin):
"currency",
"footer",
"footer_extended",
"rest_api",
"disclaimer",
)
},
),
@@ -34,6 +35,8 @@ class SiteConfigurationAdmin(SingletonModelAdmin):
"show_version",
"use_cdn",
"extra_head",
"rest_api",
"version",
),
},
),
@@ -43,6 +46,19 @@ class SiteConfigurationAdmin(SingletonModelAdmin):
def rest_api(self, obj):
return settings.REST_ENABLED
@admin.display()
def version(self, obj):
return "{} (Django {})".format(obj.version, obj.django_version)
def formfield_for_dbfield(self, db_field, **kwargs):
if db_field.name in ("footer", "footer_extended", "disclaimer"):
return db_field.formfield(
widget=TinyMCE(
mce_attrs={"height": "200"},
)
)
return super().formfield_for_dbfield(db_field, **kwargs)
@admin.register(Flatpage)
class FlatpageAdmin(admin.ModelAdmin):

View File

@@ -0,0 +1,19 @@
# Generated by Django 5.1.4 on 2025-01-30 16:39
import tinymce.models
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("portal", "0018_siteconfiguration_currency"),
]
operations = [
migrations.AddField(
model_name="siteconfiguration",
name="disclaimer",
field=tinymce.models.HTMLField(blank=True),
),
]

View File

@@ -33,6 +33,7 @@ class SiteConfiguration(SingletonModel):
currency = models.CharField(max_length=3, default="EUR")
footer = tinymce.HTMLField(blank=True)
footer_extended = tinymce.HTMLField(blank=True)
disclaimer = tinymce.HTMLField(blank=True)
show_version = models.BooleanField(default=True)
use_cdn = models.BooleanField(default=True)
extra_head = models.TextField(blank=True)
@@ -46,9 +47,11 @@ class SiteConfiguration(SingletonModel):
def site_name(self):
return settings.SITE_NAME
@property
def version(self):
return app_version
@property
def django_version(self):
return django.get_version()

View File

@@ -9,7 +9,7 @@
{% endfor %}
</p>
{% endif %}
<small class="text-muted">Updated {{ book.updated_time | date:"M d, Y H:i" }}</small>
<small class="text-body-secondary">Updated {{ book.updated_time | date:"M d, Y H:i" }}</small>
{% endblock %}
{% block carousel %}
<div class="row">

View File

@@ -1,6 +1,6 @@
{% extends "base.html" %}
{% block header %}
<p class="lead text-muted">Results found: {{ matches }}</p>
<p class="lead text-body-secondary">Results found: {{ matches }}</p>
{% endblock %}
{% block cards_layout %}
<div class="row row-cols-1 row-cols-md-2 row-cols-lg-3 g-3">

View File

@@ -7,7 +7,7 @@
{{ t.name }}</a>{# new line is required #}
{% endfor %}
</p>
<small class="text-muted">Updated {{ consist.updated_time | date:"M d, Y H:i" }}</small>
<small class="text-body-secondary">Updated {{ consist.updated_time | date:"M d, Y H:i" }}</small>
{% endif %}
{% endblock %}
{% block carousel %}

View File

@@ -1,7 +1,7 @@
{% extends 'base.html' %}
{% block header %}
<small class="text-muted">Updated {{ flatpage.updated_time | date:"M d, Y H:i" }}</small>
<small class="text-body-secondary">Updated {{ flatpage.updated_time | date:"M d, Y H:i" }}</small>
{% endblock %}
{% block carousel %}
{% endblock %}

View File

@@ -1,5 +1,5 @@
{% extends "pagination.html" %}
{% block header %}
<div class="text-muted">{{ site_conf.about | safe }}</div>
<div class="text-body-secondary">{{ site_conf.about | safe }}</div>
{% endblock %}

View File

@@ -1,18 +1,34 @@
<footer class="text-muted py-4">
<div class="container">
<p class="float-end mb-1">
<a href="#">Back to top</a>
</p>
<footer class="text-body-secondary py-4">
<div class="container d-lg-flex justify-content-between">
<div id="footer" class="mb-1">
<p>&copy; {% now "Y" %}</p> {{ site_conf.footer | safe }}
<p>&copy; {% now "Y" %}</p> {{ site_conf.footer | safe }}
</div>
<div id="footer_extended" class="mb-0">
</div>
<div class="container">
<div id="footer_extended">
{{ site_conf.footer_extended | safe }}
</div>
</div>
<div class="container">
<p class="small text-muted">Made with ❤️ for 🚂 and <a href="https://github.com/daniviga/django-ram">django-ram</a>
{% if site_conf.show_version %}<br>Version {{ site_conf.version }}{% endif %}
<div class="container d-flex text-body-secondary">
<p class="flex-fill small">Made with ❤️ for 🚂 and <i class="bi bi-github"></i> <a href="https://github.com/daniviga/django-ram">django-ram</a>
{% if site_conf.show_version %}<br>Version {{ site_conf.version }}{% endif %}</p>
<p class="text-end fs-5">
{% if site_conf.disclaimer %}<a class="text-reset" title="Disclaimer" href="" data-bs-toggle="modal" data-bs-target="#disclaimerModal"><i class="bi bi-info-square-fill"></i></a> {% endif %}
<a class="text-reset" title="Back to top" href="#"><i class="bi bi-arrow-up-left-square-fill"></i></a>
</p>
</div>
<!-- Modal -->
<div class="modal fade" id="disclaimerModal" tabindex="-1" aria-labelledby="disclaimerLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="disclaimerLabel">Disclaimer</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
{{ site_conf.disclaimer | safe }}
</div>
</div>
</div>
</div>
</footer>

View File

@@ -8,7 +8,7 @@
{% endfor %}
</p>
{% endif %}
<small class="text-muted">Updated {{ rolling_stock.updated_time | date:"M d, Y H:i" }}</small>
<small class="text-body-secondary">Updated {{ rolling_stock.updated_time | date:"M d, Y H:i" }}</small>
{% endblock %}
{% block carousel %}
<div class="row">
@@ -194,7 +194,7 @@
</tr>
<tr>
<th scope="row">Production year</th>
<td>{{ rolling_stock.production_year|default:"-" }}</td>
<td>{{ rolling_stock.production_year | default:"-" }}</td>
</tr>
{% if rolling_stock.description %}
<tr>
@@ -215,17 +215,17 @@
<tr>
<th class="w-33" scope="row">Shop</th>
<td>
{{ rolling_stock.shop|default:"-" }}
{{ rolling_stock.shop | default:"-" }}
{% if rolling_stock.shop.website %} <a href="{{ rolling_stock.shop.website }}" target="_blank"><i class="bi bi-box-arrow-up-right"></i></a>{% endif %}
</td>
</tr>
<tr>
<th class="w-33" scope="row">Purchase date</th>
<td>{{ rolling_stock.purchase_date|default:"-" }}</td>
<td>{{ rolling_stock.purchase_date | default:"-" }}</td>
</tr>
<tr>
<th scope="row">Price ({{ site_conf.currency }})</th>
<td>{{ rolling_stock.price|default:"-" }}</td>
<td>{{ rolling_stock.price | default:"-" }}</td>
</tr>
</tbody>
</table>
@@ -357,11 +357,11 @@
</tr>
<tr>
<th scope="row">Manufacturer</th>
<td>{{ rolling_stock.decoder.manufacturer|default:"-" }}</td>
<td>{{ rolling_stock.decoder.manufacturer | default:"-" }}</td>
</tr>
<tr>
<th scope="row">Version</th>
<td>{{ rolling_stock.decoder.version }}</td>
<td>{{ rolling_stock.decoder.version | default:"-"}}</td>
</tr>
<tr>
<th scope="row">Sound</th>

View File

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

View File

@@ -7,4 +7,11 @@ $ cp -R ../sample_data/images/ <storage_folder>
# Disclaimer
Logos, names and design concepts are property of each respective owner. This is an hobbistic project and it is not affiliated with any of the companies or manufacturers mentioned in this project.
Logos, names and design concepts are property of each respective owner.
This is an hobbistic project and it is not affiliated with any of the companies
or manufacturers mentioned in this project.
## Add the disclaimer to your site
You can add the disclaimer to your site by adding it to the `Disclaimer` area
in the `Site Configuration` section of the admin interface.