diff --git a/README.md b/README.md index 308c4be..05f6e69 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/ram/portal/admin.py b/ram/portal/admin.py index cf9ee55..50d8ec7 100644 --- a/ram/portal/admin.py +++ b/ram/portal/admin.py @@ -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): diff --git a/ram/portal/migrations/0019_siteconfiguration_disclaimer.py b/ram/portal/migrations/0019_siteconfiguration_disclaimer.py new file mode 100644 index 0000000..773204e --- /dev/null +++ b/ram/portal/migrations/0019_siteconfiguration_disclaimer.py @@ -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), + ), + ] diff --git a/ram/portal/models.py b/ram/portal/models.py index feea71d..31cb779 100644 --- a/ram/portal/models.py +++ b/ram/portal/models.py @@ -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() diff --git a/ram/portal/templates/bookshelf/book.html b/ram/portal/templates/bookshelf/book.html index 607720f..0acecef 100644 --- a/ram/portal/templates/bookshelf/book.html +++ b/ram/portal/templates/bookshelf/book.html @@ -9,7 +9,7 @@ {% endfor %}

{% endif %} - Updated {{ book.updated_time | date:"M d, Y H:i" }} + Updated {{ book.updated_time | date:"M d, Y H:i" }} {% endblock %} {% block carousel %}
diff --git a/ram/portal/templates/cards.html b/ram/portal/templates/cards.html index b62276b..d80659b 100644 --- a/ram/portal/templates/cards.html +++ b/ram/portal/templates/cards.html @@ -1,6 +1,6 @@ {% extends "base.html" %} {% block header %} -

Results found: {{ matches }}

+

Results found: {{ matches }}

{% endblock %} {% block cards_layout %}
diff --git a/ram/portal/templates/consist.html b/ram/portal/templates/consist.html index b380005..254de34 100644 --- a/ram/portal/templates/consist.html +++ b/ram/portal/templates/consist.html @@ -7,7 +7,7 @@ {{ t.name }}{# new line is required #} {% endfor %}

- Updated {{ consist.updated_time | date:"M d, Y H:i" }} + Updated {{ consist.updated_time | date:"M d, Y H:i" }} {% endif %} {% endblock %} {% block carousel %} diff --git a/ram/portal/templates/flatpages/flatpage.html b/ram/portal/templates/flatpages/flatpage.html index 418fb01..004a098 100644 --- a/ram/portal/templates/flatpages/flatpage.html +++ b/ram/portal/templates/flatpages/flatpage.html @@ -1,7 +1,7 @@ {% extends 'base.html' %} {% block header %} - Updated {{ flatpage.updated_time | date:"M d, Y H:i" }} + Updated {{ flatpage.updated_time | date:"M d, Y H:i" }} {% endblock %} {% block carousel %} {% endblock %} diff --git a/ram/portal/templates/home.html b/ram/portal/templates/home.html index f7080bd..cba2ba2 100644 --- a/ram/portal/templates/home.html +++ b/ram/portal/templates/home.html @@ -1,5 +1,5 @@ {% extends "pagination.html" %} {% block header %} -
{{ site_conf.about | safe }}
+
{{ site_conf.about | safe }}
{% endblock %} diff --git a/ram/portal/templates/includes/footer.html b/ram/portal/templates/includes/footer.html index 8e57903..fd53602 100644 --- a/ram/portal/templates/includes/footer.html +++ b/ram/portal/templates/includes/footer.html @@ -1,18 +1,34 @@ -