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

[IMP] auditlog/models/rule.py: Add condition to skip logging if no fields changed in write method #2692

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from

Conversation

chupaSV
Copy link

@chupaSV chupaSV commented Aug 1, 2023

Add a condition to check if any fields have changed before creating a log entry for the "write" method. This improves performance and reduces unnecessary log entries.

…elds changed in write method

Add condition to check if any fields have changed before creating a log entry for the "write" method. This improves performance and reduces unnecessary log entries.
@ChristophAbenthungCibex

Great functionality.
However, when the only changed field is a field of the list fields_to_exclude a log entry is still created but without any entry at the updated fields table. I see no problem to prevent log creation if those fields are changed.
I changed the line changed_fields = diff.changed() - set(FIELDS_BLACKLIST) to changed_fields = diff.changed() - set(FIELDS_BLACKLIST) - set(fields_to_exclude) and it works fine.

Steps to reproduce:

  1. Go to "Rules"
  2. Add the active field of the model to "fields_to_exclude_ids"
  3. "Subscribe" the rule
  4. Archive a record of the model of the rule
  5. A log without any entry at updated fields is created

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

Successfully merging this pull request may close these issues.

3 participants