Skip to content
Snippets Groups Projects
Commit 5f188647 authored by Todd Dembrey's avatar Todd Dembrey
Browse files

Add Tinymce as a richtext editor

parent ee1fcae9
No related branches found
No related tags found
No related merge requests found
...@@ -7,8 +7,10 @@ from django.utils.translation import ugettext_lazy as _ ...@@ -7,8 +7,10 @@ from django.utils.translation import ugettext_lazy as _
from django.utils.text import mark_safe from django.utils.text import mark_safe
from wagtail.wagtailcore.blocks import StaticBlock from wagtail.wagtailcore.blocks import StaticBlock
from opentech.apply.stream_forms.blocks import FormFieldsBlock, FormFieldBlock
from tinymce.widgets import TinyMCE
from opentech.apply.stream_forms.blocks import FormFieldsBlock, FormFieldBlock, TextFieldBlock
from opentech.apply.categories.blocks import CategoryQuestionBlock from opentech.apply.categories.blocks import CategoryQuestionBlock
...@@ -20,7 +22,19 @@ def find_duplicates(items): ...@@ -20,7 +22,19 @@ def find_duplicates(items):
return duplicates return duplicates
class RichTextFieldBlock(TextFieldBlock):
widget = TinyMCE(mce_attrs={
'elementpath': False,
'branding': False,
})
class Meta:
label = _('Rich text field')
icon = 'form'
class CustomFormFieldsBlock(FormFieldsBlock): class CustomFormFieldsBlock(FormFieldsBlock):
rich_text = RichTextFieldBlock(group=_('Fields'))
category = CategoryQuestionBlock(group=_('Custom')) category = CategoryQuestionBlock(group=_('Custom'))
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
......
{% extends "base.html" %} {% extends "base.html" %}
{% load wagtailcore_tags %} {% load wagtailcore_tags static %}
{% block content %} {% block content %}
<h1>{% block title %}{{ page.title }}{% endblock %}</h1> <h1>{% block title %}{{ page.title }}{% endblock %}</h1>
<form action="" method="POST"> <form action="" method="POST">
{{ form.media }}
{% csrf_token %} {% csrf_token %}
{% if form.errors or form.non_field_errors %} {% if form.errors or form.non_field_errors %}
......
...@@ -230,6 +230,7 @@ class FileFieldBlock(OptionalFormFieldBlock): ...@@ -230,6 +230,7 @@ class FileFieldBlock(OptionalFormFieldBlock):
class FormFieldsBlock(StreamBlock): class FormFieldsBlock(StreamBlock):
text_markup = RichTextBlock(group=_('Other'), label=_('Paragraph'))
char = CharFieldBlock(group=_('Fields')) char = CharFieldBlock(group=_('Fields'))
text = TextFieldBlock(group=_('Fields')) text = TextFieldBlock(group=_('Fields'))
number = NumberFieldBlock(group=_('Fields')) number = NumberFieldBlock(group=_('Fields'))
...@@ -242,7 +243,6 @@ class FormFieldsBlock(StreamBlock): ...@@ -242,7 +243,6 @@ class FormFieldsBlock(StreamBlock):
datetime = DateTimeFieldBlock(group=_('Fields')) datetime = DateTimeFieldBlock(group=_('Fields'))
image = ImageFieldBlock(group=_('Fields')) image = ImageFieldBlock(group=_('Fields'))
file = FileFieldBlock(group=_('Fields')) file = FileFieldBlock(group=_('Fields'))
text_markup = RichTextBlock(group=_('Other'), label=_('Paragraph'))
class Meta: class Meta:
label = _('Form fields') label = _('Form fields')
...@@ -55,6 +55,7 @@ INSTALLED_APPS = [ ...@@ -55,6 +55,7 @@ INSTALLED_APPS = [
'taggit', 'taggit',
'django_extensions', 'django_extensions',
'captcha', 'captcha',
'tinymce',
'wagtailcaptcha', 'wagtailcaptcha',
'django_tables2', 'django_tables2',
......
...@@ -23,6 +23,7 @@ urlpatterns = [ ...@@ -23,6 +23,7 @@ urlpatterns = [
url('^', include(public_urls)), url('^', include(public_urls)),
url('^', include(apply_urls)), url('^', include(apply_urls)),
url('^', include('social_django.urls', namespace='social')), url('^', include('social_django.urls', namespace='social')),
url(r'^tinymce/', include('tinymce.urls')),
] ]
......
...@@ -5,11 +5,14 @@ Pillow==4.3.0 ...@@ -5,11 +5,14 @@ Pillow==4.3.0
django-extensions==1.7.4 django-extensions==1.7.4
Werkzeug==0.11.11 Werkzeug==0.11.11
stellar==0.4.3 stellar==0.4.3
django-tinymce4-lite==1.7.0
wagtail-django-recaptcha==0.1 wagtail-django-recaptcha==0.1
uwsgidecorators==1.1.0 uwsgidecorators==1.1.0
mypy==0.550 mypy==0.550
factory_boy==2.9.2 factory_boy==2.9.2
wagtail_factories==0.3.0 wagtail_factories==0.3.0
flake8 flake8
social_auth_app_django==2.1.0 social_auth_app_django==2.1.0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment