diff --git a/dbtemplates/admin.py b/dbtemplates/admin.py index 2796dff..4ce3e34 100644 --- a/dbtemplates/admin.py +++ b/dbtemplates/admin.py @@ -10,9 +10,12 @@ from dbtemplates.models import (Template, remove_cached_template, add_template_to_cache) from dbtemplates.utils.template import check_template_syntax -# Check if django-reversion is installed and use reversions' VersionAdmin -# as the base admin class if yes -if settings.DBTEMPLATES_USE_REVERSION: +# Check if either django-reversion-compare or django-reversion is installed and +# use reversion_compare's CompareVersionAdmin or reversion's VersionAdmin as +# the base admin class if yes +if settings.DBTEMPLATES_USE_REVERSION_COMPARE: + from reversion_compare.admin import CompareVersionAdmin as TemplateModelAdmin +elif settings.DBTEMPLATES_USE_REVERSION: from reversion.admin import VersionAdmin as TemplateModelAdmin else: from django.contrib.admin import ModelAdmin as TemplateModelAdmin # noqa diff --git a/dbtemplates/conf.py b/dbtemplates/conf.py index 4abb258..73b123e 100644 --- a/dbtemplates/conf.py +++ b/dbtemplates/conf.py @@ -10,6 +10,7 @@ from appconf import AppConf class DbTemplatesConf(AppConf): USE_CODEMIRROR = False USE_REVERSION = False + USE_REVERSION_COMPARE = False USE_TINYMCE = False USE_REDACTOR = False ADD_DEFAULT_SITE = True @@ -45,6 +46,13 @@ class DbTemplatesConf(AppConf): "use of it in dbtemplates.") return value + def configure_use_reversion_compare(self, value): + if value and 'reversion_compare' not in settings.INSTALLED_APPS: + raise ImproperlyConfigured("Please add 'reversion_compare' 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 " diff --git a/docs/advanced.txt b/docs/advanced.txt index f66dccc..5fb2df1 100644 --- a/docs/advanced.txt +++ b/docs/advanced.txt @@ -61,8 +61,17 @@ Short installation howto 3. Sync your database with ``python manage.py syncdb`` 4. Set ``DBTEMPLATES_USE_REVERSION`` setting to ``True`` +History compare view +-------------------- + +You can also use ``dbtemplates`` together with `django-reversion-compare`_ which +provides a history compare view to compare two versions of a model which is under +reversion. + .. _django-reversion: https://github.com/etianen/django-reversion .. _django-reversion's documentation: https://django-reversion.readthedocs.io/en/latest/ +.. _django-reversion-compare: https://github.com/jedie/django-reversion-compare + .. _commands: diff --git a/docs/settings.txt b/docs/settings.txt index 45b5bbe..e0ad5f8 100644 --- a/docs/settings.txt +++ b/docs/settings.txt @@ -41,6 +41,11 @@ Set to ``False`` by default. A boolean, if enabled triggers the use of ``django-reversion``. +``DBTEMPLATES_USE_REVERSION_COMPARE`` +----------------------------- + +A boolean, if enabled triggers the use of ``django-reversion-compare``. + ``DBTEMPLATES_MEDIA_PREFIX`` ----------------------------