GeoNode/geonode

Improvements for DownloadHandler

Closed this issue · 0 comments

As a follow-up of this issue #11296 we want to introduce a new set of improvement for the download handler.
This improvements will help to make room for an API that supports multiple downloads (in the future)

Datasets

  • Rename DownloadHandler to DatasetDownloadHandler, and move it under the layers module
  • The DatasetDownloadHandler implements an is_ajax_safe method which will return a boolean -> whether the download_url can be called with AJAX or not. For the default handler it will be:
    • true for WPS
    • false for all the other cases
  • Remove the logic for the creation of the "original" Link entries here.
  • Dataset.download_url will just return build_absolute_uri. The logic of whether to return any "original" Link (created manually or received from previous DBs) will be moved to the DatasetDownloadHandler.

Documents

  • Also, documents must return whether AJAX is safe or not. I wouldn't bother too much here, since we have a convoluted download / link / href logic for documents. Maybe we can implement a Document.download_is_ajax_safe property returning true if the resource is LOCAL, false otherwise.

API

  • Implement a download_urls array property for the ResourceBaseSerializer with the following structure:
 "download_urls": [
   {
      "URL": .... , 
      "ajax_safe": true|false, 
      "default":true|false
   },
]	
  • For the moment download_urls will contain only one entry;
    • For datasets, it will be populated with the properties obtained from the single DatasetDownloadHandler. NOTICE that for REMOTE resources (e.g. services) download_urls should return an empty array. Let's think if it will be the serializer to handle this case, or let DatasetDownloadHandler return the download_url object itself (which would be None for REMOTE datasets).
    • For documents, it will be populated from Document.download_url and Document.download_is_ajax_safe
    • For the other resource types it will return an empty array
  • Deprecate the download_url field.