diff --git a/geonode/documents/handlers.py b/geonode/documents/handlers.py index 4cffe871c73..2f54d8ad1dc 100644 --- a/geonode/documents/handlers.py +++ b/geonode/documents/handlers.py @@ -18,7 +18,7 @@ def download_urls(self, **kwargs): super().download_urls() return [ { - "url": self.instance.download_url, + "url": self.instance.download_url if not self.instance.doc_url else self.instance.doc_url, "ajax_safe": self.instance.download_is_ajax_safe, }, ] diff --git a/geonode/resource/handler.py b/geonode/resource/handler.py index 3ab8979c626..1ae43ee8595 100644 --- a/geonode/resource/handler.py +++ b/geonode/resource/handler.py @@ -14,8 +14,8 @@ class BaseResourceHandler(ABC): REGISTRY = [] - def __init__(self) -> None: - self.instance = None + def __init__(self, instance=None) -> None: + self.instance = instance def __str__(self): return f"{self.__module__}.{self.__class__.__name__}" @@ -23,10 +23,6 @@ def __str__(self): def __repr__(self): return self.__str__() - @classmethod - def init_class(cls, instance): - cls.instance = instance - @classmethod def register(cls): BaseResourceHandler.REGISTRY.append(cls) @@ -41,8 +37,7 @@ def get_handler_by_instance(self, instance): """ for handler in self.get_registry(): if handler.can_handle(instance): - self.init_class(instance) - return handler() + return handler(instance) logger.error("No handlers found for the given resource") return self