-
-
Notifications
You must be signed in to change notification settings - Fork 464
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
Set app label via instantiation of historical records #486
Set app label via instantiation of historical records #486
Conversation
generated history model
generated history model
generated history model
Codecov Report
@@ Coverage Diff @@
## master #486 +/- ##
==========================================
+ Coverage 97.19% 97.22% +0.02%
==========================================
Files 16 16
Lines 713 720 +7
Branches 94 95 +1
==========================================
+ Hits 693 700 +7
Misses 10 10
Partials 10 10
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Want to add this change to CHANGES.rst
and add your name to AUTHORS.rst
and then I'll merge? @uhurusurfa
Also @uhurusurfa what test failed? |
Here is the fail trace extract minus the middle bits that do not help much: `ERROR: test_transaction_rolls_back_if_bulk_history_create_fails (simple_history.tests.tests.test_utils.BulkCreateWithHistoryTransactionTestCase)Traceback (most recent call last): The above exception was the direct cause of the following exception: Traceback (most recent call last): |
@rossmechanic - have etched my name in the anals of simple history and updted the changes file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird that you saw that error locally. Since CI passed, I'm happy to merge. Thanks for this change!
Description
Provide the ability to override the app_label Meta attribute on the generated history model.
This functionality alreay exists using the register method. The mechanism for this feature is identical
to the way it is implemented in the register method by allowing passing an app name in the instantiation.
The code change adds an additional instantiation parameter to the init method for the HistoricalRecords class
and then uses this parameter if provided in the get_meta_data method.
Related Issue
Fixes #485
Motivation and Context
It is often desirable to have the app_label different to the base model so that the history models can be directed to a different database.
This enhances security of the audit trail and can be used in situations where there is a need ot reduce the load on the main application database.
This also provides the same functionality between the "register()" and "HistoricalRecords()" mechanism for initiating audit trails on base models.
How Has This Been Tested?
A unit test was included to test this change. It only affects the setting of a Meta class attribute and does not functionally change the app code.
Screenshots (if appropriate):
Types of changes
Checklist:
make format
command to format my codeNOTE: There is 1 test that failed but failed even without the code change