Class: DownloadsController

Inherits:
ApplicationController show all
Includes:
DataControllerConfiguration::ProjectDataControllerConfiguration
Defined in:
app/controllers/downloads_controller.rb

Instance Method Summary collapse

Methods included from DataControllerConfiguration::ProjectDataControllerConfiguration

#annotator_params

Methods included from RequestType

#json_request?

Methods included from LogRecent

#log_user_recent_route

Methods included from Cookies

#digest_cookie, #digested_cookie_exists?

Methods included from Whitelist

#whitelist_constantize

Methods included from ProjectsHelper

#invalid_object, #project_link, #project_matches, #project_tag, #projects_list, #projects_search_form

Methods included from Api::Intercept

#intercept_api

Instance Method Details

#api_fileObject



50
51
52
# File 'app/controllers/downloads_controller.rb', line 50

def api_file
  send_file @download.file_path
end

#api_showObject



54
55
56
# File 'app/controllers/downloads_controller.rb', line 54

def api_show
  render '/downloads/api/index.json.jbuilder'
end

#destroyObject

DELETE /downloads/1 DELETE /downloads/1.json



19
20
21
22
23
24
25
# File 'app/controllers/downloads_controller.rb', line 19

def destroy
  @download.destroy
  respond_to do |format|
    format.html { redirect_to downloads_url, notice: 'Download was successfully destroyed.' }
    format.json { head :no_content }
  end
end

#download_fileObject

GET /downloads/1/download_file



41
42
43
44
45
46
47
48
# File 'app/controllers/downloads_controller.rb', line 41

def download_file
  if @download.ready?
    @download.increment!(:times_downloaded)
    send_file @download.file_path
  else
    redirect_to download_url
  end
end

#download_paramsObject (private)



64
65
66
# File 'app/controllers/downloads_controller.rb', line 64

def download_params
  params.require(:download).permit(:is_public)
end

#indexObject

GET /downloads GET /downloads.json



8
9
10
11
# File 'app/controllers/downloads_controller.rb', line 8

def index
  @recent_objects = Download.recent_from_project_id(sessions_current_project_id).order(updated_at: :desc).limit(10)
  render '/shared/data/all/index'
end

#listObject

GET /downloads/list GET /downloads/list.json



36
37
38
# File 'app/controllers/downloads_controller.rb', line 36

def list
  @downloads = Download.where(project_id: sessions_current_project_id).order(:id).page(params[:page]).per(params[:per])
end

#set_downloadObject (private)



60
61
62
# File 'app/controllers/downloads_controller.rb', line 60

def set_download
  @download = Download.unscoped.where(project_id: sessions_current_project_id).find(params[:id])
end

#showObject

GET /downloads/1



14
15
# File 'app/controllers/downloads_controller.rb', line 14

def show
end

#updateObject

PATCH /downloads/1 PATCH /downloads/1.json



29
30
31
32
# File 'app/controllers/downloads_controller.rb', line 29

def update 
  @download.update(download_params)
  render action: :show
end