Sha256: 87fdd9849bd75a489adf3d5013a4c4d156149b8d4dcab42c349a81461182ed43
Contents?: true
Size: 1.49 KB
Versions: 6
Compression:
Stored size: 1.49 KB
Contents
module Coupler module Extensions module Imports def self.registered(app) app.post "/projects/:project_id/imports/upload" do @import = Models::Import.new(:data => params[:data], :project => @project) erb :'imports/new' end app.post "/projects/:project_id/imports" do @import = Models::Import.new(params[:import].merge(:project_id => @project.id)) if @import.save @resource = Models::Resource.new(:import => @import) if @resource.valid? if @import.import! @resource.save redirect("/projects/#{@project.id}/resources/#{@resource.id}") else redirect("/projects/#{@project.id}/imports/#{@import.id}/edit") end end end erb(:'imports/new') end app.get "/projects/:project_id/imports/:id/edit" do @import = Models::Import[:id => params[:id], :project_id => @project.id] raise ImportNotFound unless @import erb(:'imports/edit') end app.put "/projects/:project_id/imports/:id" do @import = Models::Import[:id => params[:id], :project_id => @project.id] raise ImportNotFound unless @import @import.repair_duplicate_keys!(params[:delete]) @resource = Models::Resource.create(:import => @import) redirect("/projects/#{@project.id}/resources/#{@resource.id}") end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems