Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore null changeset on creation and deletion #282

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

joeyjoejoejr
Copy link

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 and log_delete to make sure entries aren't created if the changes are None.

@codecov
Copy link

codecov bot commented Nov 10, 2020

Codecov Report

Merging #282 (3aaada0) into master (31418d5) will decrease coverage by 0.18%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            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%) ⬇️
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.

@hramezani
Copy link
Member

Thanks @joeyjoejoejr for the patch 👍
Could you please rebase your patch?

@demmojo demmojo linked an issue Jul 29, 2022 that may be closed by this pull request
@aqeelat
Copy link
Member

aqeelat commented Dec 22, 2022

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants