django-auditlog
django-auditlog copied to clipboard
Ignore null changeset on creation and deletion
Problem
I registered a nullable field of a model using include_fields
. There was a a check for null changes
in the log_update
receiver, but not the log_create
and log_delete
ones. This meant that a log entry was created with null
for the changes field whenever a model was created or updated, but didn't have a value for that field.
When the mixin method msg_short
is called in the Audit Log admin index, it would error because it's expecting an object for changes.
What Changed:
- Made the SimpleIncludeModel label field nullable
- Added tests for creation and deletion of a model with a null label field
- Added checks to
log_create
andlog_delete
to make sure entries aren't created if the changes are None.
Codecov Report
Merging #282 (3aaada0) into master (31418d5) will decrease coverage by
0.18%
. The diff coverage is100.00%
.
@@ Coverage Diff @@
## master #282 +/- ##
==========================================
- Coverage 82.20% 82.02% -0.19%
==========================================
Files 18 18
Lines 489 495 +6
==========================================
+ Hits 402 406 +4
- Misses 87 89 +2
Impacted Files | Coverage Δ | |
---|---|---|
auditlog/diff.py | 87.09% <100.00%> (ø) |
|
auditlog/receivers.py | 100.00% <100.00%> (ø) |
|
auditlog/__init__.py | 66.66% <0.00%> (-33.34%) |
:arrow_down: |
auditlog/admin.py | 100.00% <0.00%> (ø) |
|
auditlog/mixins.py | 76.36% <0.00%> (ø) |
|
auditlog/models.py | 82.22% <0.00%> (ø) |
|
auditlog/registry.py | 91.07% <0.00%> (ø) |
|
auditlog/middleware.py | 68.42% <0.00%> (ø) |
|
auditlog/management/commands/auditlogflush.py | 0.00% <0.00%> (ø) |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 31418d5...3aaada0. Read the comment docs.
Thanks @joeyjoejoejr for the patch :+1: Could you please rebase your patch?
@hramezani I think will be solved as a side-effect of #483. We might still need the tests but let's evaluate after we merge #483.