mirror of
https://github.com/jazzband/django-dbtemplates.git
synced 2026-03-16 22:20:28 +00:00
integrate with django-reversion-compare to offer a history compare view in admin
This commit is contained in:
parent
1d53b25cc2
commit
7ea4655b57
4 changed files with 28 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 "
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
||||
|
|
|
|||
|
|
@ -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``
|
||||
----------------------------
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue