Add generic view mixins for Local Site, Profile, and Login Required checks.
Review Request #8999 — Created June 6, 2017 and submitted — Latest diff uploaded
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.