scenario_imports_controller.rb 658 B

1234567891011121314151617181920
  1. class ScenarioImportsController < ApplicationController
  2. def new
  3. @scenario_import = ScenarioImport.new(:url => params[:url])
  4. end
  5. def create
  6. @scenario_import = ScenarioImport.new(params[:scenario_import])
  7. @scenario_import.set_user(current_user)
  8. if @scenario_import.will_request_local?(scenarios_url)
  9. render :text => 'Sorry, you cannot import a Scenario by URL from your own Huginn server.' and return
  10. end
  11. if @scenario_import.valid? && @scenario_import.should_import? && @scenario_import.import
  12. redirect_to @scenario_import.scenario, notice: "Import successful!"
  13. else
  14. render action: "new"
  15. end
  16. end
  17. end