@@ -119,7 +119,6 @@ GEM |
||
119 | 119 |
formatador (0.2.5) |
120 | 120 |
friendly_id (5.0.4) |
121 | 121 |
activerecord (>= 4.0.0) |
122 |
- geocoder (1.2.6) |
|
123 | 122 |
gherkin (2.12.2) |
124 | 123 |
multi_json (~> 1.3) |
125 | 124 |
gibbon (1.1.4) |
@@ -315,7 +314,6 @@ DEPENDENCIES |
||
315 | 314 |
fog |
316 | 315 |
font-awesome-rails |
317 | 316 |
friendly_id (~> 5.0.0) |
318 |
- geocoder |
|
319 | 317 |
gibbon |
320 | 318 |
jasny_bootstrap_extension_rails |
321 | 319 |
jbuilder (~> 1.2) |
@@ -0,0 +1,3 @@ |
||
1 |
+# Place all the behaviors and hooks related to the matching controller here. |
|
2 |
+# All this logic will automatically be available in application.js. |
|
3 |
+# You can use CoffeeScript in this file: http://coffeescript.org/ |
@@ -0,0 +1,3 @@ |
||
1 |
+// Place all the styles related to the missions controller here. |
|
2 |
+// They will automatically be included in application.css. |
|
3 |
+// You can use Sass (SCSS) here: http://sass-lang.com/ |
@@ -0,0 +1,69 @@ |
||
1 |
+body { |
|
2 |
+ background-color: #fff; |
|
3 |
+ color: #333; |
|
4 |
+ font-family: verdana, arial, helvetica, sans-serif; |
|
5 |
+ font-size: 13px; |
|
6 |
+ line-height: 18px; |
|
7 |
+} |
|
8 |
+ |
|
9 |
+p, ol, ul, td { |
|
10 |
+ font-family: verdana, arial, helvetica, sans-serif; |
|
11 |
+ font-size: 13px; |
|
12 |
+ line-height: 18px; |
|
13 |
+} |
|
14 |
+ |
|
15 |
+pre { |
|
16 |
+ background-color: #eee; |
|
17 |
+ padding: 10px; |
|
18 |
+ font-size: 11px; |
|
19 |
+} |
|
20 |
+ |
|
21 |
+a { |
|
22 |
+ color: #000; |
|
23 |
+ &:visited { |
|
24 |
+ color: #666; |
|
25 |
+ } |
|
26 |
+ &:hover { |
|
27 |
+ color: #fff; |
|
28 |
+ background-color: #000; |
|
29 |
+ } |
|
30 |
+} |
|
31 |
+ |
|
32 |
+div { |
|
33 |
+ &.field, &.actions { |
|
34 |
+ margin-bottom: 10px; |
|
35 |
+ } |
|
36 |
+} |
|
37 |
+ |
|
38 |
+#notice { |
|
39 |
+ color: green; |
|
40 |
+} |
|
41 |
+ |
|
42 |
+.field_with_errors { |
|
43 |
+ padding: 2px; |
|
44 |
+ background-color: red; |
|
45 |
+ display: table; |
|
46 |
+} |
|
47 |
+ |
|
48 |
+#error_explanation { |
|
49 |
+ width: 450px; |
|
50 |
+ border: 2px solid red; |
|
51 |
+ padding: 7px; |
|
52 |
+ padding-bottom: 0; |
|
53 |
+ margin-bottom: 20px; |
|
54 |
+ background-color: #f0f0f0; |
|
55 |
+ h2 { |
|
56 |
+ text-align: left; |
|
57 |
+ font-weight: bold; |
|
58 |
+ padding: 5px 5px 5px 15px; |
|
59 |
+ font-size: 12px; |
|
60 |
+ margin: -7px; |
|
61 |
+ margin-bottom: 0px; |
|
62 |
+ background-color: #c00; |
|
63 |
+ color: #fff; |
|
64 |
+ } |
|
65 |
+ ul li { |
|
66 |
+ font-size: 12px; |
|
67 |
+ list-style: square; |
|
68 |
+ } |
|
69 |
+} |
@@ -0,0 +1,74 @@ |
||
1 |
+class MissionsController < ApplicationController |
|
2 |
+ before_action :set_mission, only: [:show, :edit, :update, :destroy] |
|
3 |
+ |
|
4 |
+ # GET /missions |
|
5 |
+ # GET /missions.json |
|
6 |
+ def index |
|
7 |
+ @missions = Mission.all |
|
8 |
+ end |
|
9 |
+ |
|
10 |
+ # GET /missions/1 |
|
11 |
+ # GET /missions/1.json |
|
12 |
+ def show |
|
13 |
+ end |
|
14 |
+ |
|
15 |
+ # GET /missions/new |
|
16 |
+ def new |
|
17 |
+ @mission = Mission.new |
|
18 |
+ end |
|
19 |
+ |
|
20 |
+ # GET /missions/1/edit |
|
21 |
+ def edit |
|
22 |
+ end |
|
23 |
+ |
|
24 |
+ # POST /missions |
|
25 |
+ # POST /missions.json |
|
26 |
+ def create |
|
27 |
+ @mission = Mission.new(mission_params) |
|
28 |
+ |
|
29 |
+ respond_to do |format| |
|
30 |
+ if @mission.save |
|
31 |
+ format.html { redirect_to @mission, notice: 'Mission was successfully created.' } |
|
32 |
+ format.json { render action: 'show', status: :created, location: @mission } |
|
33 |
+ else |
|
34 |
+ format.html { render action: 'new' } |
|
35 |
+ format.json { render json: @mission.errors, status: :unprocessable_entity } |
|
36 |
+ end |
|
37 |
+ end |
|
38 |
+ end |
|
39 |
+ |
|
40 |
+ # PATCH/PUT /missions/1 |
|
41 |
+ # PATCH/PUT /missions/1.json |
|
42 |
+ def update |
|
43 |
+ respond_to do |format| |
|
44 |
+ if @mission.update(mission_params) |
|
45 |
+ format.html { redirect_to @mission, notice: 'Mission was successfully updated.' } |
|
46 |
+ format.json { head :no_content } |
|
47 |
+ else |
|
48 |
+ format.html { render action: 'edit' } |
|
49 |
+ format.json { render json: @mission.errors, status: :unprocessable_entity } |
|
50 |
+ end |
|
51 |
+ end |
|
52 |
+ end |
|
53 |
+ |
|
54 |
+ # DELETE /missions/1 |
|
55 |
+ # DELETE /missions/1.json |
|
56 |
+ def destroy |
|
57 |
+ @mission.destroy |
|
58 |
+ respond_to do |format| |
|
59 |
+ format.html { redirect_to missions_url } |
|
60 |
+ format.json { head :no_content } |
|
61 |
+ end |
|
62 |
+ end |
|
63 |
+ |
|
64 |
+ private |
|
65 |
+ # Use callbacks to share common setup or constraints between actions. |
|
66 |
+ def set_mission |
|
67 |
+ @mission = Mission.find(params[:id]) |
|
68 |
+ end |
|
69 |
+ |
|
70 |
+ # Never trust parameters from the scary internet, only allow the white list through. |
|
71 |
+ def mission_params |
|
72 |
+ params.require(:mission).permit(:mission_agents_id, :title, :objective, :briefing, :owner_id, :status, :launched, :language, :cover_img) |
|
73 |
+ end |
|
74 |
+end |
@@ -0,0 +1,2 @@ |
||
1 |
+module MissionsHelper |
|
2 |
+end |
@@ -0,0 +1,6 @@ |
||
1 |
+class Mission < ActiveRecord::Base |
|
2 |
+ belongs_to :owner, :class_name => "User" |
|
3 |
+ has_many :mission_agents, :dependent => :destroy |
|
4 |
+ has_many :agent_steps, :through => :mission_agents |
|
5 |
+ accepts_nested_attributes_for :mission_agents, allow_destroy:true |
|
6 |
+end |
@@ -0,0 +1,19 @@ |
||
1 |
+<%= simple_form_for(@mission) do |f| %> |
|
2 |
+ <%= f.error_notification %> |
|
3 |
+ |
|
4 |
+ <div class="form-inputs"> |
|
5 |
+ <%= f.association :mission_agents %> |
|
6 |
+ <%= f.input :title %> |
|
7 |
+ <%= f.input :objective %> |
|
8 |
+ <%= f.input :briefing %> |
|
9 |
+ <%= f.association :owner %> |
|
10 |
+ <%= f.input :status %> |
|
11 |
+ <%= f.input :launched %> |
|
12 |
+ <%= f.input :language %> |
|
13 |
+ <%= f.input :cover_img %> |
|
14 |
+ </div> |
|
15 |
+ |
|
16 |
+ <div class="form-actions"> |
|
17 |
+ <%= f.button :submit %> |
|
18 |
+ </div> |
|
19 |
+<% end %> |
@@ -0,0 +1,6 @@ |
||
1 |
+<h1>Editing mission</h1> |
|
2 |
+ |
|
3 |
+<%= render 'form' %> |
|
4 |
+ |
|
5 |
+<%= link_to 'Show', @mission %> | |
|
6 |
+<%= link_to 'Back', missions_path %> |
@@ -0,0 +1,43 @@ |
||
1 |
+<h1>Listing missions</h1> |
|
2 |
+ |
|
3 |
+<table> |
|
4 |
+ <thead> |
|
5 |
+ <tr> |
|
6 |
+ <th>Mission agents</th> |
|
7 |
+ <th>Title</th> |
|
8 |
+ <th>Objective</th> |
|
9 |
+ <th>Briefing</th> |
|
10 |
+ <th>Owner</th> |
|
11 |
+ <th>Status</th> |
|
12 |
+ <th>Launched</th> |
|
13 |
+ <th>Language</th> |
|
14 |
+ <th>Cover img</th> |
|
15 |
+ <th></th> |
|
16 |
+ <th></th> |
|
17 |
+ <th></th> |
|
18 |
+ </tr> |
|
19 |
+ </thead> |
|
20 |
+ |
|
21 |
+ <tbody> |
|
22 |
+ <% @missions.each do |mission| %> |
|
23 |
+ <tr> |
|
24 |
+ <td><%= mission.mission_agents %></td> |
|
25 |
+ <td><%= mission.title %></td> |
|
26 |
+ <td><%= mission.objective %></td> |
|
27 |
+ <td><%= mission.briefing %></td> |
|
28 |
+ <td><%= mission.owner %></td> |
|
29 |
+ <td><%= mission.status %></td> |
|
30 |
+ <td><%= mission.launched %></td> |
|
31 |
+ <td><%= mission.language %></td> |
|
32 |
+ <td><%= mission.cover_img %></td> |
|
33 |
+ <td><%= link_to 'Show', mission %></td> |
|
34 |
+ <td><%= link_to 'Edit', edit_mission_path(mission) %></td> |
|
35 |
+ <td><%= link_to 'Destroy', mission, method: :delete, data: { confirm: 'Are you sure?' } %></td> |
|
36 |
+ </tr> |
|
37 |
+ <% end %> |
|
38 |
+ </tbody> |
|
39 |
+</table> |
|
40 |
+ |
|
41 |
+<br> |
|
42 |
+ |
|
43 |
+<%= link_to 'New Mission', new_mission_path %> |
@@ -0,0 +1,4 @@ |
||
1 |
+json.array!(@missions) do |mission| |
|
2 |
+ json.extract! mission, :id, :mission_agents_id, :title, :objective, :briefing, :owner_id, :status, :launched, :language, :cover_img |
|
3 |
+ json.url mission_url(mission, format: :json) |
|
4 |
+end |
@@ -0,0 +1,5 @@ |
||
1 |
+<h1>New mission</h1> |
|
2 |
+ |
|
3 |
+<%= render 'form' %> |
|
4 |
+ |
|
5 |
+<%= link_to 'Back', missions_path %> |
@@ -0,0 +1,49 @@ |
||
1 |
+<p id="notice"><%= notice %></p> |
|
2 |
+ |
|
3 |
+<p> |
|
4 |
+ <strong>Mission agents:</strong> |
|
5 |
+ <%= @mission.mission_agents %> |
|
6 |
+</p> |
|
7 |
+ |
|
8 |
+<p> |
|
9 |
+ <strong>Title:</strong> |
|
10 |
+ <%= @mission.title %> |
|
11 |
+</p> |
|
12 |
+ |
|
13 |
+<p> |
|
14 |
+ <strong>Objective:</strong> |
|
15 |
+ <%= @mission.objective %> |
|
16 |
+</p> |
|
17 |
+ |
|
18 |
+<p> |
|
19 |
+ <strong>Briefing:</strong> |
|
20 |
+ <%= @mission.briefing %> |
|
21 |
+</p> |
|
22 |
+ |
|
23 |
+<p> |
|
24 |
+ <strong>Owner:</strong> |
|
25 |
+ <%= @mission.owner %> |
|
26 |
+</p> |
|
27 |
+ |
|
28 |
+<p> |
|
29 |
+ <strong>Status:</strong> |
|
30 |
+ <%= @mission.status %> |
|
31 |
+</p> |
|
32 |
+ |
|
33 |
+<p> |
|
34 |
+ <strong>Launched:</strong> |
|
35 |
+ <%= @mission.launched %> |
|
36 |
+</p> |
|
37 |
+ |
|
38 |
+<p> |
|
39 |
+ <strong>Language:</strong> |
|
40 |
+ <%= @mission.language %> |
|
41 |
+</p> |
|
42 |
+ |
|
43 |
+<p> |
|
44 |
+ <strong>Cover img:</strong> |
|
45 |
+ <%= @mission.cover_img %> |
|
46 |
+</p> |
|
47 |
+ |
|
48 |
+<%= link_to 'Edit', edit_mission_path(@mission) %> | |
|
49 |
+<%= link_to 'Back', missions_path %> |
@@ -0,0 +1 @@ |
||
1 |
+json.extract! @mission, :id, :mission_agents_id, :title, :objective, :briefing, :owner_id, :status, :launched, :language, :cover_img, :created_at, :updated_at |
@@ -1,5 +1,7 @@ |
||
1 | 1 |
Avalanche2::Application.routes.draw do |
2 | 2 |
|
3 |
+ resources :missions |
|
4 |
+ |
|
3 | 5 |
root 'start#index' |
4 | 6 |
|
5 | 7 |
get '/change_locale/:locale', to: 'settings#change_locale', as: :change_locale |
@@ -0,0 +1,17 @@ |
||
1 |
+class CreateMissions < ActiveRecord::Migration |
|
2 |
+ def change |
|
3 |
+ create_table :missions do |t| |
|
4 |
+ t.references :mission_agents, index: true |
|
5 |
+ t.string :title |
|
6 |
+ t.string :objective |
|
7 |
+ t.text :briefing |
|
8 |
+ t.references :owner, index: true |
|
9 |
+ t.integer :status |
|
10 |
+ t.boolean :launched |
|
11 |
+ t.string :language |
|
12 |
+ t.string :cover_img |
|
13 |
+ |
|
14 |
+ t.timestamps |
|
15 |
+ end |
|
16 |
+ end |
|
17 |
+end |
@@ -11,7 +11,7 @@ |
||
11 | 11 |
# |
12 | 12 |
# It's strongly recommended that you check this file into your version control system. |
13 | 13 |
|
14 |
-ActiveRecord::Schema.define(version: 20150110020743) do |
|
14 |
+ActiveRecord::Schema.define(version: 20150121033648) do |
|
15 | 15 |
|
16 | 16 |
# These are extensions that must be enabled in order to support this database |
17 | 17 |
enable_extension "plpgsql" |
@@ -73,6 +73,23 @@ ActiveRecord::Schema.define(version: 20150110020743) do |
||
73 | 73 |
t.string "server_email" |
74 | 74 |
end |
75 | 75 |
|
76 |
+ create_table "missions", force: true do |t| |
|
77 |
+ t.integer "mission_agents_id" |
|
78 |
+ t.string "title" |
|
79 |
+ t.string "objective" |
|
80 |
+ t.text "briefing" |
|
81 |
+ t.integer "owner_id" |
|
82 |
+ t.integer "status" |
|
83 |
+ t.boolean "launched" |
|
84 |
+ t.string "language" |
|
85 |
+ t.string "cover_img" |
|
86 |
+ t.datetime "created_at" |
|
87 |
+ t.datetime "updated_at" |
|
88 |
+ end |
|
89 |
+ |
|
90 |
+ add_index "missions", ["mission_agents_id"], name: "index_missions_on_mission_agents_id", using: :btree |
|
91 |
+ add_index "missions", ["owner_id"], name: "index_missions_on_owner_id", using: :btree |
|
92 |
+ |
|
76 | 93 |
create_table "subscriptions", force: true do |t| |
77 | 94 |
t.string "first_name" |
78 | 95 |
t.string "last_name" |
@@ -0,0 +1,49 @@ |
||
1 |
+require 'test_helper' |
|
2 |
+ |
|
3 |
+class MissionsControllerTest < ActionController::TestCase |
|
4 |
+ setup do |
|
5 |
+ @mission = missions(:one) |
|
6 |
+ end |
|
7 |
+ |
|
8 |
+ test "should get index" do |
|
9 |
+ get :index |
|
10 |
+ assert_response :success |
|
11 |
+ assert_not_nil assigns(:missions) |
|
12 |
+ end |
|
13 |
+ |
|
14 |
+ test "should get new" do |
|
15 |
+ get :new |
|
16 |
+ assert_response :success |
|
17 |
+ end |
|
18 |
+ |
|
19 |
+ test "should create mission" do |
|
20 |
+ assert_difference('Mission.count') do |
|
21 |
+ post :create, mission: { briefing: @mission.briefing, cover_img: @mission.cover_img, language: @mission.language, launched: @mission.launched, mission_agents_id: @mission.mission_agents_id, objective: @mission.objective, owner_id: @mission.owner_id, status: @mission.status, title: @mission.title } |
|
22 |
+ end |
|
23 |
+ |
|
24 |
+ assert_redirected_to mission_path(assigns(:mission)) |
|
25 |
+ end |
|
26 |
+ |
|
27 |
+ test "should show mission" do |
|
28 |
+ get :show, id: @mission |
|
29 |
+ assert_response :success |
|
30 |
+ end |
|
31 |
+ |
|
32 |
+ test "should get edit" do |
|
33 |
+ get :edit, id: @mission |
|
34 |
+ assert_response :success |
|
35 |
+ end |
|
36 |
+ |
|
37 |
+ test "should update mission" do |
|
38 |
+ patch :update, id: @mission, mission: { briefing: @mission.briefing, cover_img: @mission.cover_img, language: @mission.language, launched: @mission.launched, mission_agents_id: @mission.mission_agents_id, objective: @mission.objective, owner_id: @mission.owner_id, status: @mission.status, title: @mission.title } |
|
39 |
+ assert_redirected_to mission_path(assigns(:mission)) |
|
40 |
+ end |
|
41 |
+ |
|
42 |
+ test "should destroy mission" do |
|
43 |
+ assert_difference('Mission.count', -1) do |
|
44 |
+ delete :destroy, id: @mission |
|
45 |
+ end |
|
46 |
+ |
|
47 |
+ assert_redirected_to missions_path |
|
48 |
+ end |
|
49 |
+end |
@@ -0,0 +1,23 @@ |
||
1 |
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html |
|
2 |
+ |
|
3 |
+one: |
|
4 |
+ mission_agents_id: |
|
5 |
+ title: MyString |
|
6 |
+ objective: MyString |
|
7 |
+ briefing: MyText |
|
8 |
+ owner_id: |
|
9 |
+ status: 1 |
|
10 |
+ launched: false |
|
11 |
+ language: MyString |
|
12 |
+ cover_img: MyString |
|
13 |
+ |
|
14 |
+two: |
|
15 |
+ mission_agents_id: |
|
16 |
+ title: MyString |
|
17 |
+ objective: MyString |
|
18 |
+ briefing: MyText |
|
19 |
+ owner_id: |
|
20 |
+ status: 1 |
|
21 |
+ launched: false |
|
22 |
+ language: MyString |
|
23 |
+ cover_img: MyString |
@@ -0,0 +1,4 @@ |
||
1 |
+require 'test_helper' |
|
2 |
+ |
|
3 |
+class MissionsHelperTest < ActionView::TestCase |
|
4 |
+end |
@@ -0,0 +1,7 @@ |
||
1 |
+require 'test_helper' |
|
2 |
+ |
|
3 |
+class MissionTest < ActiveSupport::TestCase |
|
4 |
+ # test "the truth" do |
|
5 |
+ # assert true |
|
6 |
+ # end |
|
7 |
+end |