Module: DownloadsHelper

Defined in:
app/helpers/downloads_helper.rb

Instance Method Summary collapse

Instance Method Details

#download_file_api_url(download) ⇒ Object



12
13
14
15
16
17
18
19
# File 'app/helpers/downloads_helper.rb', line 12

def download_file_api_url(download)
  return nil if download.nil?
  if sessions_current_project.api_access_token
    api_v1_api_download_file_url(download, project_token: sessions_current_project.api_access_token)
  else
    nil
  end
end


7
8
9
10
# File 'app/helpers/downloads_helper.rb', line 7

def download_link(download)
  return nil if download.nil?
  link_to(download_tag(download), download.metamorphosize)
end

#download_status(download) ⇒ Hash

Returns calculated attributes used in /download responses.

Returns:

  • (Hash)

    calculated attributes used in /download responses



23
24
25
26
27
28
29
# File 'app/helpers/downloads_helper.rb', line 23

def download_status(download)
  return nil if download.nil?  || !download.persisted?
  return {
    ready: download.ready?,
    expired: download.expired?
  }
end

#download_tag(download) ⇒ Object



2
3
4
5
# File 'app/helpers/downloads_helper.rb', line 2

def download_tag(download)
  return nil if download.nil?
  "[#{download.name}] #{download.description}".html_safe
end