Add generic view mixins for Local Site, Profile, and Login Required checks.
Review Request #8999 — Created June 6, 2017 and submitted
We have decorators that check if a user has access to a Local Site and
to check if a user must be authenticated to access a particular view
(based on siteconfig settings). When working with generic views, it's a
bit annoying to use those, as it requires creating adispatch()
method
and usingmethod_decorator()
with each of the decorators.This change introduces four new mixins that apply these decorators to the
view, simplifying the view's responsibilities:
CheckLocalSiteAccessViewMixin
is a convenience around the
@check_local_site
decoratorUserProfileRequiredViewMixin
is a convenience around the
@valid_prefs_required
decorator, andCheckLoginRequiredViewMixin
is a convenience around the
@check_login_required
decorator.LoginRequiredViewMixin
is a convenience around the
@login_required
decorator.
These will be used in some view conversion work that's being done
separately.
Tested these in the view work I'm doing.
Unit tests pass.
Change Summary:
Added a decorator to wrap
@valid_prefs_required
.
Summary: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Commit: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Diff: |
Revision 2 (+344 -3) |
Checks run (2 succeeded)
Change Summary:
- Added module docstrings.
- Added the mixin modules to the coderef docs.
- Added a mixin for
@login_required
. - Fixed the naming of some unit tests. They were backwards.
- Other misc docstring tweaks.
Description: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Commit: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Diff: |
Revision 3 (+413 -3) |
Checks run (2 succeeded)
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 4 (+415 -3) |