diff --git a/opentech/apply/review/forms.py b/opentech/apply/review/forms.py index bbc1b3bd733ce0779f92d28e2c303f38c512cae9..e3ad719f0d700e34c6fa5a021a7caaf9faf67dfa 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 0000000000000000000000000000000000000000..46bba71d70294d6768daa260c2f11a123f2a7aa7 --- /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, +})