Commit graph

54 commits

Author SHA1 Message Date
Abdullah Alaqeel
4a36378f3c feat: give users the option to run the json migration asyncly (#495) 2025-10-21 17:17:38 +02:00
Hasan Ramezani
78dc7a5012 Fix a bug in serialized_data with F expressions (#544) 2025-10-21 11:46:50 +02:00
Fırat Kılıç
188337b465 Fix unnecessary log when adding already existed m2m record (#535) 2025-10-21 11:46:44 +02:00
Joey Lange
a893859886 Make M2M changes comply with JSONField properly (#514) 2025-10-21 11:30:22 +02:00
August Raack
2bd6c1a3e8 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>
2025-10-21 11:04:47 +02:00
Aleh Rymašeŭski
ab65364bb4 Set history delete_related to False by default (#557)
This is a breaking change. The default behavior is to delete the
related objects, but it doesn't make sense to apply it to audit log
entries, at least not by default.
2023-09-01 15:50:08 +00:00
Aleh Rymašeŭski
47188b46d7 Stop deleting log entries in log_create 2023-09-01 15:48:59 +00:00
Aleh Rymašeŭski
682e8e270b Add null=True to LogEntry.cid field
It's already set nullable in the migration.
2023-07-19 10:15:27 +00:00
Aleh Rymašeŭski
addaaa7d68 Merge cid from upstream 2023-07-13 15:56:59 +00:00
Aleh Rymašeŭski
117696842b Merge overwritable timestamp from upstream 2023-07-13 15:53:37 +00:00
Aleh Rymašeŭski
c422dd1f0d Merge upstream version 2.2.0 2023-07-13 15:38:15 +00:00
Aleh Rymašeŭski
29d92e7eba Merge "serialized_data" feature 2023-07-13 14:58:50 +00: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
Abdullah Alaqeel
a733cd0852
feat: Make timestamp in LogEntry overwritable (#478) 2022-12-19 08:43:29 +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
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
Simon Kern
f71699a9d0
Added ACCESS action and enabled logging of object accesses (#436) 2022-11-07 08:51:00 +01:00
August Raack
777bd537e7
Add serialized object field (#412) 2022-08-21 21:45:50 +02:00
Alieh Rymašeŭski
03fb52ac3e Merge upstream master 2022-06-28 18:19:37 +00:00
Alieh Rymašeŭski
2ac014baa5 Remove a redundant exception handler
It duplicates the handler for its parent class Exception.
2022-06-28 19:20:02 +02:00
Alieh Rymašeŭski
68c7f44f9c Make checks for empty collections more pythonic 2022-06-28 19:20:02 +02:00
Hasan Ramezani
7771075dc0 Remove South compatibility codes 2022-06-28 19:19:09 +02:00
Alieh Rymašeŭski
204a2910fe Merge upstream master 2022-06-27 18:16:16 +00:00
Viktor
d928ff7f77 Return default value None if attribute choices doesn't exist
Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com>
2022-06-27 09:08:19 +02:00
Hasan Ramezani
11dceb81b8
Add flake8 to pre-commit config (#387) 2022-06-18 20:50:25 +04:30
Alieh Rymašeŭski
f3654f14b7 Merge commit '10c47181bb38ba49b0cb5927f5dab3fe4f8842e4' 2022-06-13 17:36:40 +03:00
Alieh Rymašeŭski
23b80f96b5 Merge commit '1e7d320a93efda3f470641e9abefcb0e0733cd7a' 2022-06-13 14:29:07 +03:00
Alieh Rymašeŭski
10c47181bb
Add logic to track changes to m2m fields (#309) 2022-06-08 17:09:27 +02:00
George Leslie-Waksman
1e7d320a93
Add an index to the timestamp column (#364)
Many queries, including the default ordering, for the LogEntry
model rely on the timestamp field. Adding an index will ensure
reasonable scalability for large audit logs.
2022-05-31 09:01:13 +02:00
Alieh Rymašeŭski
047fca9165 Merge upstream master 2022-05-20 12:58:34 +03:00
Hasan Ramezani
de0625b378 Drop Django 2.2 support. 2022-05-01 13:48:26 +02:00
Samuel Gonçalves
77ef852706
enable use of replica database (#359)
* enable use of replica database

When you use replica database the django-auditlog try to write in the same database where object was read (replica). But this is a read only database and crash the application.

This changes saves always in the default database.

If you want to save in multiple databases or in a special one use `DATABASE_ROUTERS` to configure it.

Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com>
2022-03-07 14:22:08 +01:00
Hasan Ramezani
86a323d2e6 Update syntax to Python 3.7+ 2022-02-24 17:43:28 +03:00
François Magimel
1b88f8c11c build: replace django-jsonfield with django-jsonfield-backport (#339)
The `django-jsonfield` module is not maintained anymore and raises some
errors with Django 4.0. So, as a recommendation in this package, and as
Django 2.2 is still maintained, `django-jsonfield-backport` will do the
job for the `JSONField` field.

Ref #43
Ref #334
2022-02-24 17:43:28 +03:00
Andreas Hasenkopf
ae60832717 Add a DB index to LogEntry's action field (#236)
For some applications the possibility to filter by the `action` field might be really interesting. However the lack of an index can lead to severe reduction of such queries.

The simplest solution: Let's a DB index on that field :)
2022-02-24 17:43:28 +03:00
Hasan Ramezani
f003f3332a Update syntax to Python 3.7+ 2022-01-10 10:18:20 +01:00
François Magimel
2e9668dc05
build: replace django-jsonfield with django-jsonfield-backport (#339)
The `django-jsonfield` module is not maintained anymore and raises some
errors with Django 4.0. So, as a recommendation in this package, and as
Django 2.2 is still maintained, `django-jsonfield-backport` will do the
job for the `JSONField` field.

Ref #43
Ref #334
2022-01-07 22:14:36 +01:00
Basti
05c280575f replace ugettext with gettext for django4 2022-01-07 08:36:23 +01:00
Andreas Hasenkopf
938431389f
Add a DB index to LogEntry's action field (#236)
For some applications the possibility to filter by the `action` field might be really interesting. However the lack of an index can lead to severe reduction of such queries.

The simplest solution: Let's a DB index on that field :)
2022-01-04 10:06:45 +01:00
Alieh Rymašeŭski
48adbc5a1e Add logic to track m2m relationships 2021-06-28 16:47:45 +03:00
Alieh Rymašeŭski
d7a73e5cbf Merge changes from upstream 2021-06-24 15:19:21 +03:00
Alieh Rymašeŭski
4232d685bd Apply isort to the code base 2021-06-24 14:33:30 +03:00
Alieh Rymašeŭski
7801239387 Blacken the code 2021-06-24 13:04:48 +03:00
Hasan Ramezani
497c83fc83 Add isort and sort orders with isort. 2020-12-06 23:10:18 +01:00
Hasan Ramezani
f5bb5cb1a2 Add black and format files with black. 2020-12-06 23:10:18 +01:00
Alieh Rymašeŭski
0ca00faafc Simplify field.base_field.choices check 2020-11-12 16:21:31 +03:00
Alieh Rymašeŭski
536a841bf3 Remove Python 2 cruft 2020-11-12 16:15:32 +03:00
Alieh Rymašeŭski
47a268eef9 Clean up project structure
Cherry-picking ee8a700b1b
2020-11-12 16:15:05 +03:00
Jan-Jelle Kester
2010b49d06 Fix Django 3.0 field choices diff 2020-09-07 16:52:32 +02:00
Jan-Jelle Kester
3acab4322b Drop Python 2, support Django 3.0, update dependencies 2020-09-07 16:52:32 +02:00