'Helper for User.has_permissions(), accepts only one character for mode'

def _check_permission(self, obj, mode='r'):

    query = models.Q(pk=self.id)
    for group in self.get_groups():
        if group:
            query = (query | models.Q(pk=group.id))
    if obj.full_access.filter(query).exists():
        return True
    if ((mode == 'r') or (mode == 'x')):
        if obj.read_access.filter(query).exists():
            return True
    if (not obj.full_access.exists()):
        return True
    return False
