From: Frédéric Perrin Date: Wed, 19 Oct 2016 23:37:24 +0000 (+0100) Subject: Add TinyMCE X-Git-Url: http://gitweb.fperrin.net/?p=djsite.git;a=commitdiff_plain;h=b22937332fc5fa45d2beb8fb0bf9495df7efa80c Add TinyMCE --- diff --git a/djsite/settings.py b/djsite/settings.py index d81d8bc..f8a0605 100644 --- a/djsite/settings.py +++ b/djsite/settings.py @@ -37,6 +37,7 @@ INSTALLED_APPS = ( 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'tinymce', 'quotes', ) @@ -101,3 +102,11 @@ USE_TZ = True # https://docs.djangoproject.com/en/1.8/howto/static-files/ STATIC_URL = '/static/' + +TINYMCE_DEFAULT_CONFIG = { +# 'theme_advanced_buttons1' : ['bold', 'underline', 'italic', 'separator', 'insertdate', 'inserttime'], + 'theme_advanced_buttons1' : 'undo,redo,cut,copy,paste,|,bold,italic,underline,strikethrough,fontsizeselect,removeformat,|,bullist,numlist,|,link,unlink', + 'theme_advanced_buttons2' : 'tablecontrols,table,row_props,cell_props,delete_col,delete_row,col_after,col_before,row_after,row_before,split_cells,merge_cells', + 'theme_advanced_buttons3' : "", + 'plugins': 'table', +} diff --git a/djsite/urls.py b/djsite/urls.py index 761ea47..3ffc7fc 100644 --- a/djsite/urls.py +++ b/djsite/urls.py @@ -18,5 +18,6 @@ from django.contrib import admin urlpatterns = [ url(r'^admin/', include(admin.site.urls)), + url(r'^tinymce/', include('tinymce.urls')), url(r'^quotes/', include('quotes.urls', namespace='quotes')), ] diff --git a/quotes/models.py b/quotes/models.py index 9c65abc..cdae648 100644 --- a/quotes/models.py +++ b/quotes/models.py @@ -1,7 +1,7 @@ from django.db import models +from tinymce import models as tinymce_models # Create your models here. - class Tag(models.Model): tag = models.CharField(max_length=100) def __unicode__(self): @@ -10,12 +10,12 @@ class Tag(models.Model): class Author(models.Model): name = models.CharField(max_length=100, help_text="Name of the author") - notes = models.TextField(blank=True, help_text= \ - "Notes about the author; may be left blank. Will \ - not be HTML-escaped.") + notes = tinymce_models.HTMLField(blank=True, help_text= \ + "Notes about the author; may be left blank. Will \ + not be HTML-escaped.",) pvt_notes = models.TextField(blank=True, help_text= \ "Notes about the author; not displayed on \ - the public interface") + the public interface",) tags = models.ManyToManyField(Tag, blank=True) birth_date = models.DateField(blank=True, null=True, @@ -62,7 +62,7 @@ class Work(models.Model): "Notes about the work; not displayed on \ the public interface") - def __unicode__(self): + def __str__(self): return "%s: %s (%s)" % (self.author.name, self.name, self.date) class Quote(models.Model):