2011-07-01 13:44:09 +00:00
|
|
|
import posixpath
|
|
|
|
|
|
|
|
|
|
from django.core.exceptions import ImproperlyConfigured
|
2011-09-06 10:31:28 +00:00
|
|
|
from django.conf import settings
|
2011-07-01 13:44:09 +00:00
|
|
|
|
2011-09-06 10:31:28 +00:00
|
|
|
from appconf import AppConf
|
2011-07-01 13:44:09 +00:00
|
|
|
|
|
|
|
|
|
2011-09-06 10:31:28 +00:00
|
|
|
class DbTemplatesConf(AppConf):
|
2011-07-01 13:44:09 +00:00
|
|
|
USE_CODEMIRROR = False
|
|
|
|
|
USE_REVERSION = False
|
2019-06-19 13:41:00 +00:00
|
|
|
USE_REVERSION_COMPARE = False
|
2012-01-18 02:22:22 +00:00
|
|
|
USE_TINYMCE = False
|
2012-09-05 18:27:55 +00:00
|
|
|
USE_REDACTOR = False
|
2011-07-01 13:44:09 +00:00
|
|
|
ADD_DEFAULT_SITE = True
|
|
|
|
|
AUTO_POPULATE_CONTENT = True
|
|
|
|
|
MEDIA_PREFIX = None
|
|
|
|
|
CACHE_BACKEND = None
|
|
|
|
|
|
|
|
|
|
def configure_media_prefix(self, value):
|
|
|
|
|
if value is None:
|
2011-09-06 10:31:28 +00:00
|
|
|
base_url = getattr(settings, "STATIC_URL", None)
|
2011-07-01 13:44:09 +00:00
|
|
|
if base_url is None:
|
2011-09-06 10:31:28 +00:00
|
|
|
base_url = settings.MEDIA_URL
|
2011-07-01 13:44:09 +00:00
|
|
|
value = posixpath.join(base_url, "dbtemplates/")
|
|
|
|
|
return value
|
|
|
|
|
|
|
|
|
|
def configure_cache_backend(self, value):
|
|
|
|
|
# If we are on Django 1.3 AND using the new CACHES setting..
|
2011-09-06 10:31:28 +00:00
|
|
|
if hasattr(settings, "CACHES"):
|
|
|
|
|
if "dbtemplates" in settings.CACHES:
|
2011-07-01 13:44:09 +00:00
|
|
|
return "dbtemplates"
|
|
|
|
|
else:
|
|
|
|
|
return "default"
|
2020-12-09 08:55:35 +00:00
|
|
|
if isinstance(value, str) and value.startswith("dbtemplates."):
|
2011-07-01 13:50:04 +00:00
|
|
|
raise ImproperlyConfigured("Please upgrade to one of the "
|
|
|
|
|
"supported backends as defined "
|
|
|
|
|
"in the Django docs.")
|
2011-07-01 13:44:09 +00:00
|
|
|
return value
|
|
|
|
|
|
|
|
|
|
def configure_use_reversion(self, value):
|
2011-09-06 10:31:28 +00:00
|
|
|
if value and 'reversion' not in settings.INSTALLED_APPS:
|
2011-07-01 13:44:09 +00:00
|
|
|
raise ImproperlyConfigured("Please add 'reversion' to your "
|
2013-04-04 09:33:00 +00:00
|
|
|
"INSTALLED_APPS setting to make "
|
|
|
|
|
"use of it in dbtemplates.")
|
2011-07-01 13:44:09 +00:00
|
|
|
return value
|
2012-01-18 02:22:22 +00:00
|
|
|
|
2019-06-19 13:41:00 +00:00
|
|
|
def configure_use_reversion_compare(self, value):
|
|
|
|
|
if value and 'reversion_compare' not in settings.INSTALLED_APPS:
|
2022-08-07 22:49:40 +00:00
|
|
|
raise ImproperlyConfigured("Please add 'reversion_compare' to your"
|
|
|
|
|
" INSTALLED_APPS setting to make "
|
2019-06-19 13:41:00 +00:00
|
|
|
"use of it in dbtemplates.")
|
|
|
|
|
return value
|
|
|
|
|
|
2012-01-18 02:22:22 +00:00
|
|
|
def configure_use_tinymce(self, value):
|
|
|
|
|
if value and 'tinymce' not in settings.INSTALLED_APPS:
|
|
|
|
|
raise ImproperlyConfigured("Please add 'tinymce' to your "
|
2013-04-04 09:33:00 +00:00
|
|
|
"INSTALLED_APPS setting to make "
|
|
|
|
|
"use of it in dbtemplates.")
|
2012-01-18 02:22:22 +00:00
|
|
|
return value
|
2012-09-05 18:27:55 +00:00
|
|
|
|
|
|
|
|
def configure_use_redactor(self, value):
|
|
|
|
|
if value and 'redactor' not in settings.INSTALLED_APPS:
|
|
|
|
|
raise ImproperlyConfigured("Please add 'redactor' to your "
|
2015-06-15 18:19:36 +00:00
|
|
|
"INSTALLED_APPS setting to make "
|
|
|
|
|
"use of it in dbtemplates.")
|
2012-09-05 18:27:55 +00:00
|
|
|
return value
|