diff --git a/Reskreen/settings.py b/Reskreen/settings.py index 509fd3f..c7c6f11 100644 --- a/Reskreen/settings.py +++ b/Reskreen/settings.py @@ -39,6 +39,7 @@ CSRF_TRUSTED_ORIGINS = ['https://rh.ambulance-clerc.ch'] # Application definition INSTALLED_APPS = [ + 'jazzmin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', @@ -210,16 +211,16 @@ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' JAZZMIN_SETTINGS = { # 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) - "site_header": "Reskreen", + "site_header": "ClercNet", # 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 - "site_logo": "books/img/logo.png", + "site_logo": "img/logo.png", # CSS classes that are applied to the logo above "site_logo_classes": "img-circle", @@ -228,10 +229,10 @@ JAZZMIN_SETTINGS = { "site_icon": None, # 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": "Resk-U", + "copyright": "Ambulance Clerc & Resk-U", # The model admin to search from the search bar, search bar omitted if excluded "search_model": "auth.User", @@ -256,7 +257,7 @@ JAZZMIN_SETTINGS = { {"model": "auth.User"}, # App with dropdown menu to all its models pages (Permissions checked against models) - {"app": "polls"}, + {"app": "carnet_rouge"}, ], ############# diff --git a/Reskreen/static/img/logo.png b/Reskreen/static/img/logo.png new file mode 100644 index 0000000..8351a9f Binary files /dev/null and b/Reskreen/static/img/logo.png differ diff --git a/Reskreen/urls.py b/Reskreen/urls.py index 6fe2103..83d499f 100644 --- a/Reskreen/urls.py +++ b/Reskreen/urls.py @@ -16,7 +16,12 @@ Including another URLconf from django.contrib import admin 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 = [ + path('', RedirectView.as_view(url='admin/login/', permanent=False), name='/'), path('admin/', admin.site.urls), path('accounts/', admin.site.urls), path('collabs/', include('collabs.urls')), @@ -24,4 +29,9 @@ urlpatterns = [ path('caldav/', include('mycaldav.urls')), #path('collabs_hour/', include('collabs.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) \ No newline at end of file diff --git a/carnet_rouge/admin.py b/carnet_rouge/admin.py index 5a83353..8a4b806 100644 --- a/carnet_rouge/admin.py +++ b/carnet_rouge/admin.py @@ -84,7 +84,7 @@ class cr_Message_Admin(SummernoteModelAdmin): 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] fields = ["Caterogy", "DestGroup", 'sTitle', "sText", "dtValidityFrom", "dtValidityTo", "bEnabled"] search_fields = ['sTitle', 'sText'] diff --git a/carnet_rouge/migrations/__init__.py b/carnet_rouge/migrations/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/carnet_rouge/models.py b/carnet_rouge/models.py index 07e7700..91c6d46 100644 --- a/carnet_rouge/models.py +++ b/carnet_rouge/models.py @@ -3,6 +3,7 @@ from django.db import models from django.conf import settings from django.contrib.auth.models import Group from django.utils import timezone +import uuid from django_quill.fields import QuillField from django.dispatch import receiver @@ -22,13 +23,21 @@ class cr_Category(models.Model): verbose_name = "catégorie" 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): + 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") sDestUsers = models.TextField("Liste des utilisateurs cibles") sNotReadUsers = models.TextField() 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) sText = models.TextField ("Corps de texte") 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) dtCreated = models.DateTimeField('date published', auto_now_add=True) + + def get_dtCreated(self): return self.dtCreated.strftime("%d.%b.%Y %H:%M:%S") diff --git a/carnet_rouge/templates/carnet_rouge/cr_message_list.html b/carnet_rouge/templates/carnet_rouge/cr_message_list.html index 6844e56..c717d6c 100644 --- a/carnet_rouge/templates/carnet_rouge/cr_message_list.html +++ b/carnet_rouge/templates/carnet_rouge/cr_message_list.html @@ -6,6 +6,7 @@
{% if object_list %} {% for obj in object_list %} +

{{ obj.sTitle }}

{% include 'carnet_rouge/cr_message.html' with obj=obj %} {% if not forloop.last %}
{% endif %} diff --git a/carnet_rouge/urls.py b/carnet_rouge/urls.py index bdec56b..f402747 100644 --- a/carnet_rouge/urls.py +++ b/carnet_rouge/urls.py @@ -9,11 +9,7 @@ from carnet_rouge import views app_name = "carnet_rouge" urlpatterns = [ path('cr', views.model_form_view, name='model_form_view'), - path('view/', views.CrDetailView.as_view(), name='cr_view'), + path('view/', views.CrDetailView.as_view(), name='cr_view'), 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) diff --git a/carnet_rouge/views.py b/carnet_rouge/views.py index ce08b84..ac99abb 100644 --- a/carnet_rouge/views.py +++ b/carnet_rouge/views.py @@ -15,6 +15,7 @@ class CrDetailView(DetailView): context["test"] = timezone.now() return context + class CrNotReadView(ListView): model = cr_Message diff --git a/requirements.txt b/requirements.txt index 97d6b3d..e1a40bb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,7 +13,6 @@ cssselect2==0.4.1 Django==4.0 django-admin-rangefilter==0.8.3 django-baton==2.2.3 -django-jazzmin==2.4.8 fonttools==4.29.1 fpdf==1.7.2 future==0.18.2 @@ -56,4 +55,5 @@ x-wr-timezone==0.0.5 xhtml2pdf==0.2.7 zopfli==0.1.9 django-autologin -django-summernote \ No newline at end of file +django-summernote +django-jazzmin \ No newline at end of file