diff --git a/common/settings.py b/common/settings.py index 6aca6a5..8a7a982 100644 --- a/common/settings.py +++ b/common/settings.py @@ -92,6 +92,7 @@ INSTALLED_APPS = ( 'django.contrib.staticfiles', 'django.contrib.admin', + 'django_summernote', 'tabimport', 'stages', 'candidats', @@ -106,6 +107,19 @@ ALLOWED_HOSTS = ['localhost', 'stages.pierre-coullery.ch'] # candidats admin shows confirmation_date readonly field twice. SILENCED_SYSTEM_CHECKS = ['admin.E012'] +SUMMERNOTE_CONFIG = { + 'summernote': { + 'toolbar': [ + # [groupName, [list of button]] + ['style', ['bold', 'italic', 'underline', 'clear']], + ['font', ['strikethrough']], + ['fontsize', ['fontsize']], + ['color', ['color']], + ['para', ['ul', 'ol', 'paragraph']], + ] + } +} + FABRIC_HOST = 'gestion.pierre-coullery.ch' FABRIC_USERNAME = '' diff --git a/common/urls.py b/common/urls.py index 3d0fc95..491f813 100644 --- a/common/urls.py +++ b/common/urls.py @@ -2,7 +2,7 @@ import os from django.conf import settings from django.contrib import admin -from django.urls import path, re_path +from django.urls import include, path, re_path from django.views.generic import RedirectView from django.views.static import serve @@ -75,6 +75,7 @@ urlpatterns = [ path('availability//summary/', views.AvailabilitySummaryView.as_view()), path('corporation//contacts/', views.CorpContactJSONView.as_view()), + path('summernote/', include('django_summernote.urls')), # Serve bulletins by Django to allow LoginRequiredMiddleware to apply path('media/bulletins/', serve, {'document_root': os.path.join(settings.MEDIA_ROOT, 'bulletins'), 'show_indexes': False} diff --git a/requirements.txt b/requirements.txt index 5a274ad..70821b8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,4 @@ tabimport>=0.4.0 openpyxl==2.4.9 xlrd reportlab +django-summernote==0.8.11.4 diff --git a/stages/forms.py b/stages/forms.py index 60d74a8..3e7dbe5 100644 --- a/stages/forms.py +++ b/stages/forms.py @@ -5,6 +5,7 @@ from django.db.models.deletion import Collector from django.forms import inlineformset_factory from django.urls import reverse +from django_summernote.widgets import SummernoteWidget from tabimport import FileFactory, UnsupportedFileFormat from .models import Corporation, Period, Section, Student, StudentFile @@ -120,6 +121,9 @@ class StudentCommentForm(forms.ModelForm): class Meta: model = Student fields = ('mc_comment',) + widgets = { + 'mc_comment': SummernoteWidget, + } def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) diff --git a/templates/student_comment.html b/templates/student_comment.html index 485bc1f..2230bef 100644 --- a/templates/student_comment.html +++ b/templates/student_comment.html @@ -3,7 +3,7 @@ {% block extrastyle %}{{ block.super }}