You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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
moderator.py
Then.. i expect that when i change field
foo_a
the moderation will trigger for that field, not forfoo_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
andfoo_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.
The text was updated successfully, but these errors were encountered: