mirror of
https://github.com/daniviga/django-ram.git
synced 2025-08-04 05:07:50 +02:00
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:
@@ -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):
|
||||
|
19
ram/portal/migrations/0019_siteconfiguration_disclaimer.py
Normal file
19
ram/portal/migrations/0019_siteconfiguration_disclaimer.py
Normal 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),
|
||||
),
|
||||
]
|
@@ -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()
|
||||
|
||||
|
@@ -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">
|
||||
|
@@ -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">
|
||||
|
@@ -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 %}
|
||||
|
@@ -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 %}
|
||||
|
@@ -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 %}
|
||||
|
@@ -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>© {% now "Y" %}</p> {{ site_conf.footer | safe }}
|
||||
<p>© {% 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>
|
||||
|
@@ -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>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
from ram.utils import git_suffix
|
||||
|
||||
__version__ = "0.16.7"
|
||||
__version__ = "0.16.8"
|
||||
__version__ += git_suffix(__file__)
|
||||
|
Reference in New Issue
Block a user