Class: Hyrax::SingleUseLinksController

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

Instance Method Summary collapse

Instance Method Details

#create_downloadObject



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

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



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

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


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

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



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

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

#indexObject



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

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