Added HTML editor

This commit is contained in:
Zak Timson 2017-09-04 02:30:16 -04:00
parent b19214edca
commit a8a4c8d239
5 changed files with 9 additions and 4 deletions

View File

@ -40,6 +40,7 @@ INSTALLED_APPS = [
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'forum.apps.ForumConfig', 'forum.apps.ForumConfig',
'froala_editor',
'main.apps.MainConfig', 'main.apps.MainConfig',
'newsletters.apps.NewslettersConfig' 'newsletters.apps.NewslettersConfig'
] ]

View File

@ -1,7 +1,7 @@
import os import os
from django.conf import settings 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 import admin
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.views.static import serve from django.views.static import serve
@ -21,8 +21,9 @@ urlpatterns = [
url(r'^admin/logout', main.views.logout, name='logout'), url(r'^admin/logout', main.views.logout, name='logout'),
url(r'^admin/', admin.site.urls, name='admin'), url(r'^admin/', admin.site.urls, name='admin'),
url(r'^attorney/(?P<id>\d+)', charter_members.views.index, name='attorney'), url(r'^attorney/(?P<id>\d+)', charter_members.views.index, name='attorney'),
url(r'^froala_editor/', include('froala_editor.urls')),
url(r'^media/secure/(?P<path>.*)$', protected_serve, {'document_root': os.path.join(settings.MEDIA_ROOT, 'secure')}, name='secure media'), url(r'^media/secure/(?P<path>.*)$', protected_serve, {'document_root': os.path.join(settings.MEDIA_ROOT, 'secure')}, name='secure media'),
url(r'^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT}, name='media'), url(r'^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT}, name='media'),
url(r'^newsletter/subscribe', newsletters.views.subscribe, name='subscribe'), 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'),
] ]

View File

@ -2,9 +2,11 @@ from django.db import models
from django.contrib.auth.admin import User from django.contrib.auth.admin import User
from django.utils.timezone import now from django.utils.timezone import now
from froala_editor.fields import FroalaField
class Newsletter(models.Model): class Newsletter(models.Model):
body = models.TextField() body = FroalaField()
created = models.DateTimeField(auto_now_add=True) created = models.DateTimeField(auto_now_add=True)
creator = models.ForeignKey(User) creator = models.ForeignKey(User)
publish = models.DateTimeField(default=now()) publish = models.DateTimeField(default=now())

View File

@ -26,7 +26,7 @@
</div> </div>
<div id="newsletter-body-{{ newsletter.id }}" class="bg-light-blue collapse"> <div id="newsletter-body-{{ newsletter.id }}" class="bg-light-blue collapse">
<div class="p-3"> <div class="p-3">
{{ newsletter.body }} {{ newsletter.body | safe }}
</div> </div>
</div> </div>
</div> </div>

View File

@ -2,3 +2,4 @@ bootstrap-admin==0.3.7.1
Django==1.11.4 Django==1.11.4
Pillow==4.2.1 Pillow==4.2.1
requests==2.11.1 requests==2.11.1
django-froala-editor==2.6.5