server-tools
server-tools copied to clipboard
[IMP] auditlog/models/rule.py: Add condition to skip logging if no fields changed in write method
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.
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:
- Go to "Rules"
- Add the active field of the model to "fields_to_exclude_ids"
- "Subscribe" the rule
- Archive a record of the model of the rule
- A log without any entry at updated fields is created