Added TinyMCE support via django-tinymce

This commit is contained in:
Mark Stahler 2012-01-17 21:22:22 -05:00
parent b13ffbb248
commit 02aaad635a
3 changed files with 20 additions and 0 deletions

View file

@ -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:
TemplateContentTextArea = TinyMce
else:
TemplateContentTextArea = forms.Textarea
class TemplateAdminForm(forms.ModelForm):
"""

View file

@ -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

4
dbtemplates/urls.py Normal file
View file

@ -0,0 +1,4 @@
from django.conf.urls.defaults import *
if 'tinymce' in settings.INSTALLED_APPS:
urlpatterns += patterns('', url(r'^tinymce/', include('tinymce.urls')))