aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/exports_controller.rb
diff options
context:
space:
mode:
authorAlban Peignier2012-06-07 13:39:35 +0200
committerAlban Peignier2012-06-07 13:39:35 +0200
commit7c0ae629a2ea0079c8b5efbd4c41b6ca661eae91 (patch)
tree26195fe0d4eb8e77a89a9dadaf25626fc3f7fc50 /app/controllers/exports_controller.rb
parent1d72c64b77c20d0d3b0bf4b05c40ba99a97493bd (diff)
downloadchouette-core-7c0ae629a2ea0079c8b5efbd4c41b6ca661eae91.tar.bz2
Add support for Exports. Refs #41
Diffstat (limited to 'app/controllers/exports_controller.rb')
-rw-r--r--app/controllers/exports_controller.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/app/controllers/exports_controller.rb b/app/controllers/exports_controller.rb
new file mode 100644
index 000000000..6a77f7f45
--- /dev/null
+++ b/app/controllers/exports_controller.rb
@@ -0,0 +1,34 @@
+class ExportsController < ChouetteController
+
+ respond_to :html, :xml, :json
+ respond_to :zip, :only => :show
+
+ belongs_to :referential
+
+ def create
+ create! do |success, failure|
+ success.html { redirect_to referential_exports_path(@referential) }
+ end
+ end
+
+ def show
+ show! do |format|
+ format.zip { send_file @export.file, :type => :zip }
+ end
+ end
+
+
+ protected
+
+ # FIXME why #resource_id is nil ??
+ def build_resource
+ super.tap do |export|
+ export.referential_id = @referential.id
+ end
+ end
+
+ def collection
+ @exports ||= end_of_association_chain.paginate(:page => params[:page])
+ end
+
+end