Class: Hyrax::SingleUseLinksController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/hyrax/single_use_links_controller.rb

Instance Method Summary collapse

Instance Method Details

#create_downloadObject



20
21
22
23
# File 'app/controllers/hyrax/single_use_links_controller.rb', line 20

def create_download
  @su = SingleUseLink.create item_id: params[:id], path: hyrax.download_path(id: params[:id])
  render plain: hyrax.download_single_use_link_url(@su.download_key)
end

#create_showObject



25
26
27
28
# File 'app/controllers/hyrax/single_use_links_controller.rb', line 25

def create_show
  @su = SingleUseLink.create(item_id: params[:id], path: asset_show_path)
  render plain: hyrax.show_single_use_link_url(@su.download_key)
end


11
12
13
14
15
16
17
18
# File 'app/controllers/hyrax/single_use_links_controller.rb', line 11

def deny_link_access(exception)
  if current_user&.persisted?
    redirect_to main_app.root_url, alert: "You do not have sufficient privileges to create links to this document"
  else
    session["user_return_to"] = request.url
    redirect_to new_user_session_url, alert: exception.message
  end
end

#destroyObject



35
36
37
38
# File 'app/controllers/hyrax/single_use_links_controller.rb', line 35

def destroy
  SingleUseLink.find_by_download_key(params[:link_id]).destroy
  head :ok
end

#indexObject



30
31
32
33
# File 'app/controllers/hyrax/single_use_links_controller.rb', line 30

def index
  links = SingleUseLink.where(item_id: params[:id]).map { |link| show_presenter.new(link) }
  render partial: 'hyrax/file_sets/single_use_link_rows', locals: { single_use_links: links }
end