blob: a5282a51449091c7877242e331bb37b1b206a035 (
plain)
1
2
3
4
5
6
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
46
47
48
49
50
|
class ExportsController < ChouetteController
include PolicyChecker
include RansackDateFilter
include IevInterfaces
skip_before_action :authenticate_user!, only: [:upload]
defaults resource_class: Export::Base, collection_name: 'exports', instance_name: 'export'
def upload
if params[:token] == resource.token_upload
resource.file = params[:file]
resource.save!
redirect_to [resource.workbench, resource]
else
user_not_authorized
end
end
private
def index_model
Export::Base
end
def build_resource
Export::Base.force_load_descendants if Rails.env.development?
@export ||= Export::Base.new(*resource_params) do |export|
export.workbench = parent
export.creator = current_user.name
end
@export
end
def export_params
permitted_keys = %i(name type referential_id)
export_class = params[:export] && params[:export][:type] && params[:export][:type].safe_constantize
if export_class
permitted_keys += export_class.options.keys
end
params.require(:export).permit(permitted_keys)
end
def decorate_collection(exports)
ExportDecorator.decorate(
exports,
context: {
workbench: @workbench
}
)
end
end
|