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: 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? - [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 - [vim-arduino](https://github.com/stevearc/vim-arduino): another IDE? No thanks
- [podman](https://podman.io/): because containers are fancy - [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 ## Future developments
A bunch of random, probably useless, ideas:
### A bookshelf
✅DONE
Because books matter more than model trains themselves.
### Live assets KPI collection ### 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 ### 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. 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 ## Requirements
- Python 3.11+ - Python 3.11+
@@ -97,6 +110,8 @@ $ python manage.py migrate
$ python manage.py createsuperuser $ python manage.py createsuperuser
``` ```
To load some sample metadata, see the [sample_data folder instructions](./sample_data/README.md).
Run Django Run Django
```bash ```bash

View File

@@ -1,6 +1,7 @@
from django.conf import settings from django.conf import settings
from django.contrib import admin from django.contrib import admin
from solo.admin import SingletonModelAdmin from solo.admin import SingletonModelAdmin
from tinymce.widgets import TinyMCE
from ram.admin import publish, unpublish from ram.admin import publish, unpublish
from portal.models import SiteConfiguration, Flatpage from portal.models import SiteConfiguration, Flatpage
@@ -8,7 +9,7 @@ from portal.models import SiteConfiguration, Flatpage
@admin.register(SiteConfiguration) @admin.register(SiteConfiguration)
class SiteConfigurationAdmin(SingletonModelAdmin): class SiteConfigurationAdmin(SingletonModelAdmin):
readonly_fields = ("site_name", "rest_api") readonly_fields = ("site_name", "rest_api", "version")
fieldsets = ( fieldsets = (
( (
None, None,
@@ -22,7 +23,7 @@ class SiteConfigurationAdmin(SingletonModelAdmin):
"currency", "currency",
"footer", "footer",
"footer_extended", "footer_extended",
"rest_api", "disclaimer",
) )
}, },
), ),
@@ -34,6 +35,8 @@ class SiteConfigurationAdmin(SingletonModelAdmin):
"show_version", "show_version",
"use_cdn", "use_cdn",
"extra_head", "extra_head",
"rest_api",
"version",
), ),
}, },
), ),
@@ -43,6 +46,19 @@ class SiteConfigurationAdmin(SingletonModelAdmin):
def rest_api(self, obj): def rest_api(self, obj):
return settings.REST_ENABLED 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) @admin.register(Flatpage)
class FlatpageAdmin(admin.ModelAdmin): 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") currency = models.CharField(max_length=3, default="EUR")
footer = tinymce.HTMLField(blank=True) footer = tinymce.HTMLField(blank=True)
footer_extended = tinymce.HTMLField(blank=True) footer_extended = tinymce.HTMLField(blank=True)
disclaimer = tinymce.HTMLField(blank=True)
show_version = models.BooleanField(default=True) show_version = models.BooleanField(default=True)
use_cdn = models.BooleanField(default=True) use_cdn = models.BooleanField(default=True)
extra_head = models.TextField(blank=True) extra_head = models.TextField(blank=True)
@@ -46,9 +47,11 @@ class SiteConfiguration(SingletonModel):
def site_name(self): def site_name(self):
return settings.SITE_NAME return settings.SITE_NAME
@property
def version(self): def version(self):
return app_version return app_version
@property
def django_version(self): def django_version(self):
return django.get_version() return django.get_version()

View File

@@ -9,7 +9,7 @@
{% endfor %} {% endfor %}
</p> </p>
{% endif %} {% 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 %} {% endblock %}
{% block carousel %} {% block carousel %}
<div class="row"> <div class="row">

View File

@@ -1,6 +1,6 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block header %} {% block header %}
<p class="lead text-muted">Results found: {{ matches }}</p> <p class="lead text-body-secondary">Results found: {{ matches }}</p>
{% endblock %} {% endblock %}
{% block cards_layout %} {% block cards_layout %}
<div class="row row-cols-1 row-cols-md-2 row-cols-lg-3 g-3"> <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 #} {{ t.name }}</a>{# new line is required #}
{% endfor %} {% endfor %}
</p> </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 %} {% endif %}
{% endblock %} {% endblock %}
{% block carousel %} {% block carousel %}

View File

@@ -1,7 +1,7 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% block header %} {% 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 %} {% endblock %}
{% block carousel %} {% block carousel %}
{% endblock %} {% endblock %}

View File

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

View File

@@ -1,18 +1,34 @@
<footer class="text-muted py-4"> <footer class="text-body-secondary py-4">
<div class="container"> <div class="container d-lg-flex justify-content-between">
<p class="float-end mb-1">
<a href="#">Back to top</a>
</p>
<div id="footer" class="mb-1"> <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>
<div id="footer_extended" class="mb-0"> </div>
<div class="container">
<div id="footer_extended">
{{ site_conf.footer_extended | safe }} {{ site_conf.footer_extended | safe }}
</div> </div>
</div> </div>
<div class="container d-flex text-body-secondary">
<div class="container"> <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>
<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 %}</p>
{% if site_conf.show_version %}<br>Version {{ site_conf.version }}{% endif %} <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> </div>
</footer> </footer>

View File

@@ -8,7 +8,7 @@
{% endfor %} {% endfor %}
</p> </p>
{% endif %} {% 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 %} {% endblock %}
{% block carousel %} {% block carousel %}
<div class="row"> <div class="row">
@@ -361,7 +361,7 @@
</tr> </tr>
<tr> <tr>
<th scope="row">Version</th> <th scope="row">Version</th>
<td>{{ rolling_stock.decoder.version }}</td> <td>{{ rolling_stock.decoder.version | default:"-"}}</td>
</tr> </tr>
<tr> <tr>
<th scope="row">Sound</th> <th scope="row">Sound</th>

View File

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

View File

@@ -7,4 +7,11 @@ $ cp -R ../sample_data/images/ <storage_folder>
# Disclaimer # 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.