diff --git a/dbtemplates/admin.py b/dbtemplates/admin.py index efdfbcb..7e4dae8 100644 --- a/dbtemplates/admin.py +++ b/dbtemplates/admin.py @@ -1,6 +1,7 @@ import posixpath from django import forms from django.contrib import admin +from django.core.exceptions import ImproperlyConfigured from django.utils.translation import ungettext, ugettext_lazy as _ from django.utils.safestring import mark_safe @@ -59,6 +60,14 @@ if settings.DBTEMPLATES_AUTO_POPULATE_CONTENT: else: content_help_text = "" +if settings.DBTEMPLATES_USE_CODEMIRROR and settings.DBTEMPLATES_USE_TINYMCE: + raise ImproperlyConfigured("You may use either CodeMirror or TinyMCE " + "with dbtemplates, not both. Please disable one of them.") + +if settings.DBTEMPLATES_USE_TINYMCE: + from tinymce.widgets import AdminTinyMCE + TemplateContentTextArea = AdminTinyMCE + class TemplateAdminForm(forms.ModelForm): """ diff --git a/dbtemplates/conf.py b/dbtemplates/conf.py index e1075a2..0bcf4ec 100644 --- a/dbtemplates/conf.py +++ b/dbtemplates/conf.py @@ -9,6 +9,7 @@ from appconf import AppConf class DbTemplatesConf(AppConf): USE_CODEMIRROR = False USE_REVERSION = False + USE_TINYMCE = False ADD_DEFAULT_SITE = True AUTO_POPULATE_CONTENT = True MEDIA_PREFIX = None @@ -40,3 +41,9 @@ class DbTemplatesConf(AppConf): raise ImproperlyConfigured("Please add 'reversion' to your " "INSTALLED_APPS setting to make use of it in dbtemplates.") return value + + def configure_use_tinymce(self, value): + if value and 'tinymce' not in settings.INSTALLED_APPS: + raise ImproperlyConfigured("Please add 'tinymce' to your " + "INSTALLED_APPS setting to make use of it in dbtemplates.") + return value