Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add `reversion_compare` compatabilbty. #605

Closed
wants to merge 2 commits into from

2 participants

@pahaz

No description provided.

@stephenmcd
Owner

I'm not sure if we want to start including a bunch of code in Mezzanine particularly to support reversion. I've started a discussion for this on the mailing list:

https://groups.google.com/group/mezzanine-users/browse_thread/thread/158fdc019dfa30d7

@stephenmcd
Owner

We've actually removed the USE_REVERSION setting in the latest version. There were several areas where it still didn't function correctly.

Your contributions started working towards correcting some of these (thank you), but it's clear that we would have needed to add more and more code into Mezzanine itself for this to be a complete solution, which I think is the wrong approach.

What we should be able to do is get it to work by simply unregistering admin classes and registering custom classes from within your own project (that include reversion compatibility). Perhaps this would make for a good separate app called mezzanine-reversion, which includes everything needed to get this to work. Would you be interested in working on something like that?

I'm going to close these pull requests for now. Thanks again.

@stephenmcd stephenmcd closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 20, 2013
  1. @pahaz
Commits on Mar 21, 2013
  1. @pahaz

    fix import

    pahaz authored
This page is out of date. Refresh to see the latest.
Showing with 30 additions and 4 deletions.
  1. +30 −4 mezzanine/core/admin.py
View
34 mezzanine/core/admin.py
@@ -10,7 +10,8 @@
from mezzanine.conf import settings
from mezzanine.core.forms import DynamicInlineAdminForm
from mezzanine.core.models import (Orderable, SitePermission,
- CONTENT_STATUS_PUBLISHED)
+ CONTENT_STATUS_PUBLISHED,
+ CONTENT_STATUS_CHOICES)
from mezzanine.utils.urls import admin_url
from mezzanine.utils.models import get_user_model
@@ -55,10 +56,35 @@ class BaseDisplayableAdmin(admin.ModelAdmin):
if "reversion" in settings.INSTALLED_APPS and settings.USE_REVERSION:
- from reversion import VersionAdmin
-
- class DisplayableAdmin(BaseDisplayableAdmin, VersionAdmin):
+ if "reversion_compare" in settings.INSTALLED_APPS:
+ from reversion_compare.admin import CompareVersionAdmin as VersionAdmin
+ else:
+ from reversion import VersionAdmin
+
+ class VersionMixedAdmin(VersionAdmin):
+ compare_exclude = ('keywords', 'site', 'parent', 'comments', 'rating')
+
+ def compare_site(self, obj_compare):
+ """ compare the foo_bar model field """
+ if obj_compare.value1 != obj_compare.value2:
+ from django.contrib.sites.models import Site
+ from_site = Site.objects.get(id=obj_compare.value1)
+ to_site = Site.objects.get(id=obj_compare.value2)
+ return "Change site id: {0} -> {1}".format(from_site, to_site)
+ return None
+
+ def compare_status(self, obj_compare):
+ """ compare the foo_bar model field """
+ if obj_compare.value1 != obj_compare.value2:
+ choice = dict(CONTENT_STATUS_CHOICES)
+ _from = unicode(choice.get(obj_compare.value1))
+ _to = unicode(choice.get(obj_compare.value2))
+ return u"{0} -> {1}".format(_from, _to)
+ return None
+
+ class DisplayableAdmin(BaseDisplayableAdmin, VersionMixedAdmin):
pass
+
else:
class DisplayableAdmin(BaseDisplayableAdmin):
pass
Something went wrong with that request. Please try again.