Commit graph

595 commits

Author SHA1 Message Date
Hasan Ramezani
3a90087d32
Add null=True to ci field (#506)
* Add null=True to ci field

* [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>
2023-02-03 16:33:20 +03:00
pre-commit-ci[bot]
565a9bbef5
[pre-commit.ci] pre-commit autoupdate (#504)
updates:
- [github.com/PyCQA/isort: 5.11.4 → 5.12.0](https://github.com/PyCQA/isort/compare/5.11.4...5.12.0)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-01-31 13:17:32 +01:00
Aaron C. de Bruyn
06ae048378
Add ability to globally exclude fields by name on all models (#498)
Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com>
2023-01-20 15:41:36 +01:00
Hasan Ramezani
7a7e2eb2ef
Run django main tests on Python >= 3.10 (#499) 2023-01-19 11:20:45 +03:00
Abdullah Alaqeel
f6b9e9f931
Always call set_actor (#484) 2023-01-04 15:05:32 +01:00
Thomas Steen Rasmussen
b9a86df456
raise AuditLogRegistrationError on invalid app in settings (#492)
Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com>
2023-01-03 16:03:37 +01:00
Cleiton de Lima
ffa6d34b11
Fix repr of a json field in field changes (#489) 2022-12-30 08:28:55 +01:00
Aivars Kalvāns
7f8edd5456
Convert AUDITLOG_EXCLUDE_TRACKING_MODELS to tuple before concatenate (#488) 2022-12-29 09:09:56 +01:00
pre-commit-ci[bot]
dff0dd0fa5
[pre-commit.ci] pre-commit autoupdate (#485)
updates:
- [github.com/PyCQA/isort: v5.11.3 → 5.11.4](https://github.com/PyCQA/isort/compare/v5.11.3...5.11.4)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-12-28 09:52:13 +01:00
August Raack
c649629225
Change diff to evaluate PKs for FK relationships (#420)
* 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
2022-12-28 09:51:44 +01:00
August Raack
2a7fc23b29
Modify `change` field to be a json field. (#407)
* Modify ``change`` field to be a json field.

Storing the object changes as a json is preferred because it allows SQL
queries to access the change values. This work moves the burden of
handling json objects from an implementation of python's json library in
this package and puts it instead onto the ORM. Ultimately, having the
text field store the changes was leaving them less accessible to external
systems and code that is written outside the scope of the django
auditlog.

This change was accomplished by updating the field type on the model and
then removing the JSON dumps invocations on write and JSON loads
invocations on read. Test were updated to assert equality of
dictionaries rather than equality of JSON parsable text.

Separately, it was asserted that postgres will make these changes to
existing data. Therefore, existing postgres installations should update the
type of existing field values without issue.

* Add test coverage for messages exceeding char len

The "Modify change field to be a json field" commit reduced test
coverage on the mixins.py file by 0.03%. The reduction in coverage was
the result of reducing the number of operations required to achieve the
desired state. An additional test was added to increase previously
uncovered code. The net effect is an increase in test case coverage.

* Add line to changelog

Better markdown formatting

Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com>

* Update CHANGELOG text format

More specific language in the improvement section regarding `LogEntry.change`

Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com>

* Update migration to show Django version 4.0

Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com>

* Update CHANGELOG to show breaking change

Running the migration to update the field type of `LogEntry.change` is a breaking change.

Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com>

* Update serial order of migrations

* Adjust manager method for compatibility

The create log method on the LogEntry manager required an additional
kwarg for a call to create an instance regardless of a change or not.
This felt brittle anyway. The reason it had worked prior to these
changes was that the `change` kwarg was sending a string "null" and
not a None when there were no changes.

Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com>
2022-12-28 09:50:35 +01:00
Abdullah Alaqeel
c65c38e539
Adding Custom Pre- and Post- Log Hooks (#483) 2022-12-27 20:14:51 +01:00
Abdullah Alaqeel
bc6d393390
Added support for Correlation ID
Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com>
2022-12-23 15:09:32 +01:00
pre-commit-ci[bot]
63c88829e0
[pre-commit.ci] pre-commit autoupdate (#482)
updates:
- [github.com/PyCQA/isort: 5.10.1 → v5.11.3](https://github.com/PyCQA/isort/compare/5.10.1...v5.11.3)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-12-19 14:52:51 -05:00
Abdullah Alaqeel
a733cd0852
feat: Make timestamp in LogEntry overwritable (#478) 2022-12-19 08:43:29 +01:00
mrampant
971a4f42f8 - fixed unused import 2022-12-16 11:41:27 +03:30
mrampant
8e496aadea - using changes_dict to fix potential TypeError when changes are None in admin list view 2022-12-16 11:41:27 +03:30
ZahraEbrahimi01
703e3e4ba6
Complete translation with gettext_lazy (#474) 2022-12-14 11:31:17 +01:00
Thomas Steen Rasmussen
27f57a53ff
Fix LogEntry.changes_dict() to return {} when json.loads() returns None (#472)
Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com>
2022-12-13 21:35:31 +01:00
pre-commit-ci[bot]
cd1ba3d01b
[pre-commit.ci] pre-commit autoupdate (#473)
updates:
- [github.com/psf/black: 22.10.0 → 22.12.0](https://github.com/psf/black/compare/22.10.0...22.12.0)
- [github.com/asottile/pyupgrade: v3.3.0 → v3.3.1](https://github.com/asottile/pyupgrade/compare/v3.3.0...v3.3.1)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-12-13 09:18:31 +01:00
pre-commit-ci[bot]
caf5daa2f8
[pre-commit.ci] pre-commit autoupdate (#466)
updates:
- [github.com/asottile/pyupgrade: v3.2.2 → v3.3.0](https://github.com/asottile/pyupgrade/compare/v3.2.2...v3.3.0)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-12-06 08:49:35 +01:00
Ihor Sychevskyi
bfaeeab74d
update docs folder link (#465) 2022-12-01 08:22:03 +01:00
pre-commit-ci[bot]
1674acae19
[pre-commit.ci] pre-commit autoupdate (#462)
updates:
- [github.com/PyCQA/flake8: 5.0.4 → 6.0.0](https://github.com/PyCQA/flake8/compare/5.0.4...6.0.0)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-11-28 21:03:19 +01:00
Hasan Ramezani
2a93c2086a
Prepare release 2.2.1 (#459) 2022-11-28 13:39:30 +03:00
Ihor Sychevskyi
b4dda75fc7
update readme link (#460) 2022-11-28 09:05:00 +01:00
Abdullah Alaqeel
4cdc756791
FIX: Parsing client IPv6 address when a proxy is involved (#457) 2022-11-22 08:44:59 +01:00
Hasan Ramezani
e23b091c99
Replace pkg_resources with importlib solution (#450) 2022-11-21 16:50:34 +01:00
Alieh Rymašeŭski
1ba3bd9d07
Disallow changing or deleting log entries (#449) 2022-11-21 16:26:23 +01:00
Youngkwang Yang
96275d5386
Add serialize_data setting (#452) 2022-11-15 13:05:35 +01:00
pre-commit-ci[bot]
a6ea91f1bc
[pre-commit.ci] pre-commit autoupdate (#451)
updates:
- [github.com/asottile/pyupgrade: v3.2.0 → v3.2.2](https://github.com/asottile/pyupgrade/compare/v3.2.0...v3.2.2)
- [github.com/adamchainz/django-upgrade: 1.11.0 → 1.12.0](https://github.com/adamchainz/django-upgrade/compare/1.11.0...1.12.0)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-11-14 22:14:53 +03:30
Hasan Ramezani
227b0d9fb5
Prepare release 2.2.0 (#434) 2022-11-07 14:48:05 +01:00
Hasan Ramezani
2b0bc9efa2
Replace the django.utils.timezone.utc by datetime.timezone.utc (#448)
Co-authored-by: Alieh Rymašeŭski <alieh.rymasheuski@gmail.com>
2022-11-07 14:26:51 +01:00
Hasan Ramezani
36eaaaa2a9
Confirm Python 3.11 support (#447) 2022-11-07 09:36:17 +01:00
Simon Kern
f71699a9d0
Added ACCESS action and enabled logging of object accesses (#436) 2022-11-07 08:51:00 +01:00
Robin Harms Oredsson
8fe776ae45
Option to disable logging on raw save and via context manager (#446)
* Disable on raw save prototype
* Contextmanager to disable instead of just raw - so we can catch m2m relations too
Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com>
2022-11-04 09:12:06 +01:00
Hasan Ramezani
aa6d977f8b Update pyupgrade and django-upgrade pre-commit hooks 2022-11-02 16:01:51 +03:30
pre-commit-ci[bot]
90ce363b78
[pre-commit.ci] pre-commit autoupdate (#442)
updates:
- [github.com/asottile/pyupgrade: v3.0.0 → v3.1.0](https://github.com/asottile/pyupgrade/compare/v3.0.0...v3.1.0)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-10-17 22:18:03 +02:00
pre-commit-ci[bot]
c04f5354ef
[pre-commit.ci] pre-commit autoupdate (#440)
updates:
- [github.com/psf/black: 22.8.0 → 22.10.0](https://github.com/psf/black/compare/22.8.0...22.10.0)
- [github.com/asottile/pyupgrade: v2.38.2 → v3.0.0](https://github.com/asottile/pyupgrade/compare/v2.38.2...v3.0.0)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-10-10 22:08:10 +02:00
Youngkwang Yang
487b8ab5f4
Remove unnecessary code in created method. (#438) 2022-10-05 18:39:48 +02:00
pre-commit-ci[bot]
993cd847fb
[pre-commit.ci] pre-commit autoupdate (#435)
updates:
- [github.com/asottile/pyupgrade: v2.38.0 → v2.38.2](https://github.com/asottile/pyupgrade/compare/v2.38.0...v2.38.2)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-09-26 20:57:48 +02:00
Alieh Rymašeŭski
0f57525058
Support search by custom USERNAME_FIELD (#432) 2022-09-21 16:19:49 +02:00
Rahul Prasad
a56d0e6f78
added fix for OneToOneRel error happening in case of Polymorphic model (#429) 2022-09-21 08:53:10 +02:00
Mathieu Rampant
d74c118834
Added verbose field name in admin (#428)
Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com>
2022-09-20 22:07:41 +02:00
pre-commit-ci[bot]
fb90112c50
[pre-commit.ci] pre-commit autoupdate (#430)
updates:
- [github.com/asottile/pyupgrade: v2.37.3 → v2.38.0](https://github.com/asottile/pyupgrade/compare/v2.37.3...v2.38.0)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-09-19 21:47:54 +02:00
pre-commit-ci[bot]
acada9edf9
[pre-commit.ci] pre-commit autoupdate (#425)
updates:
- [github.com/adamchainz/django-upgrade: 1.9.0 → 1.10.0](https://github.com/adamchainz/django-upgrade/compare/1.9.0...1.10.0)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-09-12 20:34:11 +02:00
pre-commit-ci[bot]
93602bd210
[pre-commit.ci] pre-commit autoupdate (#423)
updates:
- [github.com/psf/black: 22.6.0 → 22.8.0](https://github.com/psf/black/compare/22.6.0...22.8.0)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-09-05 20:31:07 +02:00
pre-commit-ci[bot]
527f870034
[pre-commit.ci] pre-commit autoupdate (#422)
updates:
- [github.com/adamchainz/django-upgrade: 1.8.0 → 1.9.0](https://github.com/adamchainz/django-upgrade/compare/1.8.0...1.9.0)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-08-29 20:26:04 +02:00
August Raack
777bd537e7
Add serialized object field (#412) 2022-08-21 21:45:50 +02:00
Hasan Ramezani
57423fcb3a
Add required Python and Django version to setup.py (#419) 2022-08-18 13:06:33 +02:00
François Magimel
174605d650
docs(readme): update the release section (#351)
Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com>
2022-08-17 18:51:14 +02:00