<commit_before>from django.conf import settings
from django.utils.deprecation import MiddlewareMixin

from server.models import *


class AddToBU(MiddlewareMixin):
    """
    This middleware will add the current user to any BU's they've not already
    been explicitly added to.
    """

    def process_view(self, request, view_func, view_args, view_kwargs):
        if hasattr(settings, 'ADD_TO_ALL_BUSINESS_UNITS'):
            if request.user.is_authenticated():
                if settings.ADD_TO_ALL_BUSINESS_UNITS \
                        and request.user.userprofile.level != 'GA':
                    for business_unit in BusinessUnit.objects.all():
                        if request.user not in business_unit.users.all():
                            business_unit.users.add(request.user)
                            business_unit.save()

        return None<commit_msg>Make `is_authenticated` a property access rather than a function call.<commit_after>from django.conf import settings
from django.utils.deprecation import MiddlewareMixin

from server.models import *


class AddToBU(MiddlewareMixin):
    """
    This middleware will add the current user to any BU's they've not already
    been explicitly added to.
    """

    def process_view(self, request, view_func, view_args, view_kwargs):
        if hasattr(settings, 'ADD_TO_ALL_BUSINESS_UNITS'):
            if request.user.is_authenticated:
                if settings.ADD_TO_ALL_BUSINESS_UNITS \
                        and request.user.userprofile.level != 'GA':
                    for business_unit in BusinessUnit.objects.all():
                        if request.user not in business_unit.users.all():
                            business_unit.users.add(request.user)
                            business_unit.save()

        return None
{'fraction_non_alphanumeric': 0.07421660252886202, 'fraction_numerical': 0.0, 'mean_word_length': 2.2212389380530975, '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': '6247295', 'n_tokens_mistral': 488, 'n_tokens_neox': 464, 'n_words': 126}