Changement theme avec jazzmin

This commit is contained in:
Ambulance Clerc
2023-06-04 10:41:33 +02:00
parent e55af28b25
commit 0730f7426b
10 changed files with 36 additions and 16 deletions

View File

@@ -39,6 +39,7 @@ CSRF_TRUSTED_ORIGINS = ['https://rh.ambulance-clerc.ch']
# Application definition # Application definition
INSTALLED_APPS = [ INSTALLED_APPS = [
'jazzmin',
'django.contrib.auth', 'django.contrib.auth',
'django.contrib.contenttypes', 'django.contrib.contenttypes',
'django.contrib.sessions', 'django.contrib.sessions',
@@ -210,16 +211,16 @@ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
JAZZMIN_SETTINGS = { JAZZMIN_SETTINGS = {
# title of the window (Will default to current_admin_site.site_title if absent or None) # title of the window (Will default to current_admin_site.site_title if absent or None)
"site_title": "Reskreen-Admin", "site_title": "ClercNet-Admin",
# Title on the login screen (19 chars max) (defaults to current_admin_site.site_header if absent or None) # Title on the login screen (19 chars max) (defaults to current_admin_site.site_header if absent or None)
"site_header": "Reskreen", "site_header": "ClercNet",
# Title on the brand (19 chars max) (defaults to current_admin_site.site_header if absent or None) # Title on the brand (19 chars max) (defaults to current_admin_site.site_header if absent or None)
"site_brand": "Reskreen", "site_brand": "ClercNet",
# Logo to use for your site, must be present in static files, used for brand on top left # Logo to use for your site, must be present in static files, used for brand on top left
"site_logo": "books/img/logo.png", "site_logo": "img/logo.png",
# CSS classes that are applied to the logo above # CSS classes that are applied to the logo above
"site_logo_classes": "img-circle", "site_logo_classes": "img-circle",
@@ -228,10 +229,10 @@ JAZZMIN_SETTINGS = {
"site_icon": None, "site_icon": None,
# Welcome text on the login screen # Welcome text on the login screen
"welcome_sign": "Welcome to the Reskreen admin", "welcome_sign": "Welcome to the ClercNet admin",
# Copyright on the footer # Copyright on the footer
"copyright": "Resk-U", "copyright": "Ambulance Clerc & Resk-U",
# The model admin to search from the search bar, search bar omitted if excluded # The model admin to search from the search bar, search bar omitted if excluded
"search_model": "auth.User", "search_model": "auth.User",
@@ -256,7 +257,7 @@ JAZZMIN_SETTINGS = {
{"model": "auth.User"}, {"model": "auth.User"},
# App with dropdown menu to all its models pages (Permissions checked against models) # App with dropdown menu to all its models pages (Permissions checked against models)
{"app": "polls"}, {"app": "carnet_rouge"},
], ],
############# #############

Binary file not shown.

After

Width:  |  Height:  |  Size: 311 KiB

View File

@@ -16,7 +16,12 @@ Including another URLconf
from django.contrib import admin from django.contrib import admin
from django.urls import path, include from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
from django.views.generic import RedirectView
urlpatterns = [ urlpatterns = [
path('', RedirectView.as_view(url='admin/login/', permanent=False), name='/'),
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
path('accounts/', admin.site.urls), path('accounts/', admin.site.urls),
path('collabs/', include('collabs.urls')), path('collabs/', include('collabs.urls')),
@@ -24,4 +29,9 @@ urlpatterns = [
path('caldav/', include('mycaldav.urls')), path('caldav/', include('mycaldav.urls')),
#path('collabs_hour/', include('collabs.urls')), #path('collabs_hour/', include('collabs.urls')),
path('carnet_rouge/', include('carnet_rouge.urls')), path('carnet_rouge/', include('carnet_rouge.urls')),
path('summernote/', include('django_summernote.urls')),
path('editor/', include('django_summernote.urls')),
] ]
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

View File

@@ -84,7 +84,7 @@ class cr_Message_Admin(SummernoteModelAdmin):
always_show_username = True always_show_username = True
list_display = ('id', 'DestGroup', 'sTitle', 'get_dtCreated', 'sAuthor','bEnabled', 'calc_read_quotas') list_display = ('MessageId','sTitle', 'DestGroup', 'get_dtCreated', 'sAuthor','bEnabled', 'calc_read_quotas')
list_filter = ["sAuthor", StatusFilter] list_filter = ["sAuthor", StatusFilter]
fields = ["Caterogy", "DestGroup", 'sTitle', "sText", "dtValidityFrom", "dtValidityTo", "bEnabled"] fields = ["Caterogy", "DestGroup", 'sTitle', "sText", "dtValidityFrom", "dtValidityTo", "bEnabled"]
search_fields = ['sTitle', 'sText'] search_fields = ['sTitle', 'sText']

View File

@@ -3,6 +3,7 @@ from django.db import models
from django.conf import settings from django.conf import settings
from django.contrib.auth.models import Group from django.contrib.auth.models import Group
from django.utils import timezone from django.utils import timezone
import uuid
from django_quill.fields import QuillField from django_quill.fields import QuillField
from django.dispatch import receiver from django.dispatch import receiver
@@ -22,13 +23,21 @@ class cr_Category(models.Model):
verbose_name = "catégorie" verbose_name = "catégorie"
verbose_name_plural = "catégories" verbose_name_plural = "catégories"
def increment_MessageId():
last_id = cr_Message.objects.all().order_by('MessageId').last()
if not last_id:
return 1
last_id = last_id.MessageId
return last_id + 1
class cr_Message(models.Model): class cr_Message(models.Model):
uuid = models.UUIDField(default=uuid.uuid4(), editable=False, primary_key=True)
MessageId = models.IntegerField("ID Message",editable=False, unique=True, default=increment_MessageId)
Caterogy = models.ForeignKey(cr_Category, on_delete=models.DO_NOTHING, verbose_name="Catégorie") Caterogy = models.ForeignKey(cr_Category, on_delete=models.DO_NOTHING, verbose_name="Catégorie")
sDestUsers = models.TextField("Liste des utilisateurs cibles") sDestUsers = models.TextField("Liste des utilisateurs cibles")
sNotReadUsers = models.TextField() sNotReadUsers = models.TextField()
sReadedUsers = models.TextField("Liste des utilisateurs ayant lu", blank=True) sReadedUsers = models.TextField("Liste des utilisateurs ayant lu", blank=True)
DestGroup = models.ForeignKey(Group, on_delete=models.DO_NOTHING) DestGroup = models.ForeignKey(Group, on_delete=models.DO_NOTHING, verbose_name="Groupe de destination")
sTitle = models.CharField("Titre", max_length=120) sTitle = models.CharField("Titre", max_length=120)
sText = models.TextField ("Corps de texte") sText = models.TextField ("Corps de texte")
dtValidityFrom = models.DateField("Validité depuis",default=timezone.now) dtValidityFrom = models.DateField("Validité depuis",default=timezone.now)
@@ -42,6 +51,8 @@ class cr_Message(models.Model):
dtUpdated = models.DateTimeField('date updated', auto_now=True) dtUpdated = models.DateTimeField('date updated', auto_now=True)
dtCreated = models.DateTimeField('date published', auto_now_add=True) dtCreated = models.DateTimeField('date published', auto_now_add=True)
def get_dtCreated(self): def get_dtCreated(self):
return self.dtCreated.strftime("%d.%b.%Y %H:%M:%S") return self.dtCreated.strftime("%d.%b.%Y %H:%M:%S")

View File

@@ -6,6 +6,7 @@
<div class="col"> <div class="col">
{% if object_list %} {% if object_list %}
{% for obj in object_list %} {% for obj in object_list %}
<h2>{{ obj.sTitle }}</h2>
{% include 'carnet_rouge/cr_message.html' with obj=obj %} {% include 'carnet_rouge/cr_message.html' with obj=obj %}
{% if not forloop.last %} {% if not forloop.last %}
<hr>{% endif %} <hr>{% endif %}

View File

@@ -9,11 +9,7 @@ from carnet_rouge import views
app_name = "carnet_rouge" app_name = "carnet_rouge"
urlpatterns = [ urlpatterns = [
path('cr', views.model_form_view, name='model_form_view'), path('cr', views.model_form_view, name='model_form_view'),
path('view/<int:pk>', views.CrDetailView.as_view(), name='cr_view'), path('view/<uuid:pk>', views.CrDetailView.as_view(), name='cr_view'),
path('notread', views.CrNotReadView.as_view(), name='cr_not_read_list'), path('notread', views.CrNotReadView.as_view(), name='cr_not_read_list'),
path('summernote/', include('django_summernote.urls')),
path('editor/', include('django_summernote.urls')),
] ]
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

View File

@@ -15,6 +15,7 @@ class CrDetailView(DetailView):
context["test"] = timezone.now() context["test"] = timezone.now()
return context return context
class CrNotReadView(ListView): class CrNotReadView(ListView):
model = cr_Message model = cr_Message

View File

@@ -13,7 +13,6 @@ cssselect2==0.4.1
Django==4.0 Django==4.0
django-admin-rangefilter==0.8.3 django-admin-rangefilter==0.8.3
django-baton==2.2.3 django-baton==2.2.3
django-jazzmin==2.4.8
fonttools==4.29.1 fonttools==4.29.1
fpdf==1.7.2 fpdf==1.7.2
future==0.18.2 future==0.18.2
@@ -57,3 +56,4 @@ xhtml2pdf==0.2.7
zopfli==0.1.9 zopfli==0.1.9
django-autologin django-autologin
django-summernote django-summernote
django-jazzmin