* Add test case to test log entry changes_str property for m2m changes.
* Add support for m2m field changes and generic changes in AbstractLogEntry.changes_str property.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Add more test cases for changes_str.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Add chengelog note
* Validate type and length of changes_dict values.
* Restructure change iterator.
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* add new setting to activate string repr
* skip using foreign key to construct and display diff of foreign key fields
* concise name and documentation update
# Conflicts:
# docs/source/usage.rst
* add test for enabled setting
* fix code block in docs
* fix version
* add warning to documentation
* Add failing test for diffing polymorphic model instances.
* Make diffing more robust for polymorphic models:
When working with polymorphic models, where a child model inherits from a
parent model, Django's pre_save signal may send model instances in a way
where the log_update() handler receives an instance of the child as the
`old` model, but an instance of the parent as the `new` model.
This leads to a `FieldDoesNotExist` error when a field that only exists on the
child was modified, and `get_field_value()` attempts look up that field on the
parent.
This change makes diffing polymorphic models more robust by considering this
case in `get_default_value()`. Changes to those child fields won't be tracked
in these cases, but at least `django-auditlog` won't prevent the model from
being saved.
* Add `AUDITLOG_USE_BASE_MANAGER` setting configuration
* Adjust `LogEntry._get_changes_display_for_fk_field` behaviour for setting
* Adjust `log_update` and `log_m2m_changes` in `receivers.py` for setting
* Add `ModelManagerTest.test_use_base_manager_setting`
* Add entry in Usage documentation
* (In passing, fix a formatting issue in `usage.rst`)
The `AUDITLOG_USE_BASE_MANAGER` setting has a default of `False` to maintain
initial backwards compatibility with previous versions.
* 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>
* split auditlog HTML render logic from Admin mixin into reusable functions
* add AuditlogHistoryAdminMixin class
* add test cases for auditlog html render functions
* add audit log history view documentation
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Fix minor
* Add missing versionadded and configuration options for AuditlogHistoryAdminMixin
* Add missing test cases
* Update versionadded to 3.2.2 for AuditlogHistoryAdminMixin
* Update CHANGELOG.md
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Add support for Django 5.2
* Update setup.py
Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com>
* docs: mention Django 5.2 in requirements and changelog
* docs: only keep Django 5.2 support line in changelog improvements
* docs: move and update Django 5.2 changelog entry with PR reference
* Update CHANGELOG.md
---------
Co-authored-by: Hasan Ramezani <hasan.r67@gmail.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>
* 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 IntegrityError when cloning objects with pk=None
* [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>
* Add ability to globally mask fields by name on all models.
Fixes https://github.com/jazzband/django-auditlog/issues/701
* Add feature explanation in `usage.rst` file.
* Add a record to CHANGELOG.md file.
* Add test coverage.
* fix: use sender for m2m signal dispatch connection
This fix adds support for a use case where a single m2m through model is
used on multiple models. When the reciever is used for the dispatch uid
in this use case it cause duplicated logs because the through model
singal connection happens multiple times.
By changing the m2m signal connection to use the sender for the dispatch
uid this duplication is prevented because the signal connection only
happens once for the through model.
Refs: #685
* fix(format): apply black formatting
* add test and changelog entry
* remove unused import
* correct import sorting
* move change log message to correct section
* Add AUDITLOG_TRUNCATE_CHANGES_DISPLAY and AUDITLOG_TRUNCATE_LIMIT
To configure how many characters will be truncated or disable it
* Add AUDITLOG_CHANGE_DISPLAY_TRUNCATE_LENGTH settings
to keep or truncate strings of `changes_display_dict` property at a variable length
* [feat]: Add truncate option to flush command
* [test]: Add test cases for flush command with truncate
* [refactor]: Simplified truncate query class and remove redundant return statement
* [test]: Add test cases to test truncate for unsupported database vendor
* [docs]: Update change log
* 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>
* Disable logging remote IP address
* Update auditlog/middleware.py
* Update CHANGELOG.md
* Update auditlog/middleware.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update auditlog/middleware.py and add tests in ManyRelatedModelTest
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Update receivers.py
* Update signals.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update signals.py
Removed trailing whitespace...
* Update tests.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update CHANGELOG.md
* 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>
* use contextvar instead of threadlocal
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update auditlog/context.py
* 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>