diff --git a/mayan/apps/documents/__init__.py b/mayan/apps/documents/__init__.py index 420464e46c..b334937aed 100644 --- a/mayan/apps/documents/__init__.py +++ b/mayan/apps/documents/__init__.py @@ -139,7 +139,7 @@ class_permissions(Document, [PERMISSION_DOCUMENT_DELETE, PERMISSION_DOCUMENT_VIEW, PERMISSION_HISTORY_VIEW]) -document_search = SearchModel('documents', 'Document', permission=PERMISSION_DOCUMENT_VIEW, serializer='documents.serializers.DocumentSerializer') +document_search = SearchModel('documents', 'Document', permission=PERMISSION_DOCUMENT_VIEW, serializer_string='documents.serializers.DocumentSerializer') # TODO: move these to their respective apps # Moving these to other apps cause an ImportError; circular import? diff --git a/mayan/apps/dynamic_search/classes.py b/mayan/apps/dynamic_search/classes.py index 806afd1fdd..b4ffa51b04 100644 --- a/mayan/apps/dynamic_search/classes.py +++ b/mayan/apps/dynamic_search/classes.py @@ -17,21 +17,19 @@ logger = logging.getLogger(__name__) class SearchModel(object): registry = {} - @classmethod - def get_all(cls): - return cls.registry.values() - @classmethod def get(cls, full_name): - return cls.registry[full_name] + result = cls.registry[full_name] + result.serializer = load_backend(self.serializer_string) + return result - def __init__(self, app_label, model_name, serializer, label=None, permission=None): + def __init__(self, app_label, model_name, serializer_string, label=None, permission=None): self.app_label = app_label self.model_name = model_name self.search_fields = {} self.model = get_model(app_label, model_name) self.label = label or self.model._meta.verbose_name - self.serializer = load_backend(serializer) + self.serializer_string = serializer_string self.permission = permission self.__class__.registry[self.get_full_name()] = self