From 6c4256d97caf234fe27b99e7ad663e6ccffa025c Mon Sep 17 00:00:00 2001 From: Dan Braghis <dan.braghis@torchbox.com> Date: Wed, 13 Jun 2018 16:38:22 +0100 Subject: [PATCH] Move simplified TinyMCE definition into utils.options --- opentech/apply/review/forms.py | 21 +-------------------- opentech/apply/utils/options.py | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 20 deletions(-) create mode 100644 opentech/apply/utils/options.py diff --git a/opentech/apply/review/forms.py b/opentech/apply/review/forms.py index bbc1b3bd7..e3ad719f0 100644 --- a/opentech/apply/review/forms.py +++ b/opentech/apply/review/forms.py @@ -1,7 +1,7 @@ from django import forms from django.core.exceptions import NON_FIELD_ERRORS, ValidationError -from tinymce.widgets import TinyMCE +from opentech.apply.utils.options import RICH_TEXT_WIDGET from .models import Review, RECOMMENDATION_CHOICES @@ -22,25 +22,6 @@ YES_NO_CHOICES = ( (0, 'No') ) -RICH_TEXT_WIDGET = TinyMCE(mce_attrs={ - 'elementpath': False, - 'branding': False, - 'toolbar1': 'undo redo | styleselect | bold italic | bullist numlist | link', - 'style_formats': [ - {'title': 'Headers', 'items': [ - {'title': 'Header 1', 'format': 'h1'}, - {'title': 'Header 2', 'format': 'h2'}, - {'title': 'Header 3', 'format': 'h3'}, - ]}, - {'title': 'Inline', 'items': [ - {'title': 'Bold', 'icon': 'bold', 'format': 'bold'}, - {'title': 'Italic', 'icon': 'italic', 'format': 'italic'}, - {'title': 'Underline', 'icon': 'underline', 'format': 'underline'}, - ]}, - ], - 'height': 180, -}) - class RichTextField(forms.CharField): widget = RICH_TEXT_WIDGET diff --git a/opentech/apply/utils/options.py b/opentech/apply/utils/options.py new file mode 100644 index 000000000..46bba71d7 --- /dev/null +++ b/opentech/apply/utils/options.py @@ -0,0 +1,21 @@ +from tinymce.widgets import TinyMCE + + +RICH_TEXT_WIDGET = TinyMCE(mce_attrs={ + 'elementpath': False, + 'branding': False, + 'toolbar1': 'undo redo | styleselect | bold italic | bullist numlist | link', + 'style_formats': [ + {'title': 'Headers', 'items': [ + {'title': 'Header 1', 'format': 'h1'}, + {'title': 'Header 2', 'format': 'h2'}, + {'title': 'Header 3', 'format': 'h3'}, + ]}, + {'title': 'Inline', 'items': [ + {'title': 'Bold', 'icon': 'bold', 'format': 'bold'}, + {'title': 'Italic', 'icon': 'italic', 'format': 'italic'}, + {'title': 'Underline', 'icon': 'underline', 'format': 'underline'}, + ]}, + ], + 'height': 180, +}) -- GitLab