Mission validation models scafolding and agent details steps layout

James Peret 10 年 前
コミット
572447eb40
共有32 個のファイルを変更した268 個の追加60 個の削除を含む
  1. 8 0
      app/assets/javascripts/missions.js
  2. 0 7
      app/assets/javascripts/missions.js.coffee
  3. 30 5
      app/assets/stylesheets/avalanche_theme.css.less
  4. 0 1
      app/assets/stylesheets/missions.css.less
  5. 1 0
      app/models/agent_step.rb
  6. 5 0
      app/models/step_submission.rb
  7. 2 0
      app/models/step_validation.rb
  8. 0 3
      app/models/step_verification.rb
  9. 4 0
      app/models/submission_content.rb
  10. 5 0
      app/models/submission_text.rb
  11. 3 0
      app/models/validation_text.rb
  12. 24 0
      app/views/missions/_step_submission.html.erb
  13. 11 5
      app/views/missions/show_agent_details.html.erb
  14. 1 1
      app/views/missions/show_agents.html.erb
  15. 0 12
      db/migrate/20150121035726_create_step_verifications.rb
  16. 5 0
      db/migrate/20150218012027_add_step_submission_to_agent_step.rb
  17. 2 3
      db/migrate/20150121035550_create_step_validations.rb
  18. 11 0
      db/migrate/20150218012317_create_validation_texts.rb
  19. 13 0
      db/migrate/20150218012402_create_step_submissions.rb
  20. 11 0
      db/migrate/20150218012416_create_submission_contents.rb
  21. 12 0
      db/migrate/20150218012557_create_submission_texts.rb
  22. 46 7
      db/schema.rb
  23. 5 1
      readme.md
  24. 15 0
      test/fixtures/step_submissions.yml
  25. 6 8
      test/fixtures/step_validations.yml
  26. 11 0
      test/fixtures/submission_contents.yml
  27. 13 0
      test/fixtures/submission_texts.yml
  28. 2 6
      test/fixtures/step_verifications.yml
  29. 1 1
      test/models/step_verification_test.rb
  30. 7 0
      test/models/submission_content_test.rb
  31. 7 0
      test/models/submission_text_test.rb
  32. 7 0
      test/models/validation_text_test.rb

+ 8 - 0
app/assets/javascripts/missions.js

@@ -0,0 +1,8 @@
1
+# Missions JS
2
+
3
+function attachHandler(jQuery) {
4
+	
5
+}
6
+
7
+$(document).ready(attachHandler);
8
+$(document).load(attachHandler);

+ 0 - 7
app/assets/javascripts/missions.js.coffee

@@ -1,7 +0,0 @@
1
-# Missions JS
2
-
3
-attachRatingHandler = ->
4
-
5
-    
6
-$(document).ready attachRatingHandler
7
-$(document).on "page:load", attachRatingHandler

+ 30 - 5
app/assets/stylesheets/avalanche_theme.css.less

