Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into interpolated_options
Conflicts: app/models/agent.rb spec/models/agent_spec.rb
- Loading branch information
Showing
73 changed files
with
2,717 additions
and
758 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.scenario-import { | ||
.agent-import-list { | ||
.agent-import { | ||
margin-bottom: 20px; | ||
|
||
.instructions { | ||
margin-bottom: 10px; | ||
} | ||
|
||
.current { | ||
font-weight: bold; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module HasGuid | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
before_save :make_guid | ||
end | ||
|
||
protected | ||
|
||
def make_guid | ||
self.guid = SecureRandom.hex unless guid.present? | ||
end | ||
end |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
class ScenarioImportsController < ApplicationController | ||
def new | ||
@scenario_import = ScenarioImport.new(:url => params[:url]) | ||
end | ||
|
||
def create | ||
@scenario_import = ScenarioImport.new(params[:scenario_import]) | ||
@scenario_import.set_user(current_user) | ||
|
||
if @scenario_import.will_request_local?(scenarios_url) | ||
render :text => 'Sorry, you cannot import a Scenario by URL from your own Huginn server.' and return | ||
end | ||
|
||
if @scenario_import.valid? && @scenario_import.should_import? && @scenario_import.import | ||
redirect_to @scenario_import.scenario, notice: "Import successful!" | ||
else | ||
render action: "new" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
class ScenariosController < ApplicationController | ||
skip_before_filter :authenticate_user!, :only => :export | ||
|
||
def index | ||
@scenarios = current_user.scenarios.page(params[:page]) | ||
|
||
respond_to do |format| | ||
format.html | ||
format.json { render json: @scenarios } | ||
end | ||
end | ||
|
||
def new | ||
@scenario = current_user.scenarios.build | ||
|
||
respond_to do |format| | ||
format.html | ||
format.json { render json: @scenario } | ||
end | ||
end | ||
|
||
def show | ||
@scenario = current_user.scenarios.find(params[:id]) | ||
@agents = @scenario.agents.preload(:scenarios).page(params[:page]) | ||
|
||
respond_to do |format| | ||
format.html | ||
format.json { render json: @scenario } | ||
end | ||
end | ||
|
||
def share | ||
@scenario = current_user.scenarios.find(params[:id]) | ||
|
||
respond_to do |format| | ||
format.html | ||
format.json { render json: @scenario } | ||
end | ||
end | ||
|
||
def export | ||
@scenario = Scenario.find(params[:id]) | ||
raise ActiveRecord::RecordNotFound unless @scenario.public? || (current_user && current_user.id == @scenario.user_id) | ||
|
||
@exporter = AgentsExporter.new(:name => @scenario.name, | ||
:description => @scenario.description, | ||
:guid => @scenario.guid, | ||
:source_url => @scenario.public? && export_scenario_url(@scenario), | ||
:agents => @scenario.agents) | ||
response.headers['Content-Disposition'] = 'attachment; filename="' + @exporter.filename + '"' | ||
render :json => JSON.pretty_generate(@exporter.as_json) | ||
end | ||
|
||
def edit | ||
@scenario = current_user.scenarios.find(params[:id]) | ||
|
||
respond_to do |format| | ||
format.html | ||
format.json { render json: @scenario } | ||
end | ||
end | ||
|
||
def create | ||
@scenario = current_user.scenarios.build(params[:scenario]) | ||
|
||
respond_to do |format| | ||
if @scenario.save | ||
format.html { redirect_to @scenario, notice: 'This Scenario was successfully created.' } | ||
format.json { render json: @scenario, status: :created, location: @scenario } | ||
else | ||
format.html { render action: "new" } | ||
format.json { render json: @scenario.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
def update | ||
@scenario = current_user.scenarios.find(params[:id]) | ||
|
||
respond_to do |format| | ||
if @scenario.update_attributes(params[:scenario]) | ||
format.html { redirect_to @scenario, notice: 'This Scenario was successfully updated.' } | ||
format.json { head :no_content } | ||
else | ||
format.html { render action: "edit" } | ||
format.json { render json: @scenario.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
def destroy | ||
@scenario = current_user.scenarios.find(params[:id]) | ||
@scenario.destroy | ||
|
||
respond_to do |format| | ||
format.html { redirect_to scenarios_path } | ||
format.json { head :no_content } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.