diff options
| author | Alban Peignier | 2012-06-06 19:11:25 +0200 | 
|---|---|---|
| committer | Alban Peignier | 2012-06-06 19:11:25 +0200 | 
| commit | ecc2c32f1c42ca5b22d96924c6371c23b12723ac (patch) | |
| tree | defb322c7075b9bbf114afed1bdd44f3b4f3fa25 /app/controllers/imports_controller.rb | |
| parent | 3a2bc072996a61047ba1d829101b4dd8bfda336c (diff) | |
| download | chouette-core-ecc2c32f1c42ca5b22d96924c6371c23b12723ac.tar.bz2 | |
Add view to manage several Import implementations
Diffstat (limited to 'app/controllers/imports_controller.rb')
| -rw-r--r-- | app/controllers/imports_controller.rb | 24 | 
1 files changed, 24 insertions, 0 deletions
diff --git a/app/controllers/imports_controller.rb b/app/controllers/imports_controller.rb index 7e33b8c26..06017da7d 100644 --- a/app/controllers/imports_controller.rb +++ b/app/controllers/imports_controller.rb @@ -2,14 +2,38 @@ class ImportsController < ChouetteController    respond_to :html, :xml, :json    belongs_to :referential +  def new +    new! do +      available_imports +    end +  end +    def create      create! do |success, failure| +      available_imports        success.html { redirect_to referential_imports_path(@referential) }      end    end    protected +  def available_imports +    @available_imports ||= Import.types.collect do |type| +      unless @import.type == type +        @referential.imports.build :type => type +      else +        @import +      end +    end +  end + +  # FIXME why #resource_id is nil ?? +  def build_resource +    super.tap do |import| +      import.referential_id = @referential.id +    end +  end +    def collection      @imports ||= end_of_association_chain.paginate(:page => params[:page])    end  | 
