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:
CheckLocalSiteAccessViewMixinis a convenience around the
@check_local_sitedecoratorUserProfileRequiredViewMixinis a convenience around the
@valid_prefs_requireddecorator, andCheckLoginRequiredViewMixinis a convenience around the
@check_login_requireddecorator.LoginRequiredViewMixinis a convenience around the
@login_requireddecorator.
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:
-
Add generic view mixins for Local Site and Login Required checks.Add generic view mixins for Local Site, Profile, and Login Required checks.
- Description:
-
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 a dispatch()methodand using method_decorator()with each of the decorators.~ This change introduces two new mixins that apply these decorators to the
~ This change introduces three new mixins that apply these decorators to the
view, simplifying the view's responsibilities. CheckLocalSiteAccessViewMixinis a convenience around the~ @check_local_sitedecorator, andCheckLoginRequiredViewMixinis a~ convenience around the @check_login_requireddecorator.~ @check_local_sitedecorator,UserProfileRequiredViewMixinis a~ convenience around the @valid_prefs_requireddecorator, and+ CheckLoginRequiredViewMixinis a convenience convenience around the+ @check_login_requireddecorator.These will be used in some view conversion work that's being done
separately. - Commit:
-
2f4923e661db5fb0b4c2c25bf6ec81bd635d0b98ad36e3ebe55bfb6bd10b289cf5a869f20603a313
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:
-
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 a dispatch()methodand using method_decorator()with each of the decorators.~ This change introduces three new mixins that apply these decorators to the
~ view, simplifying the view's responsibilities. ~ CheckLocalSiteAccessViewMixinis a convenience around the~ @check_local_sitedecorator,UserProfileRequiredViewMixinis a~ convenience around the @valid_prefs_requireddecorator, and~ CheckLoginRequiredViewMixinis a convenience convenience around the~ @check_login_requireddecorator.~ This change introduces four new mixins that apply these decorators to the
~ view, simplifying the view's responsibilities: ~ ~ CheckLocalSiteAccessViewMixinis a convenience around the
@check_local_sitedecorator
~ UserProfileRequiredViewMixinis a convenience around the
@valid_prefs_requireddecorator, and
~ CheckLoginRequiredViewMixinis a convenience around the
@check_login_requireddecorator.
~ LoginRequiredViewMixinis a convenience around the
@login_requireddecorator.
These will be used in some view conversion work that's being done
separately. - Commit:
-
ad36e3ebe55bfb6bd10b289cf5a869f20603a31309ccc3fe74b427e1c6f80cdf4c4e9ed9e9a1783f