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

Fix LogEntry.changes_dict() to return {} when json.loads() returns None #472

Merged
merged 3 commits into from
Dec 13, 2022
Merged

Fix LogEntry.changes_dict() to return {} when json.loads() returns None #472

merged 3 commits into from
Dec 13, 2022

Conversation

tykling
Copy link
Contributor

@tykling tykling commented Dec 12, 2022

LogEntry.changes_str raises an exception when viewing the new "accessed" AuditLog objects with no changes. This PR fixes LogEntry.changes_dict() so it always returns a dict, even if json.loads() returns None.

This PR fixes #471 which has the backtrace and more details 👍

@hramezani
Copy link
Member

Thanks @tykling for reporting the issue and preparing the fix.

Please consider to:

@codecov
Copy link

codecov bot commented Dec 13, 2022

Codecov Report

Merging #472 (561228e) into master (caf5daa) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #472   +/-   ##
=======================================
  Coverage   92.74%   92.74%           
=======================================
  Files          26       26           
  Lines         786      786           
=======================================
  Hits          729      729           
  Misses         57       57           
Impacted Files Coverage Δ
auditlog/models.py 87.65% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@tykling
Copy link
Contributor Author

tykling commented Dec 13, 2022

done

CHANGELOG.md Outdated Show resolved Hide resolved
Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com>
@hramezani
Copy link
Member

@tykling Thanks for the update. Please add a regression test. I mean you need to add a test that fails without your fix to show what problem you are fixing.

@tykling
Copy link
Contributor Author

tykling commented Dec 13, 2022

I did and it does

@hramezani hramezani merged commit 27f57a5 into jazzband:master Dec 13, 2022
@hramezani
Copy link
Member

Ah Sorry. You are right! Thanks @tykling 👍

ilhan-yrkesdorren pushed a commit to ilhan-yrkesdorren/django-auditlog that referenced this pull request Jan 9, 2023
…ne (jazzband#472)

Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com>
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.

Calling changes_str in a template for an access object results in a backtrace
2 participants