-
-
Notifications
You must be signed in to change notification settings - Fork 472
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 history_user automatically using middleware #108
Conversation
@@ -221,6 +224,19 @@ def create_historical_record(self, instance, type): | |||
manager.create(history_date=history_date, history_type=type, | |||
history_user=history_user, **attrs) | |||
|
|||
def get_history_user(self, instance): | |||
"""Use hints from the instance and middleware to identify the |
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.
Minor nitpick: I prefer to follow PEP 257 for one line docstrings.
Can we only enable the middleware during relevant tests? Maybe |
This will pass once 1.3 is removed from the matrix in #103. |
This looks great for me. 👍 for merging. |
It is a good solution. Thanks for your efforts! |
Set history_user automatically using middleware
This adds an optional feature to populate
history_user
on historical models using middleware to retrieve the request object.@treyhunner, @mauricioabreu I think this should be an acceptable implimentation of feature request #25. It probably could use a few tests around the new
get_history_user
method, and the documentation could be clearer.