Class: CurationConcern::GenericFilesController

Inherits:
BaseController show all
Includes:
Morphine
Defined in:
app/controllers/curation_concern/generic_files_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#authorize_curation_concern!, #contributor_agreement, #save_and_add_related_files_submit_value

Methods inherited from ApplicationController

#show_action_bar?, #show_site_search?, #sufia, with_themed_layout

Instance Method Details

#attach_action_breadcrumbObject



4
5
6
7
# File 'app/controllers/curation_concern/generic_files_controller.rb', line 4

def attach_action_breadcrumb
  add_breadcrumb "#{parent.human_readable_type}", polymorphic_path([:curation_concern, parent])
  super
end

#createObject



46
47
48
49
50
51
52
53
54
# File 'app/controllers/curation_concern/generic_files_controller.rb', line 46

def create
  curation_concern.batch = parent
  actor.create!
  respond_with([:curation_concern, parent])
rescue ActiveFedora::RecordInvalid
  respond_with([:curation_concern, curation_concern]) { |wants|
    wants.html { render 'new', status: :unprocessable_entity }
  }
end

#curation_concernObject



33
34
35
36
37
38
39
40
# File 'app/controllers/curation_concern/generic_files_controller.rb', line 33

def curation_concern
  @curation_concern ||=
  if params[:id]
    GenericFile.find(params[:id])
  else
    GenericFile.new(params[:generic_file])
  end
end

#destroyObject



83
84
85
86
87
88
89
# File 'app/controllers/curation_concern/generic_files_controller.rb', line 83

def destroy
  parent = curation_concern.batch
  title = curation_concern.to_s
  curation_concern.destroy
  flash[:notice] = "Deleted #{title}"
  respond_with([:curation_concern, parent])
end

#editObject



61
62
63
# File 'app/controllers/curation_concern/generic_files_controller.rb', line 61

def edit
  respond_with(curation_concern)
end

#newObject



42
43
44
# File 'app/controllers/curation_concern/generic_files_controller.rb', line 42

def new
  respond_with(curation_concern)
end

#parentObject



10
11
12
13
14
15
16
17
# File 'app/controllers/curation_concern/generic_files_controller.rb', line 10

def parent
  @parent ||=
  if params[:id]
    curation_concern.batch
  else
    ActiveFedora::Base.find(namespaced_parent_id,cast: true)
  end
end

#rollbackObject



78
79
80
81
# File 'app/controllers/curation_concern/generic_files_controller.rb', line 78

def rollback
  retrieve_version
  respond_with([:curation_concern, curation_concern])
end

#showObject



57
58
59
# File 'app/controllers/curation_concern/generic_files_controller.rb', line 57

def show
  respond_with(curation_concern)
end

#updateObject



65
66
67
68
69
70
71
72
# File 'app/controllers/curation_concern/generic_files_controller.rb', line 65

def update
  actor.update!
  respond_with([:curation_concern, curation_concern])
rescue ActiveFedora::RecordInvalid
  respond_with([:curation_concern, curation_concern]) { |wants|
    wants.html { render 'edit', status: :unprocessable_entity }
  }
end

#versionsObject



74
75
76
# File 'app/controllers/curation_concern/generic_files_controller.rb', line 74

def versions
  respond_with(curation_concern)
end