Commit graph

74 commits

Author SHA1 Message Date
Hasan Ramezani
a53a6facfe
Drop Python 3.8 support (#678) 2024-10-17 18:40:21 +02:00
Cleiton de Lima
4c3ee0b36d
Added remote port (#671) 2024-10-07 15:52:34 +02:00
Hasan Ramezani
8af8011073
Fixed a problem when setting Value(None) in JSONField (#646) 2024-05-27 12:58:58 +03:30
Hasan Ramezani
a652eebfaf
Fixed problem when setting django.db.models.functions.Now() in DateTimeField (#635) 2024-04-29 23:38:09 +02:00
Hasan Ramezani
ceae2f9b4a
Prepare release 3.0.0 (#629) 2024-04-12 11:51:31 +02:00
Hasan Ramezani
7b035943c7
Fixed manuall logging when model is not registered (#627)
* Fixed manuall logging when model is not registered

* Move change log
2024-04-12 10:14:42 +02:00
nathan
a93d9ef665
Fix serialize __proxy__ objects before logging (#624)
* 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>
2024-04-08 12:06:36 +02:00
nathan
a0ae594425
Disable logging remote IP address (#620)
* 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>
2024-03-31 01:37:39 +01:00
Hasan Ramezani
1ce39c0149
Prepare release 3.0.0-beta.4 (#599) 2024-01-03 11:29:07 +03:30
Hasan Ramezani
387b0cec22
Confrim Django 5.0 and drop django 4.1 (#598) 2023-12-29 18:46:54 +03:30
Aleh Rymašeŭski
dbb50e462c
Handle ObjectDoesNotExist in evaluation of repr (#592) 2023-12-11 22:15:34 +03:00
errrken
140719eeb5
Conditionally disable / enable logging (#590)
* 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>
2023-12-07 20:45:41 +03:00
Hasan Ramezani
5072f5d9b1
Prepare release 3.0.0-beta.3 (#587) 2023-11-14 11:02:31 +03:30
hamsh
9e987169da
use contextvar instead of threadlocal (#581)
* 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>
2023-11-06 12:35:34 +03:30
James Gillard
a034588ec7
Confirm Python 3.12 support (#572)
* Confirm Python 3.12 support

* Remove dj4.2/py3.12 from tox.ini
2023-11-02 10:54:28 +03:30
Hasan Ramezani
e15a610dc9
Prepare release 3.0.0-beta.2 (#573) 2023-10-05 13:38:57 +02:00
Abdullah Alaqeel
ccc59e85f1
fix: don't set the correlation_id if the AUDITLOG_CID_GETTER is None (#565) 2023-09-20 13:23:45 +03:00
Aleh Rymašeŭski
ac737fd55c
Stop deleting log entries in log_create (#559) 2023-09-11 16:16:37 +02:00
Abdullah Alaqeel
af31261946
fix: only fire the post_log signal when the log is created or when there is an error (#561) 2023-09-07 14:28:47 +02:00
Abdullah Alaqeel
9f1a09bde7
Prepare for 3.0.0 beta release (#555) 2023-08-29 13:46:48 +02:00
Aleh Rymašeŭski
c52786855b
Allow cascade deletion of auditlog entries (#556)
* Allow cascade deletion of auditlog entries

* Cache iteration over self.urls
2023-08-27 11:12:39 +02:00
Aleh Rymašeŭski
fb1ae7abed
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-08-24 17:25:56 +02:00
Abdullah Alaqeel
134ef73723
feat: give users the option to run the json migration asyncly (#495) 2023-08-13 11:38:21 +02:00
Abdullah Alaqeel
f2591e420b
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
2023-08-09 17:11:21 +02:00
Hasan Ramezani
2c595f174c
Drop support for Python 3.7 (#546) 2023-07-13 23:56:08 +02:00
Hasan Ramezani
9bcc511e21
Fix a bug in serialized_data with F expressions (#544) 2023-07-13 08:53:47 +02:00
Rustam Astafeev
0d9fb8d6fc
fixed getting field's verbose_name (#508)
Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com>
2023-05-18 01:59:11 +03:30
Darren Maki
cd0d3ea311
Audit changes to FK fields when saved using *_id naming. (#525)
* 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.
2023-05-08 18:56:01 +03:30
Hasan Ramezani
fcb6c4ce27
Fix a bug in audit log admin page when USE_TZ=False (#511)
Co-authored-by: Ebrahimi <z.ebrahimi.d80@gmail.com>
2023-02-10 17:52:07 +03:00
Hasan Ramezani
7aec22d38c
Add 2.2.2 changelog (#510) 2023-02-10 13:17:02 +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
Abdullah Alaqeel
f6b9e9f931
Always call set_actor (#484) 2023-01-04 15:05:32 +01:00
Cleiton de Lima
ffa6d34b11
Fix repr of a json field in field changes (#489) 2022-12-30 08:28:55 +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
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
2a93c2086a
Prepare release 2.2.1 (#459) 2022-11-28 13:39:30 +03: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
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
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