diff --git a/app/controllers/concerns/scholars_archive/works_controller_behavior.rb b/app/controllers/concerns/scholars_archive/works_controller_behavior.rb index 8bcd4fab5..4d15c7102 100644 --- a/app/controllers/concerns/scholars_archive/works_controller_behavior.rb +++ b/app/controllers/concerns/scholars_archive/works_controller_behavior.rb @@ -3,8 +3,16 @@ module WorksControllerBehavior extend ActiveSupport::Concern include Hyrax::WorksControllerBehavior included do + before_action :redirect_mismatched_work, only: [:show] before_action :migrate_work_in_place, only: [:edit, :show] + def redirect_mismatched_work + curation_concern = ActiveFedora::Base.find(params[:id]) + if curation_concern.class != _curation_concern_type + redirect_to(main_app.polymorphic_path(curation_concern), status: :moved_permanently) and return + end + end + def migrate_work_in_place work = ActiveFedora::Base.find(params[:id]) unless Migrator.has_migrated?(work: work)