# Path: business_logic/models/node.py
# class NodeAccessor(models.Model):
# 
#     @property
#     def node(self):
#         if hasattr(self, '_node_cache'):
#             return self._node_cache
# 
#         return Node.objects.get(content_type=ContentType.objects.get_for_model(self.__class__), object_id=self.id)
# 
#     class Meta:
#         abstract = True


import re
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.utils.encoding import python_2_unicode_compatible, force_text
from django.utils.translation import ugettext_lazy as _
from .node import NodeAccessor
# -*- coding: utf-8 -*-
#




@python_2_unicode_compatible
class ReferenceDescriptor(models.Model):
    content_type = models.OneToOneField(ContentType, on_delete=models.CASCADE)
    title = models.CharField(max_length=255, null=True, blank=True)
    search_fields = models.TextField(null=True, blank=True)
    name_field = models.SlugField(max_length=255, null=True, blank=True)

    class Meta:
        verbose_name = _('Reference descriptor')
        verbose_name_plural = _('Reference descriptors')

    def __str__(self):
        return force_text(self.content_type)

    def get_search_fields(self):
        if not self.search_fields:
            return []

        return re.split(r'[^\w_]+', self.search_fields)



# Path: business_logic/models/node.py
# class NodeAccessor(models.Model):
# 
#     @property
#     def node(self):
#         if hasattr(self, '_node_cache'):
#             return self._node_cache
# 
#         return Node.objects.get(content_type=ContentType.objects.get_for_model(self.__class__), object_id=self.id)
# 
#     class Meta:
#         abstract = True


# Path: business_logic/models/reference.py
import re
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.utils.encoding import python_2_unicode_compatible, force_text
from django.utils.translation import ugettext_lazy as _
from .node import NodeAccessor

# -*- coding: utf-8 -*-
#




@python_2_unicode_compatible
class ReferenceDescriptor(models.Model):
    content_type = models.OneToOneField(ContentType, on_delete=models.CASCADE)
    title = models.CharField(max_length=255, null=True, blank=True)
    search_fields = models.TextField(null=True, blank=True)
    name_field = models.SlugField(max_length=255, null=True, blank=True)

    class Meta:
        verbose_name = _('Reference descriptor')
        verbose_name_plural = _('Reference descriptors')

    def __str__(self):
        return force_text(self.content_type)

    def get_search_fields(self):
        if not self.search_fields:
            return []

        return re.split(r'[^\w_]+', self.search_fields)



class ReferenceConstant(NodeAccessor):