Ejemplo n.º 1
0
    def dispatch(self, request, *args, **kwargs):
        feature_set = _setify(self.pydici_feature)

        if not user_has_features(request.user, feature_set):
            resolved_login_url = resolve_url(settings.LOGIN_URL)
            path = request.get_full_path()
            return redirect_to_login(path, resolved_login_url, REDIRECT_FIELD_NAME)
        return super(PydiciFeatureMixin, self).dispatch(request, *args, **kwargs)
Ejemplo n.º 2
0
    def dispatch(self, request, *args, **kwargs):
        feature_set = _setify(self.pydici_feature)

        if not user_has_features(request.user, feature_set):
            resolved_login_url = resolve_url(settings.LOGIN_URL)
            path = request.get_full_path()
            return redirect_to_login(path, resolved_login_url, REDIRECT_FIELD_NAME)
        return super(PydiciFeatureMixin, self).dispatch(request, *args, **kwargs)
Ejemplo n.º 3
0
def pydici_feature(features, login_url=None):
    """
    Decorator for views which require users to have access to `feature`.

    `features` can be either a string, a tuple of strings or a set of strings.
    If it is a tuple or a set then the user must have access to all features.
    """
    feature_set = _setify(features)
    return user_passes_test(lambda u: user_has_features(u, feature_set), login_url=login_url)
Ejemplo n.º 4
0
def pydici_feature(features, login_url=None):
    """
    Decorator for views which require users to have access to `feature`.

    `features` can be either a string, a tuple of strings or a set of strings.
    If it is a tuple or a set then the user must have access to all features.
    """
    feature_set = _setify(features)
    return user_passes_test(lambda u: user_has_features(u, feature_set), login_url=login_url)