Commit graph

72 commits

Author SHA1 Message Date
Abdullah Alaqeel
b6e5223bf3 chore: add a check arg to the migration command (#563)
* chore: add a check arg to the migration command

* chore: add a check arg to the migration command
2025-10-21 17:20:45 +02:00
Abdullah Alaqeel
4a36378f3c feat: give users the option to run the json migration asyncly (#495) 2025-10-21 17:17:38 +02:00
Abdullah Alaqeel
73800bb34c feat: collect all models including auto created ones and excluding non-managed ones (#550)
feat: automatically register m2m fields for models when opting to auto register models
2025-10-21 11:47:20 +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
Rustam Astafeev
a5f54d09df fixed getting field's verbose_name (#508)
Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com>
2025-10-21 11:46:04 +02:00
Joey Lange
a893859886 Make M2M changes comply with JSONField properly (#514) 2025-10-21 11:30:22 +02:00
Aaron C. de Bruyn
81a6cf2344 Add ability to globally exclude fields by name on all models (#498)
Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com>
2025-10-21 11:26:26 +02:00
Abdullah Alaqeel
1cecc8ca80 Always call set_actor (#484) 2025-10-21 11:23:35 +02:00
Thomas Steen Rasmussen
fb6c363e2c raise AuditLogRegistrationError on invalid app in settings (#492)
Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com>
2025-10-21 11:13:52 +02:00
Cleiton de Lima
4a56697422 Fix repr of a json field in field changes (#489) 2025-10-21 11:11:43 +02:00
Aivars Kalvāns
a41c0f852d Convert AUDITLOG_EXCLUDE_TRACKING_MODELS to tuple before concatenate (#488) 2025-10-21 11:10:49 +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
Abdullah Alaqeel
b8cdfb0dbb Adding Custom Pre- and Post- Log Hooks (#483) 2025-10-21 10:38:15 +02:00
Aleh Rymašeŭski
408a105fe1 Allow cascade deletion of auditlog entries (#556)
* Allow cascade deletion of auditlog entries

* Cache iteration over self.urls
2023-09-01 15:50:51 +00: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
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
c95a0c1405 Merge upstream version 2.2.1 2023-07-13 15:40:32 +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
614f4bc4da Merge another part of upstream 2.2.0 2023-07-13 15:25:04 +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
Abdullah Alaqeel
4cdc756791
FIX: Parsing client IPv6 address when a proxy is involved (#457) 2022-11-22 08:44:59 +01:00
Alieh Rymašeŭski
1ba3bd9d07
Disallow changing or deleting log entries (#449) 2022-11-21 16:26:23 +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
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
Youngkwang Yang
487b8ab5f4
Remove unnecessary code in created method. (#438) 2022-10-05 18:39:48 +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
August Raack
777bd537e7
Add serialized object field (#412) 2022-08-21 21:45:50 +02:00
Hasan Ramezani
18868aaaed Handle port in remote_addr 2022-08-17 13:37:22 +02:00
Alieh Rymašeŭski
a24b79af0c
Display timestamps in server timezone (#404) 2022-08-01 20:41:41 +02:00
Alieh Rymašeŭski
95929cd5b6 Add assertions for msg_short 2022-06-30 09:04:43 +02:00
Alieh Rymašeŭski
7861dae4f9 Show field values before deletion in the admin 2022-06-30 09:04:43 +02:00
Alieh Rymašeŭski
d7dd32af92 Switch MIDDLEWARE from a tuple to a list
This is a recommended change starting with Django 1.9.
2022-06-28 19:20:02 +02:00
Hasan Ramezani
b5edd50f02 Remove double underscores from tests name 2022-06-28 19:19:09 +02:00
Alieh Rymašeŭski
309eef5d2a Allow running tox environments in parallel 2022-06-28 19:08:36 +02:00
Alieh Rymašeŭski
fd35c61fda Silence an expected RuntimeWarning 2022-06-28 19:08:36 +02: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
Hasan Ramezani
be973ca71f
Add pyupgrade to pre-commit-config (#385) 2022-06-15 15:48:08 +02: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
128555fa29
Add date based auditlog filter for auditlogflush command (#365) 2022-05-31 21:35:50 +04:30
Rich Rauenzahn
d9b0d76f3a
[tests] Check cases when reverse related field DoesNotExist. (#252) 2022-05-31 09:32:32 +02:00
Alieh Rymašeŭski
bcd0d43566
Add set_actor context manager (#262) 2022-05-24 09:33:54 +02:00
yeongkwang
32694b1324
Add register model using Django settings (#368)
Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com>
2022-05-23 10:02:22 +02:00
Saurabh Kumar
cdd9f40d84 Disable add button in admin ui
Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com>
2022-05-20 22:13:47 +02:00