Sha256: c0562707bf04f45477d4f2ae30496e20a29002ae7d76432d0e9cc1e8e63abbf8

Contents?: true

Size: 981 Bytes

Versions: 8

Compression:

Stored size: 981 Bytes

Contents

require 'sufia/single_use_error'

class SingleUseLinksController < ApplicationController
  include Sufia::Noid

  prepend_before_filter :normalize_identifier
  before_filter :load_asset
  before_filter :authenticate_user!
  before_filter :authorize_user!

  def new_download
    @su = SingleUseLink.create :itemId => params[:id], :path => sufia.download_path(:id => @asset)
    @link = sufia.download_single_use_link_path(@su.downloadKey)

    respond_to do |format|
      format.html
      format.js  { render :js => @link }
    end
  end

  def new_show
    @su = SingleUseLink.create :itemId => params[:id], :path => sufia.polymorphic_path(@asset)
    @link = sufia.show_single_use_link_path(@su.downloadKey)

    respond_to do |format|
      format.html
      format.js  { render :js => @link }
    end
  end

  protected
  def authorize_user!
    authorize! :read, @asset
  end

  def load_asset
    @asset = ActiveFedora::Base.load_instance_from_solr(params[:id])
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
sufia-3.5.0 app/controllers/single_use_links_controller.rb
sufia-3.4.0 app/controllers/single_use_links_controller.rb
sufia-3.4.0.rc4 app/controllers/single_use_links_controller.rb
sufia-3.4.0.rc3 app/controllers/single_use_links_controller.rb
sufia-3.3.1 app/controllers/single_use_links_controller.rb
sufia-3.4.0.rc2 app/controllers/single_use_links_controller.rb
sufia-3.4.0.rc1 app/controllers/single_use_links_controller.rb
sufia-3.3.0 app/controllers/single_use_links_controller.rb