<commit_before># -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
from django.contrib.auth.backends import ModelBackend
import logging

LOG = logging.getLogger(__name__)

class DbaasBackend(ModelBackend):
    
    def has_perm(self, user_obj, perm, obj=None):
        #LOG.debug("validating perm %s for user %s on object %s" % (perm, user_obj, obj))
        # We are using django_services in admin, but it does not provide any support to 
        # object level permission
        if not user_obj.is_active:
            return False
        else:
            return perm in user_obj.get_all_permissions(obj=None)
<commit_msg>overriding get all permissions<commit_after># -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
from django.contrib.auth.backends import ModelBackend
import logging

LOG = logging.getLogger(__name__)

class DbaasBackend(ModelBackend):

    def get_all_permissions(self, user_obj, obj=None):
        if user_obj.is_anonymous() or obj is not None:
            return set()
        if not hasattr(user_obj, '_perm_cache'):
            user_obj._perm_cache = set(["%s.%s" % (p.content_type.app_label, p.codename) for p in user_obj.user_permissions.select_related()])
            user_obj._perm_cache.update(self.get_group_permissions(user_obj))
        return user_obj._perm_cache

    def has_perm(self, user_obj, perm, obj=None):
        #LOG.debug("validating perm %s for user %s on object %s" % (perm, user_obj, obj))
        # We are using django_services in admin, but it does not provide any support to 
        # object level permission
        if not user_obj.is_active:
            return False
        else:
            return perm in user_obj.get_all_permissions(obj=None)

{'fraction_non_alphanumeric': 0.08838526912181303, 'fraction_numerical': 0.0011331444759206798, 'mean_word_length': 3.214797136038186, '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': '207401', 'n_tokens_mistral': 531, 'n_tokens_neox': 529, 'n_words': 155}