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

Make change reason customizable with overriding. #962

Merged
merged 4 commits into from
Mar 22, 2022

Conversation

amartis
Copy link
Member

@amartis amartis commented Mar 19, 2022

Description

Shortcoming of the previous architecture:
Recording the reason for a change was only possible through manually setting to each object or through bulk_history_create.
So recording API request as the reason (of the change) automatically was hard to implement with this architecture.

Solution:
Getting change reason is now done through HistoricalRecords method get_change_reason_for_object.
And thus this method can be overriden in subclass to define custom behavior.

Related Issue

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have run the pre-commit run command to format and lint.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have added my name and/or github handle to AUTHORS.rst
  • I have added my change to CHANGES.rst
  • All new and existing tests passed.

amartis and others added 2 commits March 20, 2022 00:02
Shortcoming of previous architecture:
Recording reason for change was only through manually setting to each object or through bulk_history_create.
So recording API request as reason automatically was hard to implement with this architecture.

Solution:
Getting change reason is now done through `HistoricalRecords` method `get_change_reason_for_object`.
And thus this method can be overriden in subclass to define custom behavior.
@codecov
Copy link

codecov bot commented Mar 19, 2022

Codecov Report

Merging #962 (031ba14) into master (fc9b55e) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #962   +/-   ##
=======================================
  Coverage   97.90%   97.90%           
=======================================
  Files          23       23           
  Lines        1096     1098    +2     
  Branches      213      213           
=======================================
+ Hits         1073     1075    +2     
  Misses         10       10           
  Partials       13       13           
Impacted Files Coverage Δ
simple_history/models.py 98.36% <100.00%> (+<0.01%) ⬆️

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 fc9b55e...031ba14. Read the comment docs.

@amartis
Copy link
Member Author

amartis commented Mar 21, 2022

@jeking3 I made the change in PR #948 onto master branch as you recommended.
Will you review this PR and approve?
FYI, this change is successfully running in a Django project of mine.

Thanks for reviewing previously, btw!

@jeking3 jeking3 merged commit 9a61286 into jazzband:master Mar 22, 2022
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.

2 participants