Class: ProjectsController
Instance Method Summary
collapse
#add_breadcrumb, #after_sign_in_path_for, #breadcrumbs, #new_session_path, #render_not_found, #require_admin_user
Instance Method Details
#details ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'app/controllers/projects_controller.rb', line 7
def details
return if project.blank?
add_breadcrumb(@presenter.title, project_path)
add_breadcrumb("Details")
@provenance_events = project.provenance_events.where.not(event_type: ProvenanceEvent::STATUS_UPDATE_EVENT_TYPE)
@project_eligible_to_edit = true if project.status == Project::APPROVED_STATUS && eligible_editor?
@project_metadata = @project.metadata
@storage_capacity = @project_metadata[:storage_capacity]
@size = @storage_capacity[:size]
@unit = @storage_capacity[:unit]
@requested_size = @size[:requested]
@requested_unit = @unit[:requested]
@approved_size = @size[:approved]
@approved_unit = @unit[:approved]
@storage_expectations = @project_metadata[:storage_performance_expectations]
@requested_storage_expectations = @storage_expectations[:requested]
@approved_storage_expectations = @storage_expectations[:approved]
@project_session = "details"
respond_to do |format|
format.html do
render
end
format.json do
render json: project.to_json
end
format.xml do
render xml: @presenter.to_xml
end
end
end
|
#file_list_download ⇒ Object
113
114
115
116
117
118
119
120
121
122
123
|
# File 'app/controllers/projects_controller.rb', line 113
def file_list_download
job_id = params[:job_id]
user_request = FileInventoryRequest.where(job_id:job_id).first
if user_request.nil?
redirect_to "/"
else
filename = user_request.output_file
send_data File.read(filename), type: "text/plain", filename: "filelist.csv", disposition: "attachment"
end
end
|
#index ⇒ Object
47
48
49
50
51
52
53
54
|
# File 'app/controllers/projects_controller.rb', line 47
def index
if current_user.eligible_sysadmin?
search_projects
else
flash[:alert] = I18n.t(:access_denied)
redirect_to dashboard_path
end
end
|
#list_contents ⇒ Object
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
# File 'app/controllers/projects_controller.rb', line 97
def list_contents
return if project.blank?
project_job_service.list_contents_job(user: current_user)
json_response = {
message: "File list for \"#{project.title}\" is being generated in the background. A link to the downloadable file list will be available in the \"Recent Activity\" section of your dashboard when it is available. You may safely navigate away from this page or close this tab."
}
render json: json_response
rescue => ex
message = "Error producing document list (project id: #{project&.id}): #{ex.message}"
Rails.logger.error(message)
Honeybadger.notify(message)
render json: { message: "Document list could not be generated." }
end
|
#show ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'app/controllers/projects_controller.rb', line 56
def show
return if project.blank?
add_breadcrumb(@presenter.title, project_path)
add_breadcrumb("Contents")
@latest_completed_download = current_user.user_requests.where(project_id: @project.id, state: "completed").order(:completion_time).last
@storage_usage = project.storage_usage(session_id: current_user.mediaflux_session)
@storage_capacity = project.storage_capacity(session_id: current_user.mediaflux_session)
@num_files = project.asset_count(session_id: current_user.mediaflux_session)
@file_list = project.file_list(session_id: current_user.mediaflux_session, size: 100)
@files = @file_list[:files]
@files.sort_by!(&:path)
@project_session = "content"
respond_to do |format|
format.html { render }
format.xml { render xml: ProjectShowPresenter.new(project, current_user).to_xml
}
end
end
|
GET “projects/:id/:id-mf”
This action is used to render the mediaflux metadata for a project.
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'app/controllers/projects_controller.rb', line 83
def show_mediaflux
project_id = params[:id]
project = Project.find(project_id)
respond_to do |format|
format.xml do
render xml: project.mediaflux_meta_xml(user: current_user)
end
end
rescue => ex
Rails.logger.error "Error getting MediaFlux XML for project #{project_id}, user #{current_user.uid}: #{ex.message}"
flash[:alert] = "Error fetching Mediaflux XML for this project"
redirect_to project_path(project_id)
end
|