-
Notifications
You must be signed in to change notification settings - Fork 217
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
TBD: access mixins: support for custom exceptions #145
Conversation
I would appreciate some feedback on this. E.g. is |
This definitely needs docs. I'm not sure why you deleted the AnonymousUser test, though? That should still pass based on the changes to We also definitely want to make sure the response is a valid As for the naming of |
Yep, that removed test does pass. All tests pass for me after merging in master. I'd like to get a new release out tomorrow or at the latest early next week. If you can get this together with docs it'll make it into the 1.5 release. Otherwise I'll push it back to 1.6. |
@chrisjones-brack3t |
If you mean I'll leave |
- Add `handle_no_permission`. - Move `no_permissions_fail` and `redirect_unauthenticated_users` to base AccessMixin.
The `redirect_unauthenticated_users` attribute has moved to the base class. Also add explicit tests for `redirect_unauthenticated_users=False`.
e294f01
to
5c272ea
Compare
I've rebased the branch and updated the documentation: only the .rst for now, I am not sure about the class documentation - should this get added to the base class, or to all mixins, like it's currently done, or just both? I've also changed it to pass the |
@kennethlove |
Thanks for merging! However, it is missing docs probably and some questions are unanswered. |
I wanted to use a custom exception with
SuperuserRequiredMixin
(Http404
) and added support for it.raise_exception
can now beTrue
,False
, a custom exception or a callable (that should return a response).I have then factored the no-permission handling into a separate function, and moved
redirect_unauthenticated_users
to the base mixin.This does not include any documentation changes yet, because I wanted to gather feedback on it first.
E.g., I am not sure if
handle_no_permission
should fall back to raising an exception for any non-HTTP-response (not isinstance(ret, (HttpResponse, StreamingHttpResponse))
).