Module: Hyrax::CurationConcernController

Extended by:
ActiveSupport::Concern
Includes:
Blacklight::AccessControls::Catalog, Blacklight::Base
Included in:
BatchUploadsControllerBehavior, CitationsController, WorksControllerBehavior
Defined in:
app/controllers/concerns/hyrax/curation_concern_controller.rb

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#actor=(value) ⇒ Object

Sets the attribute actor

Parameters:

  • value

    the value to set the attribute actor to.



116
117
118
# File 'app/controllers/concerns/hyrax/curation_concern_controller.rb', line 116

def actor=(value)
  @actor = value
end

Instance Method Details

#createObject



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'app/controllers/concerns/hyrax/curation_concern_controller.rb', line 44

def create
  if actor.create(attributes_for_actor)
    after_create_response
  else
    respond_to do |wants|
      wants.html do
        build_form
        render 'new', status: :unprocessable_entity
      end
      wants.json { render_json_response(response_type: :unprocessable_entity, options: { errors: curation_concern.errors }) }
    end
  end
end

#destroyObject



100
101
102
103
104
105
# File 'app/controllers/concerns/hyrax/curation_concern_controller.rb', line 100

def destroy
  title = curation_concern.to_s
  return unless actor.destroy
  Hyrax.config.callback.run(:after_destroy, curation_concern.id, current_user)
  after_destroy_response(title)
end

#editObject



82
83
84
# File 'app/controllers/concerns/hyrax/curation_concern_controller.rb', line 82

def edit
  build_form
end

#file_managerObject



107
108
109
# File 'app/controllers/concerns/hyrax/curation_concern_controller.rb', line 107

def file_manager
  @form = Forms::FileManagerForm.new(curation_concern, current_ability)
end

#inspect_workObject

Raises:

  • (Hydra::AccessDenied)


111
112
113
114
# File 'app/controllers/concerns/hyrax/curation_concern_controller.rb', line 111

def inspect_work
  raise Hydra::AccessDenied unless current_ability.admin?
  presenter
end

#newObject



40
41
42
# File 'app/controllers/concerns/hyrax/curation_concern_controller.rb', line 40

def new
  build_form
end

#showObject

Finds a solr document matching the id and sets @presenter

Raises:

  • CanCan::AccessDenied if the document is not found or the user doesn’t have access to it.



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'app/controllers/concerns/hyrax/curation_concern_controller.rb', line 60

def show
  respond_to do |wants|
    wants.html { presenter && parent_presenter }
    wants.json do
      # load and authorize @curation_concern manually because it's skipped for html
      @curation_concern = _curation_concern_type.find(params[:id]) unless curation_concern
      authorize! :show, @curation_concern
      render :show, status: :ok
    end
    additional_response_formats(wants)
    wants.ttl do
      render body: presenter.export_as_ttl, content_type: 'text/turtle'
    end
    wants.jsonld do
      render body: presenter.export_as_jsonld, content_type: 'application/ld+json'
    end
    wants.nt do
      render body: presenter.export_as_nt, content_type: 'application/n-triples'
    end
  end
end

#updateObject



86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'app/controllers/concerns/hyrax/curation_concern_controller.rb', line 86

def update
  if actor.update(attributes_for_actor)
    after_update_response
  else
    respond_to do |wants|
      wants.html do
        build_form
        render 'edit', status: :unprocessable_entity
      end
      wants.json { render_json_response(response_type: :unprocessable_entity, options: { errors: curation_concern.errors }) }
    end
  end
end