from functools import wraps

from django.http import HttpResponseForbidden

from license_info.tools import check_features


def license_feature_required(features):
    """Check that license has list of required features
    @param features: List of strings with features names"""

    def actual_decorator(view):
        @wraps(view)
        def wrapper(request, *args, **kwargs):
            if not check_features(features):
                return HttpResponseForbidden()

            return view(request, *args, **kwargs)

        return wrapper

    return actual_decorator
