From a8a4c8d239703b38d6e1a01e2cd9fa5632234a21 Mon Sep 17 00:00:00 2001 From: Zak Timson Date: Mon, 4 Sep 2017 02:30:16 -0400 Subject: [PATCH] Added HTML editor --- OACPL/settings.base.py | 1 + OACPL/urls.py | 5 +++-- newsletters/models.py | 4 +++- newsletters/templates/newsletters.html | 2 +- requirements.txt | 1 + 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/OACPL/settings.base.py b/OACPL/settings.base.py index 1904b2f..51c244e 100644 --- a/OACPL/settings.base.py +++ b/OACPL/settings.base.py @@ -40,6 +40,7 @@ INSTALLED_APPS = [ 'django.contrib.messages', 'django.contrib.staticfiles', 'forum.apps.ForumConfig', + 'froala_editor', 'main.apps.MainConfig', 'newsletters.apps.NewslettersConfig' ] diff --git a/OACPL/urls.py b/OACPL/urls.py index 554f489..b62233c 100644 --- a/OACPL/urls.py +++ b/OACPL/urls.py @@ -1,7 +1,7 @@ import os from django.conf import settings -from django.conf.urls import url +from django.conf.urls import include, url from django.contrib import admin from django.contrib.auth.decorators import login_required from django.views.static import serve @@ -21,8 +21,9 @@ urlpatterns = [ url(r'^admin/logout', main.views.logout, name='logout'), url(r'^admin/', admin.site.urls, name='admin'), url(r'^attorney/(?P\d+)', charter_members.views.index, name='attorney'), + url(r'^froala_editor/', include('froala_editor.urls')), url(r'^media/secure/(?P.*)$', protected_serve, {'document_root': os.path.join(settings.MEDIA_ROOT, 'secure')}, name='secure media'), url(r'^media/(?P.*)$', serve, {'document_root': settings.MEDIA_ROOT}, name='media'), url(r'^newsletter/subscribe', newsletters.views.subscribe, name='subscribe'), - url(r'^newsletter/', newsletters.views.newsletters, name='newsletters') + url(r'^newsletter/', newsletters.views.newsletters, name='newsletters'), ] diff --git a/newsletters/models.py b/newsletters/models.py index 069e6a8..0f8e523 100644 --- a/newsletters/models.py +++ b/newsletters/models.py @@ -2,9 +2,11 @@ from django.db import models from django.contrib.auth.admin import User from django.utils.timezone import now +from froala_editor.fields import FroalaField + class Newsletter(models.Model): - body = models.TextField() + body = FroalaField() created = models.DateTimeField(auto_now_add=True) creator = models.ForeignKey(User) publish = models.DateTimeField(default=now()) diff --git a/newsletters/templates/newsletters.html b/newsletters/templates/newsletters.html index 3474985..dacd87a 100644 --- a/newsletters/templates/newsletters.html +++ b/newsletters/templates/newsletters.html @@ -26,7 +26,7 @@
- {{ newsletter.body }} + {{ newsletter.body | safe }}
diff --git a/requirements.txt b/requirements.txt index e43a349..91468d2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,4 @@ bootstrap-admin==0.3.7.1 Django==1.11.4 Pillow==4.2.1 requests==2.11.1 +django-froala-editor==2.6.5