* Drop Python 3.9 support, set minimum version to 3.10
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update CHANGELOG.md
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Fix lint error
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Add test cases for the `mask_str` function
* Add custom masking function support through mask_callable
* Add test cases for custom masking function
* Update documentation for custom masking function
* fix test case
* rename `AUDITLOG_DEFAULT_MASK_CALLABLE` variable
-AUDITLOG_DEFAULT_MASK_CALLABLE to `AUDITLOG_MASK_CALLABLE`
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update `CHANGELOG.md` to include mask function customization feature
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* 'get_field_value' - improve default value handling
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Add Test cases
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Branch that implements issue #675, basically, storing the correct JSON type that corresponds to the Python type (None -> null, 1 -> 1', not "1"`).
It's driven by a setting, AUDITLOG_ STORE_JSON_CHANGES , as recommended by @hramezani
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* code formatting tweaks from @hramezani
* increasing test coverage
* added usage for AUDITLOG_STORE_JSON_CHANGES setting
* updated CHANGELOG with info on AUDITLOG_STORE_JSON_CHANGES field
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* added another test for wrong setting type
* should not have committed temporary test changes
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Fix serialize __proxy__ objects before logging
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update CHANGELOG.md
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com>
* Audit changes to FK fields when saved using *_id naming.
In Django you can save changes to a FK field on a model using the ID
field name (attname) in addition to the regular FK field name with:
model.related_model_id = 42
model.save(update_fields=["related_model_id'])
or:
model.related_model = related_model
model.save(update_fields=["related_model_id'])
as opposed to the more common:
model.related_model = related_model
model.save(update_fields=["related_model'])
This change ensures those model changes are logged properly.
* Apply suggested change from code review.
* Add a CHANGELOG entry for the fix.
* Change diff to evaluate PKs for FK relationships
The diff method now evaluates the primary keys for changes to determine
if a new LogEntry should be created. Previously, the diff method was
evaluating the string representation of the object. This was flawed
because cases can occur when a parent object has in memory changes to
its string string representation and the child related object is saved
prior to these in memory changes being persisted. In these cases a new
LogEntry object would be created erroneously. This cases is asserted
with a test and a regression test will verify the bug.
The consequence of these updates is that the ``LogEntry.changes`` field
now stores primary keys rather than string representations for related
objects. To keep the changes dictionary display unaffected by this
update, a method was added to the ``LogEntry`` model. This method looks
up the object display string from the stored foreign key. Exceptions
were written to handle backwards compatibility.
* Added test case to cover another bug
Because the string representation is not unique for every object, relying
on it to determine FK diffs may not capture all changes. This test case
shows another type of scenario that is fixed by comparing primary keys
rather than object string representations. This is likely occurring
fairly regularly but is hard to spot because it is an error of omission.
* Update to docstring and added changelog