@@ -307,16 +307,27 @@ h4 {
307 307
 .panel {
308 308
 	.panel-heading {
309 309
 		background-color: @light-gray;
310
-		height: 42px;
311
-		.theme-box-padding;
312
-		
310
+		height: 32px;
311
+		.theme-box-padding;	
312
+	}
313
+	.panel-heading.panel-divider {
314
+		border-top: @theme-border;
315
+		border-bottom: @theme-border;
316
+		height: 32px;
317
+		margin-bottom: -2px;
318
+		background-color: @white;
319
+		.caret { margin-top: 16px; margin-left: 5px; margin-right: 5px; }
313 320
 	}
314 321
 	.panel-title {
315 322
 		margin-top: 0px;
316 323
 		margin-bottom: 0px;
317 324
 		.task-text {
325
+			font-family: Avenir-Medium;
318 326
 			font-size: 18px;
319
-			padding-top: 8px;
327
+			color: #000000;
328
+			line-height: 25px;
329
+			padding-top: 6px;
330
+			font-weight: 200;
320 331
 		}
321 332
 		.caret {
322 333
 			float: left;
@@ -324,16 +335,30 @@ h4 {
324 335
 			margin-right: 5px;
325 336
 			margin-left: 5px;
326 337
 		}
338
+		.task-number { line-height: 36px;}
339
+		.task-icon { padding-top: 7px }
340
+		.task-icon i { color: @black }
327 341
 	}
328 342
 	.panel-body {
329 343
 		.panel-content {
330
-			.theme-box-padding;
344
+			.panel-text {
345
+				font-family: Avenir-Light;
346
+				font-size: 18px;
347
+				color: #1D1D26;
348
+				line-height: 26px;
349
+				.theme-box-padding;
350
+			}
351
+		}
352
+		.accordion {
353
+			margin-bottom: 0px;
331 354
 		}
332 355
 	}
333 356
 	.panel-body.in { border-top: @theme-border; }
334 357
 	.panel-footer {}
335 358
 } 
336 359
 
360
+// Overrides
361
+.accordion-inner { padding: 0px; }
337 362
 
338 363
 // Footer
339 364
 

+ 0 - 1
app/assets/stylesheets/missions.css.less

@@ -217,7 +217,6 @@
217 217
 
218 218
 .task-icon {
219 219
 	font-size: 24px;
220
-	float: right;
221 220
 	padding-top: 13px;
222 221
 }
223 222
 

+ 1 - 0
app/models/agent_step.rb

@@ -1,4 +1,5 @@
1 1
 class AgentStep < ActiveRecord::Base
2 2
   belongs_to :mission_agent
3 3
   has_many :step_validations
4
+  has_many :step_submissions
4 5
 end

+ 5 - 0
app/models/step_submission.rb

@@ -0,0 +1,5 @@
1
+class StepSubmission < ActiveRecord::Base
2
+  belongs_to :agent_step  
3
+  belongs_to :validated_by, :class_name => "User"
4
+  has_many :submission_contents
5
+end

+ 2 - 0
app/models/step_validation.rb

@@ -1,3 +1,5 @@
1 1
 class StepValidation < ActiveRecord::Base
2 2
   belongs_to :agent_step
3
+  has_many :submission_contents
4
+  belongs_to :validation, polymorphic: true
3 5
 end

+ 0 - 3
app/models/step_verification.rb

@@ -1,3 +0,0 @@
1
-class StepVerification < ActiveRecord::Base
2
-  belongs_to :validated_by, :class_name => "User"
3
-end

+ 4 - 0
app/models/submission_content.rb

@@ -0,0 +1,4 @@
1
+class SubmissionContent < ActiveRecord::Base
2
+  belongs_to :agent_step
3
+  belongs_to :submission, polymorphic: true
4
+end

+ 5 - 0
app/models/submission_text.rb

@@ -0,0 +1,5 @@
1
+class SubmissionText < ActiveRecord::Base
2
+  belongs_to :submission_content
3
+  has_one :submission_content, as: :submission, dependent: :destroy
4
+  belongs_to :validation
5
+end

+ 3 - 0
app/models/validation_text.rb

@@ -0,0 +1,3 @@
1
+class ValidationText < ActiveRecord::Base
2
+  has_one :step_validation, as: :validation, dependent: :destroy
3
+end

+ 24 - 0
app/views/missions/_step_submission.html.erb

@@ -0,0 +1,24 @@
1
+<% submission_id = 'collapse_step_' + step.step.to_s + '_validations' %>
2
+<%= content_tag(:div, class: 'panel-group accordion', id: submission_id) do %>
3
+	<% step.step_validations.each do |validation| %>
4
+		<% validation_id = 'collapse_validation_' + validation.id.to_s %>
5
+		<%= content_tag(:div, class: 'panel-heading panel-divider') do %>
6
+			<%= content_tag(:div, class: 'panel-title') do %>
7
+				<%= link_to(('#'+ validation_id), class: 'accordion-toggle', :data => {toggle: 'collapse', parent: submission_id}) do %>
8
+					<%= content_tag(:span, '<i class="fa fa-picture-o"></i>'.html_safe, class: 'task-icon pull-left') %>
9
+					<%= content_tag(:span, '', class: 'caret caret-center') %>
10
+					<%= content_tag(:span, (step.step_validations.first != nil ? step.step_validations.first.validation.description : 'test'), class: 'task-text') %>
11
+				<% end %>
12
+				
13
+			<% end %>
14
+		<% end %>
15
+		<%= content_tag(:div, class: 'panel-body collapse', id: validation_id) do %>
16
+			<%= content_tag(:div, class: 'panel-content') do %>
17
+				<%= content_tag(:div, class: "panel-text") do %>
18
+					<p>sdfsdfsdfsdfdsf</p>
19
+				<% end %>
20
+			<% end %>
21
+		<% end %>
22
+	<% end %>
23
+<% end %>
24
+

+ 11 - 5
app/views/missions/show_agent_details.html.erb

@@ -71,12 +71,12 @@
71 71
 		<% end %>
72 72
 	<% end %>
73 73
 	<%= content_tag(:div, class: 'row') do %>
74
-		<%= content_tag(:div, class: 'span12 accordion', id: 'colapse_steps') do %>
74
+		<%= content_tag(:div, class: 'span12 panel-group accordion', id: 'colapse_steps') do %>
75 75
 			<%= content_tag(:h4, ((t 'agent.tasks') + ':') ) %>
76 76
 			<% # Steps %>
77 77
 			<% @agent.agent_steps.order('step ASC').each do |step| %>
78
-				<%= content_tag(:div, class: 'panel panel-default accordion-group') do %>
79
-					<%= content_tag(:div, class: 'panel-heading accordion-heading') do %>
78
+				<%= content_tag(:div, class: 'panel panel-default') do %>
79
+					<%= content_tag(:div, class: 'panel-heading') do %>
80 80
 						<%= content_tag(:h3, class: 'panel-title') do %>
81 81
 							<%= content_tag(:span, step.step, class: 'task-number') %>
82 82
 							<a class="accordion-toggle" data-toggle="collapse" data-parent="#colapse_steps" href="#collapse_step_<%= step.step %>">
@@ -86,8 +86,14 @@
86 86
 							
87 87
 						<% end %>
88 88
 					<% end %>
89
-					<%= content_tag(:div, class: 'panel-body accordion-body collapse', id: ('collapse_step_'+ step.step.to_s)) do %>
90
-						<div class="panel-content accordion-inner">dsfsdfsdfsdfsdf</div>
89
+					<%= content_tag(:div, class: 'panel-body collapse', id: ('collapse_step_'+ step.step.to_s)) do %>
90
+						<%= content_tag(:div, class: "panel-content") do %>
91
+							<%= content_tag(:div, class: "panel-text") do %>
92
+								<%= step.description.html_safe %>
93
+							<% end %>
94
+							<%= render :partial => 'step_submission', locals: {step: step} %>
95
+							
96
+						<% end %>
91 97
 					<% end %>
92 98
 				<% end %>
93 99
 			<% end %>

+ 1 - 1
app/views/missions/show_agents.html.erb

@@ -44,7 +44,7 @@
44 44
 										<%= content_tag(:p) do %>
45 45
 											<%= content_tag(:span, step.step, class: 'task-number') %>
46 46
 											<%= content_tag(:span, step.title, class: 'task-text') %>
47
-											<%= content_tag(:span, '<i class="fa fa-picture-o"></i>'.html_safe, class: 'task-icon') %>
47
+											<%= content_tag(:span, '<i class="fa fa-picture-o"></i>'.html_safe, class: 'task-icon pull-right') %>
48 48
 										<% end %>
49 49
 									<% end %>
50 50
 								<% else %>

+ 0 - 12
db/migrate/20150121035726_create_step_verifications.rb

@@ -1,12 +0,0 @@
1
-class CreateStepVerifications < ActiveRecord::Migration
2
-  def change
3
-    create_table :step_verifications do |t|
4
-      t.references :step_validation, index: true
5
-      t.boolean :validated
6
-      t.references :validated_by, index: true
7
-      t.string :content
8
-
9
-      t.timestamps
10
-    end
11
-  end
12
-end

+ 5 - 0
db/migrate/20150218012027_add_step_submission_to_agent_step.rb

@@ -0,0 +1,5 @@
1
+class AddStepSubmissionToAgentStep < ActiveRecord::Migration
2
+  def change
3
+    add_reference :agent_steps, :step_submissions, index: true
4
+  end
5
+end

+ 2 - 3
db/migrate/20150121035550_create_step_validations.rb

@@ -2,9 +2,8 @@ class CreateStepValidations < ActiveRecord::Migration
2 2
   def change
3 3
     create_table :step_validations do |t|
4 4
       t.references :agent_step, index: true
5
-      t.references :step_verifications, index: true
6
-      t.string :mode
7
-      t.string :description
5
+      t.integer :validation_id
6
+      t.string :validation_type
8 7
 
9 8
       t.timestamps
10 9
     end

+ 11 - 0
db/migrate/20150218012317_create_validation_texts.rb

@@ -0,0 +1,11 @@
1
+class CreateValidationTexts < ActiveRecord::Migration
2
+  def change
3
+    create_table :validation_texts do |t|
4
+      t.references :step_validation, index: true
5
+      t.references :submission_text, index: true
6
+      t.string :description
7
+
8
+      t.timestamps
9
+    end
10
+  end
11
+end

+ 13 - 0
db/migrate/20150218012402_create_step_submissions.rb

@@ -0,0 +1,13 @@
1
+class CreateStepSubmissions < ActiveRecord::Migration
2
+  def change
3
+    create_table :step_submissions do |t|
4
+      t.references :agent_step, index: true
5
+      t.references :submission_contents, index: true
6
+      t.boolean :validated
7
+      t.references :validated_by, index: true
8
+      t.datetime :date_validated
9
+
10
+      t.timestamps
11
+    end
12
+  end
13
+end

+ 11 - 0
db/migrate/20150218012416_create_submission_contents.rb

@@ -0,0 +1,11 @@
1
+class CreateSubmissionContents < ActiveRecord::Migration
2
+  def change
3
+    create_table :submission_contents do |t|
4
+      t.references :submission_content, index: true
5
+      t.integer :submission_id
6
+      t.string :submission_type
7
+
8
+      t.timestamps
9
+    end
10
+  end
11
+end

+ 12 - 0
db/migrate/20150218012557_create_submission_texts.rb

@@ -0,0 +1,12 @@
1
+class CreateSubmissionTexts < ActiveRecord::Migration
2
+  def change
3
+    create_table :submission_texts do |t|
4
+      t.references :submission_content, index: true
5
+      t.string :content
6
+      t.boolean :accepted
7
+      t.references :validation, index: true
8
+
9
+      t.timestamps
10
+    end
11
+  end
12
+end

+ 46 - 7
db/schema.rb

@@ -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: 20150217035951) do
14
+ActiveRecord::Schema.define(version: 20150218012557) do
15 15
 
16 16
   # These are extensions that must be enabled in order to support this database
17 17
   enable_extension "plpgsql"
@@ -25,9 +25,11 @@ ActiveRecord::Schema.define(version: 20150217035951) do
25 25
     t.datetime "completed_date"
26 26
     t.datetime "created_at"
27 27
     t.datetime "updated_at"
28
+    t.integer  "step_submissions_id"
28 29
   end
29 30
 
30 31
   add_index "agent_steps", ["mission_agent_id"], name: "index_agent_steps_on_mission_agent_id", using: :btree
32
+  add_index "agent_steps", ["step_submissions_id"], name: "index_agent_steps_on_step_submissions_id", using: :btree
31 33
 
32 34
   create_table "blog_posts", force: true do |t|
33 35
     t.string   "title"
@@ -138,25 +140,51 @@ ActiveRecord::Schema.define(version: 20150217035951) do
138 140
   add_index "missions", ["mission_agents_id"], name: "index_missions_on_mission_agents_id", using: :btree
139 141
   add_index "missions", ["owner_id"], name: "index_missions_on_owner_id", using: :btree
140 142
 
143
+  create_table "step_submissions", force: true do |t|
144
+    t.integer  "agent_step_id"
145
+    t.integer  "submission_contents_id"
146
+    t.boolean  "validated"
147
+    t.integer  "validated_by_id"
148
+    t.datetime "date_validated"
149
+    t.datetime "created_at"
150
+    t.datetime "updated_at"
151
+  end
152
+
153
+  add_index "step_submissions", ["agent_step_id"], name: "index_step_submissions_on_agent_step_id", using: :btree
154
+  add_index "step_submissions", ["submission_contents_id"], name: "index_step_submissions_on_submission_contents_id", using: :btree
155
+  add_index "step_submissions", ["validated_by_id"], name: "index_step_submissions_on_validated_by_id", using: :btree
156
+
141 157
   create_table "step_validations", force: true do |t|
142 158
     t.integer  "agent_step_id"
143
-    t.string   "mode"
144
-    t.string   "description"
159
+    t.integer  "validation_id"
160
+    t.string   "validation_type"
145 161
     t.datetime "created_at"
146 162
     t.datetime "updated_at"
147 163
   end
148 164
 
149 165
   add_index "step_validations", ["agent_step_id"], name: "index_step_validations_on_agent_step_id", using: :btree
150 166
 
151
-  create_table "step_verifications", force: true do |t|
152
-    t.boolean  "validated"
153
-    t.integer  "validated_by_id"
167
+  create_table "submission_contents", force: true do |t|
168
+    t.integer  "submission_content_id"
169
+    t.integer  "submission_id"
170
+    t.string   "submission_type"
171
+    t.datetime "created_at"
172
+    t.datetime "updated_at"
173
+  end
174
+
175
+  add_index "submission_contents", ["submission_content_id"], name: "index_submission_contents_on_submission_content_id", using: :btree
176
+
177
+  create_table "submission_texts", force: true do |t|
178
+    t.integer  "submission_content_id"
154 179
     t.string   "content"
180
+    t.boolean  "accepted"
181
+    t.integer  "validation_id"
155 182
     t.datetime "created_at"
156 183
     t.datetime "updated_at"
157 184
   end
158 185
 
159
-  add_index "step_verifications", ["validated_by_id"], name: "index_step_verifications_on_validated_by_id", using: :btree
186
+  add_index "submission_texts", ["submission_content_id"], name: "index_submission_texts_on_submission_content_id", using: :btree
187
+  add_index "submission_texts", ["validation_id"], name: "index_submission_texts_on_validation_id", using: :btree
160 188
 
161 189
   create_table "subscriptions", force: true do |t|
162 190
     t.string   "first_name"
@@ -202,4 +230,15 @@ ActiveRecord::Schema.define(version: 20150217035951) do
202 230
   add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree
203 231
   add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree
204 232
 
233
+  create_table "validation_texts", force: true do |t|
234
+    t.integer  "step_validation_id"
235
+    t.integer  "submission_text_id"
236
+    t.string   "description"
237
+    t.datetime "created_at"
238
+    t.datetime "updated_at"
239
+  end
240
+
241
+  add_index "validation_texts", ["step_validation_id"], name: "index_validation_texts_on_step_validation_id", using: :btree
242
+  add_index "validation_texts", ["submission_text_id"], name: "index_validation_texts_on_submission_text_id", using: :btree
243
+
205 244
 end

+ 5 - 1
readme.md

@@ -99,7 +99,7 @@ rails g model step_submission agent_step:reference submission_contents:reference
99 99
 rails g model submission_content submission_content:references submission_id:integer submission_type
100 100
 
101 101
 # Text Submission
102
-rails g model submission_text submission_content:references content
102
+rails g model submission_text submission_content:references content accepted:boolean validation:references
103 103
 
104 104
 ```
105 105
 
@@ -144,3 +144,7 @@ Each step can have multiple step validations that are set by the mission directo
144 144
 The *submission_content* class is also responsible for triggering the automatic validation that some *step_validations* might have. If the validation requires an operator decision, than the *step_submission* will show up on the mission control panel for manual validation. If the step can be automatic validated, than the system will create a *step_verification* for the current submission.
145 145
 
146 146
 ----------------------
147
+
148
+Enviar imagens com os desenhos
149
+Enviar uma imagem para cada tela do app
150
+Espere a validação pelo diretor da missão

+ 15 - 0
test/fixtures/step_submissions.yml

@@ -0,0 +1,15 @@
1
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2
+
3
+one:
4
+  agent_step_id: 
5
+  submission_contents_id: 
6
+  validated: false
7
+  validated_by_id: 
8
+  date_validated: 2015-02-17 23:24:02
9
+
10
+two:
11
+  agent_step_id: 
12
+  submission_contents_id: 
13
+  validated: false
14
+  validated_by_id: 
15
+  date_validated: 2015-02-17 23:24:02

+ 6 - 8
test/fixtures/step_validations.yml

@@ -1,13 +1,11 @@
1 1
 # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2 2
 
3 3
 one:
4
-  agent_step: 
5
-  step_verifications_id: 
6
-  mode: MyString
7
-  description: MyString
4
+  agent_step_id: 
5
+  validation_id: 1
6
+  validation_type: MyString
8 7
 
9 8
 two:
10
-  agent_step: 
11
-  step_verifications_id: 
12
-  mode: MyString
13
-  description: MyString
9
+  agent_step_id: 
10
+  validation_id: 1
11
+  validation_type: MyString

+ 11 - 0
test/fixtures/submission_contents.yml

@@ -0,0 +1,11 @@
1
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2
+
3
+one:
4
+  submission_content_id: 
5
+  submission_id: 1
6
+  submission_type: MyString
7
+
8
+two:
9
+  submission_content_id: 
10
+  submission_id: 1
11
+  submission_type: MyString

+ 13 - 0
test/fixtures/submission_texts.yml

@@ -0,0 +1,13 @@
1
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2
+
3
+one:
4
+  submission_content_id: 
5
+  content: MyString
6
+  accepted: false
7
+  validation_id: 
8
+
9
+two:
10
+  submission_content_id: 
11
+  content: MyString
12
+  accepted: false
13
+  validation_id: 

+ 2 - 6
test/fixtures/step_verifications.yml

@@ -2,12 +2,8 @@
2 2
 
3 3
 one:
4 4
   step_validation_id: 
5
-  validated: false
6
-  validated_by_id: 
7
-  content: MyString
5
+  description: MyString
8 6
 
9 7
 two:
10 8
   step_validation_id: 
11
-  validated: false
12
-  validated_by_id: 
13
-  content: MyString
9
+  description: MyString

+ 1 - 1
test/models/step_verification_test.rb

@@ -1,6 +1,6 @@
1 1
 require 'test_helper'
2 2
 
3
-class StepVerificationTest < ActiveSupport::TestCase
3
+class StepSubmissionTest < ActiveSupport::TestCase
4 4
   # test "the truth" do
5 5
   #   assert true
6 6
   # end

+ 7 - 0
test/models/submission_content_test.rb

@@ -0,0 +1,7 @@
1
+require 'test_helper'
2
+
3
+class SubmissionContentTest < ActiveSupport::TestCase
4
+  # test "the truth" do
5
+  #   assert true
6
+  # end
7
+end

+ 7 - 0
test/models/submission_text_test.rb

@@ -0,0 +1,7 @@
1
+require 'test_helper'
2
+
3
+class SubmissionTextTest < ActiveSupport::TestCase
4
+  # test "the truth" do
5
+  #   assert true
6
+  # end
7
+end

+ 7 - 0
test/models/validation_text_test.rb

@@ -0,0 +1,7 @@
1
+require 'test_helper'
2
+
3
+class ValidationTextTest < ActiveSupport::TestCase
4
+  # test "the truth" do
5
+  #   assert true
6
+  # end
7
+end