mirror of
https://github.com/jazzband/django-auditlog.git
synced 2026-03-16 22:20:26 +00:00
Fixed manuall logging when model is not registered (#627)
* Fixed manuall logging when model is not registered * Move change log
This commit is contained in:
parent
f1f9020347
commit
c2e3ad3f16
3 changed files with 26 additions and 1 deletions
|
|
@ -1,11 +1,18 @@
|
||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
## Next Release
|
## Next Release
|
||||||
|
#### Fixes
|
||||||
|
|
||||||
|
- Fixed manuall logging when model is not registered ([#627](https://github.com/jazzband/django-auditlog/pull/627))
|
||||||
|
|
||||||
|
#### Improvements
|
||||||
|
- feat: Excluding ip address when `AUDITLOG_DISABLE_REMOTE_ADDR` is set to True ([#620](https://github.com/jazzband/django-auditlog/pull/620))
|
||||||
|
|
||||||
|
|
||||||
## 3.0.0-beta.4 (2024-01-02)
|
## 3.0.0-beta.4 (2024-01-02)
|
||||||
|
|
||||||
#### Improvements
|
#### Improvements
|
||||||
- feat: Excluding ip address when `AUDITLOG_DISABLE_REMOTE_ADDR` is set to True ([#620](https://github.com/jazzband/django-auditlog/pull/620))
|
|
||||||
- feat: If any receiver returns False, no logging will be made. This can be useful if logging should be conditionally enabled / disabled ([#590](https://github.com/jazzband/django-auditlog/pull/590))
|
- feat: If any receiver returns False, no logging will be made. This can be useful if logging should be conditionally enabled / disabled ([#590](https://github.com/jazzband/django-auditlog/pull/590))
|
||||||
- Django: Confirm Django 5.0 support ([#598](https://github.com/jazzband/django-auditlog/pull/598))
|
- Django: Confirm Django 5.0 support ([#598](https://github.com/jazzband/django-auditlog/pull/598))
|
||||||
- Django: Drop Django 4.1 support ([#598](https://github.com/jazzband/django-auditlog/pull/598))
|
- Django: Drop Django 4.1 support ([#598](https://github.com/jazzband/django-auditlog/pull/598))
|
||||||
|
|
|
||||||
|
|
@ -210,6 +210,9 @@ class LogEntryManager(models.Manager):
|
||||||
def _get_serialized_data_or_none(self, instance):
|
def _get_serialized_data_or_none(self, instance):
|
||||||
from auditlog.registry import auditlog
|
from auditlog.registry import auditlog
|
||||||
|
|
||||||
|
if not auditlog.contains(instance.__class__):
|
||||||
|
return None
|
||||||
|
|
||||||
opts = auditlog.get_serialize_options(instance.__class__)
|
opts = auditlog.get_serialize_options(instance.__class__)
|
||||||
if not opts["serialize_data"]:
|
if not opts["serialize_data"]:
|
||||||
return None
|
return None
|
||||||
|
|
|
||||||
|
|
@ -1102,6 +1102,21 @@ class UnregisterTest(TestCase):
|
||||||
# Check for log entries
|
# Check for log entries
|
||||||
self.assertEqual(LogEntry.objects.count(), 0, msg="There are no log entries")
|
self.assertEqual(LogEntry.objects.count(), 0, msg="There are no log entries")
|
||||||
|
|
||||||
|
def test_manual_logging(self):
|
||||||
|
obj = self.obj
|
||||||
|
obj.boolean = True
|
||||||
|
obj.save()
|
||||||
|
LogEntry.objects.log_create(
|
||||||
|
instance=obj,
|
||||||
|
action=LogEntry.Action.UPDATE,
|
||||||
|
changes="",
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
obj.history.filter(action=LogEntry.Action.UPDATE).count(),
|
||||||
|
1,
|
||||||
|
msg="There is one log entry for 'UPDATE'",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class RegisterModelSettingsTest(TestCase):
|
class RegisterModelSettingsTest(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue