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



50
51
52
53
54
55
56
57
58
# File 'app/controllers/curation_concern/generic_files_controller.rb', line 50

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



37
38
39
40
41
42
43
44
# File 'app/controllers/curation_concern/generic_files_controller.rb', line 37

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

#destroyObject



91
92
93
94
95
96
# File 'app/controllers/curation_concern/generic_files_controller.rb', line 91

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

#editObject



65
66
67
# File 'app/controllers/curation_concern/generic_files_controller.rb', line 65

def edit
  respond_with(curation_concern)
end

#newObject



46
47
48
# File 'app/controllers/curation_concern/generic_files_controller.rb', line 46

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



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

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

#showObject



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

def show
  respond_with(curation_concern)
end

#updateObject



69
70
71
72
73
74
75
76
# File 'app/controllers/curation_concern/generic_files_controller.rb', line 69

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



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

def versions
  respond_with(curation_concern)
end