Class: EventImportFilesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- EventImportFilesController
- Defined in:
- app/controllers/event_import_files_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /event_import_files POST /event_import_files.json.
-
#destroy ⇒ Object
DELETE /event_import_files/1 DELETE /event_import_files/1.json.
-
#edit ⇒ Object
GET /event_import_files/1/edit.
-
#index ⇒ Object
GET /event_import_files GET /event_import_files.json.
-
#new ⇒ Object
GET /event_import_files/new GET /event_import_files/new.json.
-
#show ⇒ Object
GET /event_import_files/1 GET /event_import_files/1.json.
-
#update ⇒ Object
PUT /event_import_files/1 PUT /event_import_files/1.json.
Instance Method Details
#create ⇒ Object
POST /event_import_files POST /event_import_files.json
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'app/controllers/event_import_files_controller.rb', line 59 def create @event_import_file = EventImportFile.new(event_import_file_params) @event_import_file.user = current_user respond_to do |format| if @event_import_file.save if @event_import_file.mode == 'import' EventImportFileJob.perform_later(@event_import_file) end format.html { redirect_to @event_import_file, notice: t('import.successfully_created', model: t('activerecord.models.event_import_file')) } format.json { render json: @event_import_file, status: :created, location: @event_import_file } else format.html { render action: "new" } format.json { render json: @event_import_file.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /event_import_files/1 DELETE /event_import_files/1.json
98 99 100 101 102 103 104 105 |
# File 'app/controllers/event_import_files_controller.rb', line 98 def destroy @event_import_file.destroy respond_to do |format| format.html { redirect_to event_import_files_url } format.json { head :no_content } end end |
#edit ⇒ Object
GET /event_import_files/1/edit
54 55 |
# File 'app/controllers/event_import_files_controller.rb', line 54 def edit end |
#index ⇒ Object
GET /event_import_files GET /event_import_files.json
8 9 10 11 12 13 14 15 |
# File 'app/controllers/event_import_files_controller.rb', line 8 def index @event_import_files = EventImportFile.order(created_at: :desc).page(params[:page]) respond_to do |format| format.html # index.html.erb format.json { render json: @event_import_files } end end |
#new ⇒ Object
GET /event_import_files/new GET /event_import_files/new.json
42 43 44 45 46 47 48 49 50 51 |
# File 'app/controllers/event_import_files_controller.rb', line 42 def new @event_import_file = EventImportFile.new @event_import_file.default_library = current_user.profile.library @event_import_file.default_event_category = @event_categories.first respond_to do |format| format.html # new.html.erb format.json { render json: @event_import_file } end end |
#show ⇒ Object
GET /event_import_files/1 GET /event_import_files/1.json
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/controllers/event_import_files_controller.rb', line 19 def show if @event_import_file.event_import.path unless ENV['ENJU_STORAGE'] == 's3' file = @event_import_file.event_import.path end end @event_import_results = @event_import_file.event_import_results.page(params[:page]) respond_to do |format| format.html # show.html.erb format.json { render json: @event_import_file } format.download { if ENV['ENJU_STORAGE'] == 's3' redirect_to @event_import_file.event_import.expiring_url(10) else send_file file, filename: @event_import_file.event_import_file_name, type: 'application/octet-stream' end } end end |
#update ⇒ Object
PUT /event_import_files/1 PUT /event_import_files/1.json
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'app/controllers/event_import_files_controller.rb', line 80 def update respond_to do |format| if @event_import_file.update(event_import_file_params) if @event_import_file.mode == 'import' EventImportFileJob.perform_later(@event_import_file) end format.html { redirect_to @event_import_file, notice: t('controller.successfully_updated', model: t('activerecord.models.event_import_file')) } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @event_import_file.errors, status: :unprocessable_entity } end end end |