diff options
| author | Luc Donnet | 2015-04-22 10:38:49 +0200 |
|---|---|---|
| committer | Luc Donnet | 2015-04-22 10:38:49 +0200 |
| commit | 42c570ba88f073d0082b948ced1e3b6f57868afe (patch) | |
| tree | 9221feb52585362b8ec6a53baef4a7254747e178 /app/controllers/imports_controller.rb | |
| parent | 75b5d7d86f6b5a26b7f88eb7c6b788d59163ef5b (diff) | |
| download | chouette-core-42c570ba88f073d0082b948ced1e3b6f57868afe.tar.bz2 | |
Update import use
Diffstat (limited to 'app/controllers/imports_controller.rb')
| -rw-r--r-- | app/controllers/imports_controller.rb | 41 |
1 files changed, 9 insertions, 32 deletions
diff --git a/app/controllers/imports_controller.rb b/app/controllers/imports_controller.rb index e7ff7ff15..e09fdfec5 100644 --- a/app/controllers/imports_controller.rb +++ b/app/controllers/imports_controller.rb @@ -1,17 +1,13 @@ require 'will_paginate/array' +require 'open-uri' class ImportsController < ChouetteController defaults :resource_class => Import - respond_to :html, :only => [:show, :index, :new, :create, :delete] + respond_to :html, :only => [:show, :index, :destroy, :imported_file] respond_to :js, :only => [:show, :index] belongs_to :referential - # create => curl -F "file=@Citura.zip;filename=Citura.zip" -F "file=@parameters.json;filename=parameters.json" http://localhost:8080/chouette_iev/referentials/test/importer/neptune - # index curl http://localhost:8080/mobi.chouette.api/referentials/test/jobs - # show curl http://localhost:8080/mobi.chouette.api/referentials/test/jobs - - def index begin index! do @@ -34,24 +30,11 @@ class ImportsController < ChouetteController flash[:error] = t('iev.failure') redirect_to referential_path(@referential) end - end - - def new - begin - new! do - puts "OK" - end - rescue Ievkit::Error => error - logger.error("Iev failure : #{error.message}") - flash[:error] = t('iev.failure') - redirect_to referential_path(@referential) - end - end - - def create + end + + def destroy begin - create! do - puts "OK" + destroy! do end rescue Ievkit::Error => error logger.error("Iev failure : #{error.message}") @@ -60,12 +43,9 @@ class ImportsController < ChouetteController end end - def delete + def imported_file begin - delete! do - import_service.delete(@import.id) - redirect_to referential_imports_path(@referential) - end + send_file open(resource.file_path), { :type => "application/#{resource.filename_extension}", :disposition => "attachment", :filename => resource.filename } rescue Ievkit::Error => error logger.error("Iev failure : #{error.message}") flash[:error] = t('iev.failure') @@ -74,14 +54,11 @@ class ImportsController < ChouetteController end protected + alias_method :import, :resource def import_service ImportService.new(@referential) end - - def build_resource(attributes = {}) - @import ||= ImportTask.new - end def resource @import ||= import_service.find( params[:id] ) |
