Sha256: cd8251e1485011e5313c60b1e42c897dfd8ade3786dca9bae46dab7af179ecf9

Contents?: true

Size: 1.42 KB

Versions: 10

Compression:

Stored size: 1.42 KB

Contents

# Include this module into any of your Controller classes to add Hydra functionality
#
# The primary function of this module is to mix in a number of other Hydra Modules, including 
#   Hydra::AccessControlsEnforcement
#
# @example 
#  class CustomHydraController < ApplicationController  
#    include Hydra::Controller::ControllerBehavior
#  end
#
module Hydra::Controller::ControllerBehavior
  extend ActiveSupport::Concern

  included do
    # Other modules to auto-include
    include Hydra::AccessControlsEnforcement
  
    # Catch permission errors
    rescue_from CanCan::AccessDenied do |exception|
      if (exception.action == :edit)
        redirect_to({:action=>'show'}, :alert => exception.message)
      elsif current_user and current_user.persisted?
        redirect_to root_path, :alert => exception.message
      else
        session["user_return_to"] = request.url
        redirect_to new_user_session_path, :alert => exception.message
      end
    end
  end
  
  
  # get the currently configured user identifier.  Can be overridden to return whatever (ie. login, email, etc)
  # defaults to using whatever you have set as the Devise authentication_key
  def user_key
    current_user.user_key if current_user
  end

  module ClassMethods
    # get the solr name for a field with this name and using the given solrizer descriptor
    def solr_name(name, *opts)
      ActiveFedora::SolrService.solr_name(name, *opts)
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
hydra-core-8.0.0 app/controllers/concerns/hydra/controller/controller_behavior.rb
hydra-core-8.0.0.beta1 app/controllers/concerns/hydra/controller/controller_behavior.rb
hydra-core-7.2.2 app/controllers/concerns/hydra/controller/controller_behavior.rb
hydra-core-7.2.1 app/controllers/concerns/hydra/controller/controller_behavior.rb
hydra-core-7.2.0 app/controllers/concerns/hydra/controller/controller_behavior.rb
hydra-core-7.1.0 app/controllers/concerns/hydra/controller/controller_behavior.rb
hydra-core-7.1.0.rc2 app/controllers/concerns/hydra/controller/controller_behavior.rb
hydra-core-7.1.0.rc1 app/controllers/concerns/hydra/controller/controller_behavior.rb
hydra-core-7.0.2 app/controllers/concerns/hydra/controller/controller_behavior.rb
hydra-core-7.0.1 app/controllers/concerns/hydra/controller/controller_behavior.rb