Can django-moderation and django-reversion work together for a content_type?
Asked Answered
E

1

6

We are working on a django website in which we want to give users control of the content, but we want to have administrator users to moderate the content, and a queue of the accepted content in case some superuser want to rollback data to a specific version in the past.

I cannot find a django app to make both things. I was reading about django-moderation and django-reversion, and I was wondering if there is a way to make them work together.

I saw that this is a recurrent question, but no one answers it right. The typical answer is use one or another, but no one seems to have a solution for the problem.

I read that the main problem is that in case of having moderation and versions for a content, it may (for sure) create a tree of versions.

But then, I thought that I want only the accepted versions to be stored, then the past versions would generate a lineal history backwards in time, i.e. if I revert something and accept a new thing, then I think it's ok to delete the rejected branch from the point where I reverted when I accept (then store) the new version, leading to a new branch.

Is that possible to do with both django-moderation and django-reversion?

Info about the apps:

[1] https://github.com/etianen/django-reversion/wiki

[2] https://github.com/dominno/django-moderation

Easley answered 25/1, 2012 at 22:11 Comment(0)
B
5

'Yes'.

So I had this same problem, but I also had the problem that django-moderation seems more than a little unmaintained.

I forked django-moderation at https://github.com/CBWhiz/django-moderation and made a bunch of changes to actually get it working under Django 1.4. I'm pretty certain I broke a bit of backwards compatibility though, so i'm not sure if my branch will ever be re-merged.

As for django-reversion, it works well together for my needs. I had to add a hack to django-moderation specificly to support it though: https://github.com/CBWhiz/django-moderation/commit/3b367d68954cea3d7910d8efc5850a136229db0e#L0R49

So, installing django-reversion and my branch of django-moderation works reasonably well together.

The only possible snag might be that the reversion history will add an entry every time you hit save, not when you approve, so it also stores unapproved edits. That could conceivably be hacked around also if you felt up for it.

Betweentimes answered 13/4, 2012 at 3:42 Comment(9)
2 questions: Do you think it would work in django 1.3? and with geodjango?Easley
Should be easy to fix for 1.3. For Geo, however, you might need to back out the changes to using _base_manager since that might break Geo.Betweentimes
Moderation works ok, but I cannot configure reversion, could you give me a clue on how to register the models?Easley
ok I don't know why wasn't working. Now is working. The solution was to import reversion / class CustomAdmin(ModerationAdmin, reversion.VersionAdmin): I think I had them like this class CustomAdmin(ModerationAdmin, reversion.VersionAdmin)Easley
Yep, the order matters due to overload order. Glad I could help.Betweentimes
Trying exactly the same as you. I installed django-reversion and your fork of django-moderation. When registering the same model to both reversion and moderation i get an error: <class 'myapp.models.Foobar'> has already been registered with django-reversion - any idea? (sometimes i get 'module' object is not callable)Polystyrene
Instantiating the admin registers it with django-reversion (this is normal behavior for reversion.VersionAdmin). Are you trying to register it separately?Betweentimes
I am not using it in Admin. This is in my models.py file: reversion.register(Description) moderation.register(Description)Polystyrene
Never mind, i tried it again and it worked. Nevertheless, i found it to be too restrictive. I'll use reversion and an own moderation app that hooks as onetoone relation to the version table.Polystyrene

© 2022 - 2024 — McMap. All rights reserved.