Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with fields_exclude and auto_approve #53

Open
tiuma opened this issue Jan 3, 2012 · 0 comments
Open

Problem with fields_exclude and auto_approve #53

tiuma opened this issue Jan 3, 2012 · 0 comments
Labels

Comments

@tiuma
Copy link

tiuma commented Jan 3, 2012

Hi,

There is a bug with fields_exclude (or this function is not clear).
I will explain with an example:

I want to avoid moderation of certain fields of a model. For example...

models.py

class Foo(models.Model):
    foo_a = models.CharField(max_length=80)
    foo_b = models.IntegerField

moderator.py

class FooModerator(GenericModerator):
    auto_approve_for_superusers = True
    auto_approve_for_staff = False
    #Fields to exclude from object change list. Default: []
    fields_exclude = ['foo_b']


moderation.register(Foo, FooModerator)

Then.. i expect that when i change field foo_a the moderation will trigger for that field, not for foo_b.

Tests Results:

Case 1

As a superuser, or a user with auto_approve settings enabled, when i change only a field inside fields_exclude list, i never see the change.
That is if i edit the excluded field (foo_b field), then that field is not changed (it still have the old value). Moderation status = Approved.

Case 2 (this works ok):

As a superuser, when i change other fields and a excluded field, it works fine. That is if i edit both, the excluded field and a regular field (foo_a and foo_b), then all the fields have the expected result.
Moderation status = Approved.

Case 3:

Same as case 1 but as a staff user and the same object instance as in case 1 (try it after case 1): The moderation works as expected, that is if i edit only the excluded field, the change can be seeing. Moderation status = Approved.

Case 4:

Same as case 1 but as a staff user and other object instance: The moderation fails with same results as in case 1. Moderation status = Pending.

Case 5:

Continue case 4. When approved, the excluded field (foo_b) is not changed causing loose of data. But.. the next time that object is edited moderation and excluded fields works again!!

I hope I have explained...
Regards,

Mario.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant