<commit_before>from __future__ import unicode_literals

# Authentication and Authorisation
from functools import wraps
from . import http

def permit(test_func):
    '''Decorate a handler to control access'''
    def decorator(view_func):
        @wraps(view_func)
        def _wrapped_view(self, *args, **kwargs):
            if test_func(self, *args, **kwargs):
                return view_func(self, *args, **kwargs)
            return http.Forbidden()
        return _wrapped_view
    return decorator

permit_logged_in = permit(
    lambda self, *args, **kwargs: self.request.user.is_authenticated()
)

permit_staff = permit(
    lambda self, *args, **kwargs: self.request.user.is_staff
)


def permit_groups(*groups):
    def in_groups(request, *args):
        return request.user.groups.filter(name__in=args).exists()
    return permit(
        lambda self, *args, **kwargs: in_groups(self.request, *groups)
    )<commit_msg>Fix wrong paramter name in permit_groups decorator<commit_after>from __future__ import unicode_literals

# Authentication and Authorisation
from functools import wraps
from . import http

def permit(test_func):
    '''Decorate a handler to control access'''
    def decorator(view_func):
        @wraps(view_func)
        def _wrapped_view(self, *args, **kwargs):
            if test_func(self, *args, **kwargs):
                return view_func(self, *args, **kwargs)
            return http.Forbidden()
        return _wrapped_view
    return decorator

permit_logged_in = permit(
    lambda self, *args, **kwargs: self.request.user.is_authenticated()
)

permit_staff = permit(
    lambda self, *args, **kwargs: self.request.user.is_staff
)


def permit_groups(*groups):
    def in_groups(request, *args):
        return request.user.groups.filter(name__in=groups).exists()
    return permit(
        lambda self, *args, **kwargs: in_groups(self.request, *groups)
    )
{'fraction_non_alphanumeric': 0.10825013137151865, 'fraction_numerical': 0.0, 'mean_word_length': 3.48, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6556590', 'n_tokens_mistral': 587, 'n_tokens_neox': 577, 'n_words': 150}