dominno / django-moderation

django-moderation is reusable application for Django framework, that allows to moderate any model objects.
BSD 3-Clause "New" or "Revised" License
269 stars 90 forks source link

bypass for view and form for special user #36

Closed ouhouhsami closed 13 years ago

ouhouhsami commented 13 years ago

Maybe there is a way to achieve this, but I didn't find a solution: User via UserProfile create instance of a Model A, when they save, I'm not able to show to them (and only them) the instance they have just created (because it's not moderated yet), or even, allow them to modify their submission.

For instance : one user create model A instance, I would like him to be able to re-edit is datas, and to have a sort of preview of what he has just done, not getting a 'instance does'nt exist' for my user only. (is that clear ?, may be a decorator could do this for the 'owner' of the instance created ?)

thx

treyhunner commented 13 years ago

Some possible workarounds for this:

You'll probably also want to use BaseModeratedObjectForm to show the original version of the object to the user.

dominno commented 13 years ago

Each manager that is registered with moderation has unmoderated version of this manager under name "unmoderated_MANAGER_NAME", ex. MyModel.unmoderated_objects.all()

So you can do something like this:

if user.is_staff:
    MyModel.unmoderated_objects.all()
else:
    MyModel.objects.all()
ouhouhsami commented 13 years ago

thx dominno and treyhunner for your answers. I think the easiest way for me to deal with my problem is to use unmoderated_objects.