@@ -18,6 +18,7 @@ rerun.txt |
||
18 | 18 |
pickle-email-*.html |
19 | 19 |
|
20 | 20 |
public/svg/ |
21 |
+public/images/ |
|
21 | 22 |
|
22 | 23 |
# TODO Comment out these rules if you are OK with secrets being uploaded to the repo |
23 | 24 |
#config/initializers/secret_token.rb |
@@ -165,8 +165,27 @@ |
||
165 | 165 |
margin-bottom: 15px; |
166 | 166 |
} |
167 | 167 |
|
168 |
+.reward-image { |
|
169 |
+ text-align: center; |
|
170 |
+ img { height: 150px; } |
|
171 |
+} |
|
172 |
+ |
|
173 |
+.reward-blank { |
|
174 |
+ height: 120px; |
|
175 |
+ font-family: Avenir-MediumOblique; |
|
176 |
+ font-size: 14px; |
|
177 |
+ color: #3C3F47; |
|
178 |
+ line-height: 19px; |
|
179 |
+ text-align: center; |
|
180 |
+ padding-top: 63px; |
|
181 |
+} |
|
182 |
+ |
|
168 | 183 |
.reward-badge p { |
169 |
- margin-top: -25px; |
|
184 |
+ //margin-top: -25px; |
|
185 |
+} |
|
186 |
+ |
|
187 |
+.reward-image p { |
|
188 |
+ margin-top: 10px; |
|
170 | 189 |
} |
171 | 190 |
|
172 | 191 |
.reward-agent-title { |
@@ -184,6 +203,12 @@ |
||
184 | 203 |
line-height: 19px; |
185 | 204 |
} |
186 | 205 |
|
206 |
+.rewards-details { |
|
207 |
+ min-height: 25px; |
|
208 |
+ .btn { margin-left: 10px;} |
|
209 |
+} |
|
210 |
+.rewards-details.centered { text-align: center; margin-top: 20px;} |
|
211 |
+ |
|
187 | 212 |
// Steps |
188 | 213 |
|
189 | 214 |
.thumbnail-task { |
@@ -1,12 +1,8 @@ |
||
1 | 1 |
class AgentsController < ApplicationController |
2 | 2 |
|
3 |
+ before_action :set_agent_dashboard, only: [:dashboard, :rewards] |
|
4 |
+ |
|
3 | 5 |
def dashboard |
4 |
- if user_signed_in? |
|
5 |
- @agent_missions = current_user.mission_agents |
|
6 |
- @directing_missions = Mission.find_all_by_owner_id(current_user.id) |
|
7 |
- else |
|
8 |
- redirect_to(new_user_session_path, alert: (t 'agent.not_logged_in')) |
|
9 |
- end |
|
10 | 6 |
end |
11 | 7 |
|
12 | 8 |
def list |
@@ -16,5 +12,20 @@ class AgentsController < ApplicationController |
||
16 | 12 |
def show |
17 | 13 |
@user = User.find_by_id(params[:id]) |
18 | 14 |
end |
19 |
- |
|
15 |
+ |
|
16 |
+ def rewards |
|
17 |
+ end |
|
18 |
+ |
|
19 |
+ private |
|
20 |
+ |
|
21 |
+ def set_agent_dashboard |
|
22 |
+ if user_signed_in? |
|
23 |
+ @agent_missions = current_user.mission_agents |
|
24 |
+ @directing_missions = Mission.find_all_by_owner_id(current_user.id) |
|
25 |
+ @rewards = UserReward.find_all_by_user_id(current_user.id) |
|
26 |
+ else |
|
27 |
+ redirect_to(new_user_session_path, alert: (t 'agent.not_logged_in')) |
|
28 |
+ end |
|
29 |
+ end |
|
30 |
+ |
|
20 | 31 |
end |
@@ -7,6 +7,7 @@ class Mission < ActiveRecord::Base |
||
7 | 7 |
belongs_to :owner, :class_name => "User" |
8 | 8 |
has_many :mission_agents, :dependent => :destroy |
9 | 9 |
has_many :agent_steps, :through => :mission_agents |
10 |
+ has_many :rewards |
|
10 | 11 |
accepts_nested_attributes_for :mission_agents, allow_destroy:true |
11 | 12 |
|
12 | 13 |
mount_uploader :cover_img, MissionCoverUploader |
@@ -121,6 +122,9 @@ class Mission < ActiveRecord::Base |
||
121 | 122 |
|
122 | 123 |
def completed |
123 | 124 |
self.update(status: 3) |
125 |
+ self.rewards.each do |reward| |
|
126 |
+ reward.distribute |
|
127 |
+ end |
|
124 | 128 |
end |
125 | 129 |
|
126 | 130 |
def failed |
@@ -10,6 +10,8 @@ class MissionAgent < ActiveRecord::Base |
||
10 | 10 |
has_many :agent_steps, :dependent => :destroy |
11 | 11 |
has_many :mission_candidates, :dependent => :destroy |
12 | 12 |
|
13 |
+ has_and_belongs_to_many :rewards |
|
14 |
+ |
|
13 | 15 |
accepts_nested_attributes_for :agent_steps, allow_destroy:true |
14 | 16 |
accepts_nested_attributes_for :mission_candidates |
15 | 17 |
|
@@ -21,7 +23,7 @@ class MissionAgent < ActiveRecord::Base |
||
21 | 23 |
end |
22 | 24 |
end |
23 | 25 |
|
24 |
- def incompleted_step_count |
|
26 |
+ def incomplete_step_count |
|
25 | 27 |
steps = 0 |
26 | 28 |
self.agent_steps.each do |step| |
27 | 29 |
if step.completed |
@@ -31,4 +33,12 @@ class MissionAgent < ActiveRecord::Base |
||
31 | 33 |
return steps |
32 | 34 |
end |
33 | 35 |
|
36 |
+ def has_completed_steps |
|
37 |
+ if self.incomplete_step_count == 0 && self.agent_steps.count > 0 && self.user != nil |
|
38 |
+ return true |
|
39 |
+ else |
|
40 |
+ return false |
|
41 |
+ end |
|
42 |
+ end |
|
43 |
+ |
|
34 | 44 |
end |
@@ -0,0 +1,15 @@ |
||
1 |
+class Reward < ActiveRecord::Base |
|
2 |
+ belongs_to :mission |
|
3 |
+ has_and_belongs_to_many :mission_agents |
|
4 |
+ has_many :user_rewards |
|
5 |
+ mount_uploader :img, RewardUploader |
|
6 |
+ |
|
7 |
+ def distribute |
|
8 |
+ self.mission_agents.each do |agent| |
|
9 |
+ if agent.has_completed_steps |
|
10 |
+ user_reward = UserReward.create(reward: self, user: agent.user) |
|
11 |
+ end |
|
12 |
+ end |
|
13 |
+ end |
|
14 |
+ |
|
15 |
+end |
@@ -37,7 +37,7 @@ class User < ActiveRecord::Base |
||
37 | 37 |
def incomplete_step_count |
38 | 38 |
total = 0 |
39 | 39 |
self.mission_agents.each do |agent| |
40 |
- total = total + agent.incompleted_step_count |
|
40 |
+ total = total + agent.incomplete_step_count |
|
41 | 41 |
end |
42 | 42 |
return total |
43 | 43 |
end |
@@ -0,0 +1,4 @@ |
||
1 |
+class UserReward < ActiveRecord::Base |
|
2 |
+ belongs_to :reward |
|
3 |
+ belongs_to :user |
|
4 |
+end |
@@ -0,0 +1,77 @@ |
||
1 |
+# encoding: utf-8 |
|
2 |
+ |
|
3 |
+class RewardUploader < CarrierWave::Uploader::Base |
|
4 |
+ |
|
5 |
+ # Include RMagick or MiniMagick support: |
|
6 |
+ include CarrierWave::RMagick |
|
7 |
+ # include CarrierWave::MiniMagick |
|
8 |
+ include CarrierWave::MimeTypes |
|
9 |
+ |
|
10 |
+ include ::CarrierWave::Backgrounder::Delay |
|
11 |
+ |
|
12 |
+ # Choose what kind of storage to use for this uploader: |
|
13 |
+ |
|
14 |
+ if Rails.env.test? or Rails.env.cucumber? |
|
15 |
+ storage :file |
|
16 |
+ end |
|
17 |
+ |
|
18 |
+ if Rails.env.development? |
|
19 |
+ storage :file |
|
20 |
+ end |
|
21 |
+ |
|
22 |
+ if Rails.env.production? |
|
23 |
+ # Include the Sprockets helpers for Rails 3.1+ asset pipeline compatibility if using fog: |
|
24 |
+ # include Sprockets::Rails::Helper |
|
25 |
+ include Sprockets::Helpers |
|
26 |
+ storage :fog |
|
27 |
+ end |
|
28 |
+ |
|
29 |
+ process :set_content_type |
|
30 |
+ |
|
31 |
+ # Override the directory where uploaded files will be stored. |
|
32 |
+ # This is a sensible default for uploaders that are meant to be mounted: |
|
33 |
+ def store_dir |
|
34 |
+ "uploads/#{mounted_as}/#{model.id}" |
|
35 |
+ end |
|
36 |
+ |
|
37 |
+ def root |
|
38 |
+ "#{Rails.root}/public" |
|
39 |
+ end |
|
40 |
+ |
|
41 |
+ def cache_dir |
|
42 |
+ "#{Rails.root}/tmp/uploads/#{mounted_as}/" |
|
43 |
+ end |
|
44 |
+ |
|
45 |
+ # Provide a default URL as a default if there hasn't been a file uploaded: |
|
46 |
+ # def default_url |
|
47 |
+ # # For Rails 3.1+ asset pipeline compatibility: |
|
48 |
+ # # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_')) |
|
49 |
+ # |
|
50 |
+ # "/images/fallback/" + [version_name, "default.png"].compact.join('_') |
|
51 |
+ # end |
|
52 |
+ |
|
53 |
+ # Process files as they are uploaded: |
|
54 |
+ # process :scale => [200, 300] |
|
55 |
+ # |
|
56 |
+ # def scale(width, height) |
|
57 |
+ # # do something |
|
58 |
+ # end |
|
59 |
+ |
|
60 |
+ # Create different versions of your uploaded files: |
|
61 |
+ version :thumb do |
|
62 |
+ process :resize_to_fill => [354, 150, gravity = ::Magick::CenterGravity] |
|
63 |
+ end |
|
64 |
+ |
|
65 |
+ # Add a white list of extensions which are allowed to be uploaded. |
|
66 |
+ # For images you might use something like this: |
|
67 |
+ # def extension_white_list |
|
68 |
+ # %w(jpg jpeg gif png) |
|
69 |
+ # end |
|
70 |
+ |
|
71 |
+ # Override the filename of the uploaded files: |
|
72 |
+ # Avoid using model.id or version_name here, see uploader/store.rb for details. |
|
73 |
+ # def filename |
|
74 |
+ # "something.jpg" if original_filename |
|
75 |
+ # end |
|
76 |
+ |
|
77 |
+end |
@@ -0,0 +1,61 @@ |
||
1 |
+<%= content_tag(:div, class: 'row') do %> |
|
2 |
+ <%= content_tag(:div, class: 'span8') do %> |
|
3 |
+ <% # Mission Count %> |
|
4 |
+ <%= content_tag(:div, class: 'dashboard-stats') do %> |
|
5 |
+ <%= content_tag(:p) do %> |
|
6 |
+ <%= content_tag(:i, '', class: 'icon-mission') %> |
|
7 |
+ <%= content_tag(:span, agent_missions.count) %> |
|
8 |
+ <% end %> |
|
9 |
+ <%= content_tag(:p, (t 'mission.missions')) %> |
|
10 |
+ <% end %> |
|
11 |
+ <% # Director Missions Count %> |
|
12 |
+ <%= content_tag(:div, class: 'dashboard-stats') do %> |
|
13 |
+ <%= content_tag(:p) do %> |
|
14 |
+ <%= content_tag(:i, '', class: 'icon-radar') %> |
|
15 |
+ <%= content_tag(:span, current_user.directing_missions_count) %> |
|
16 |
+ <% end %> |
|
17 |
+ <%= content_tag(:p, (t 'mission.directing_missions')) %> |
|
18 |
+ <% end %> |
|
19 |
+ <% # Task Count %> |
|
20 |
+ <%= content_tag(:div, class: 'dashboard-stats') do %> |
|
21 |
+ <%= content_tag(:p) do %> |
|
22 |
+ <%= content_tag(:i, '', class: 'icon-task') %> |
|
23 |
+ <%= content_tag(:span, current_user.incomplete_step_count) %> |
|
24 |
+ <% end %> |
|
25 |
+ <%= content_tag(:p, (t 'agent.tasks')) %> |
|
26 |
+ <% end %> |
|
27 |
+ <% # Rewards Count %> |
|
28 |
+ <%= content_tag(:div, class: 'dashboard-stats') do %> |
|
29 |
+ <%= content_tag(:p) do %> |
|
30 |
+ <%= content_tag(:i, '', class: 'icon-reward') %> |
|
31 |
+ <%= content_tag(:span, rewards.count) %> |
|
32 |
+ <% end %> |
|
33 |
+ <%= content_tag(:p, (t 'agent.unclaimed_rewards')) %> |
|
34 |
+ <% end %> |
|
35 |
+ <% # Messsages Count %> |
|
36 |
+ <% content_tag(:div, class: 'dashboard-stats') do %> |
|
37 |
+ <%= content_tag(:p) do %> |
|
38 |
+ <%= content_tag(:i, '', class: 'icon-chat') %> |
|
39 |
+ <%= content_tag(:span, '48') %> |
|
40 |
+ <% end %> |
|
41 |
+ <%= content_tag(:p, (t 'agent.messages')) %> |
|
42 |
+ <% end %> |
|
43 |
+ <% # Points %> |
|
44 |
+ <% content_tag(:div, class: 'dashboard-stats') do %> |
|
45 |
+ <%= content_tag(:p) do %> |
|
46 |
+ <%= content_tag(:span, '150K') %> |
|
47 |
+ <% end %> |
|
48 |
+ <%= content_tag(:p, (t 'agent.points')) %> |
|
49 |
+ <% end %> |
|
50 |
+ <%= bootstrap_flash %> |
|
51 |
+ <% end %> |
|
52 |
+ <% content_tag(:div, class: 'span4 trust-stat') do %> |
|
53 |
+ <div class="progress-bar"> |
|
54 |
+ <div class="progress progress-striped"> |
|
55 |
+ <div class="bar bar-success" style="width: 95%;"></div> |
|
56 |
+ </div> |
|
57 |
+ <div class="percentage">95%</div> |
|
58 |
+ </div> |
|
59 |
+ <%= content_tag(:p, (t 'agent.trust')) %> |
|
60 |
+ <% end %> |
|
61 |
+<% end %> |
@@ -0,0 +1,13 @@ |
||
1 |
+<% # Tabs %> |
|
2 |
+<%= content_tag(:div, class: 'container container-tabs') do %> |
|
3 |
+ <%= content_tag(:div, class: 'row') do %> |
|
4 |
+ <%= content_tag(:div, class: 'span12') do %> |
|
5 |
+ <%= content_tag(:ul, class: 'nav nav-tabs') do %> |
|
6 |
+ <%= content_tag(:li, (link_to (t 'mission.missions'), dashboard_path), class: ('active' if params[:action] == 'dashboard' )) %> |
|
7 |
+ <%= content_tag(:li, (link_to (t 'mission.rewards'), user_rewards_path), class: ('active' if params[:action] == 'rewards' )) %> |
|
8 |
+ <%= content_tag(:li, (link_to (t 'agent.tasks'), '#'), class: 'disabled') %> |
|
9 |
+ <%= content_tag(:li, (link_to (t 'agent.messages'), '#'), class: 'disabled') %> |
|
10 |
+ <% end %> |
|
11 |
+ <% end %> |
|
12 |
+ <% end %> |
|
13 |
+<% end %> |
@@ -8,74 +8,13 @@ |
||
8 | 8 |
<% end %> |
9 | 9 |
<% end %> |
10 | 10 |
<% end %> |
11 |
- <%= content_tag(:div, class: 'row') do %> |
|
12 |
- <%= content_tag(:div, class: 'span8') do %> |
|
13 |
- <% # Mission Count %> |
|
14 |
- <%= content_tag(:div, class: 'dashboard-stats') do %> |
|
15 |
- <%= content_tag(:p) do %> |
|
16 |
- <%= content_tag(:i, '', class: 'icon-mission') %> |
|
17 |
- <%= content_tag(:span, @agent_missions.count) %> |
|
18 |
- <% end %> |
|
19 |
- <%= content_tag(:p, (t 'mission.missions')) %> |
|
20 |
- <% end %> |
|
21 |
- <% # Director Missions Count %> |
|
22 |
- <%= content_tag(:div, class: 'dashboard-stats') do %> |
|
23 |
- <%= content_tag(:p) do %> |
|
24 |
- <%= content_tag(:i, '', class: 'icon-radar') %> |
|
25 |
- <%= content_tag(:span, current_user.directing_missions_count) %> |
|
26 |
- <% end %> |
|
27 |
- <%= content_tag(:p, (t 'mission.directing_missions')) %> |
|
28 |
- <% end %> |
|
29 |
- <% # Task Count %> |
|
30 |
- <%= content_tag(:div, class: 'dashboard-stats') do %> |
|
31 |
- <%= content_tag(:p) do %> |
|
32 |
- <%= content_tag(:i, '', class: 'icon-task') %> |
|
33 |
- <%= content_tag(:span, current_user.incomplete_step_count) %> |
|
34 |
- <% end %> |
|
35 |
- <%= content_tag(:p, (t 'agent.tasks')) %> |
|
36 |
- <% end %> |
|
37 |
- <% # Messsages Count %> |
|
38 |
- <% content_tag(:div, class: 'dashboard-stats') do %> |
|
39 |
- <%= content_tag(:p) do %> |
|
40 |
- <%= content_tag(:i, '', class: 'icon-chat') %> |
|
41 |
- <%= content_tag(:span, '48') %> |
|
42 |
- <% end %> |
|
43 |
- <%= content_tag(:p, (t 'agent.messages')) %> |
|
44 |
- <% end %> |
|
45 |
- <% # Points %> |
|
46 |
- <% content_tag(:div, class: 'dashboard-stats') do %> |
|
47 |
- <%= content_tag(:p) do %> |
|
48 |
- <%= content_tag(:span, '150K') %> |
|
49 |
- <% end %> |
|
50 |
- <%= content_tag(:p, (t 'agent.points')) %> |
|
51 |
- <% end %> |
|
52 |
- <%= bootstrap_flash %> |
|
53 |
- <% end %> |
|
54 |
- <% content_tag(:div, class: 'span4 trust-stat') do %> |
|
55 |
- <div class="progress-bar"> |
|
56 |
- <div class="progress progress-striped"> |
|
57 |
- <div class="bar bar-success" style="width: 95%;"></div> |
|
58 |
- </div> |
|
59 |
- <div class="percentage">95%</div> |
|
60 |
- </div> |
|
61 |
- <%= content_tag(:p, (t 'agent.trust')) %> |
|
62 |
- <% end %> |
|
63 |
- <% end %> |
|
11 |
+ <% # User Stats %> |
|
12 |
+ <%= render :partial => 'dashboard_stats', locals: {agent_missions: @agent_missions, rewards: @rewards} %> |
|
64 | 13 |
<% end %> |
65 | 14 |
<% end %> |
66 | 15 |
|
67 | 16 |
<% # Tabs %> |
68 |
-<%= content_tag(:div, class: 'container container-tabs') do %> |
|
69 |
- <%= content_tag(:div, class: 'row') do %> |
|
70 |
- <%= content_tag(:div, class: 'span12') do %> |
|
71 |
- <%= content_tag(:ul, class: 'nav nav-tabs') do %> |
|
72 |
- <%= content_tag(:li, (link_to (t 'mission.missions'), dashboard_path), class: 'active') %> |
|
73 |
- <%= content_tag(:li, (link_to (t 'agent.tasks'), '#'), class: 'disabled') %> |
|
74 |
- <%= content_tag(:li, (link_to (t 'agent.messages'), '#'), class: 'disabled') %> |
|
75 |
- <% end %> |
|
76 |
- <% end %> |
|
77 |
- <% end %> |
|
78 |
-<% end %> |
|
17 |
+<%= render :partial => 'dashboard_tabs' %> |
|
79 | 18 |
|
80 | 19 |
<% # Content%> |
81 | 20 |
<%= content_tag(:div, class: 'container') do %> |
@@ -0,0 +1,29 @@ |
||
1 |
+<% # Header BG %> |
|
2 |
+<%= content_tag(:div, class: 'container-bg container-pre-tabs') do %> |
|
3 |
+ <%= content_tag(:div, class: 'container top-container container-bg') do %> |
|
4 |
+ <%= content_tag(:div, class: 'row') do %> |
|
5 |
+ <%= content_tag(:div, class: 'span12') do %> |
|
6 |
+ <%= content_tag(:div, class: 'page-header') do %> |
|
7 |
+ <%= content_tag(:h1, (t 'agent.dashboard')) %> |
|
8 |
+ <% end %> |
|
9 |
+ <% end %> |
|
10 |
+ <% end %> |
|
11 |
+ <% # User Stats %> |
|
12 |
+ <%= render :partial => 'dashboard_stats', locals: {agent_missions: @agent_missions, rewards: @rewards} %> |
|
13 |
+ <% end %> |
|
14 |
+<% end %> |
|
15 |
+ |
|
16 |
+<%= render :partial => 'dashboard_tabs' %> |
|
17 |
+ |
|
18 |
+<% # Content%> |
|
19 |
+<%= content_tag(:div, class: 'container') do %> |
|
20 |
+ <% content_tag(:div, class: 'row') do %> |
|
21 |
+ <%= content_tag(:ul, class: 'rewards thumbnails mission-list') do %> |
|
22 |
+ <% @rewards.each do |user_reward| %> |
|
23 |
+ <%= content_tag(:div, class: 'span4') do %> |
|
24 |
+ <%= render :partial => 'missions/reward', locals: {reward: user_reward.reward, dashboard: true } %> |
|
25 |
+ <% end %> |
|
26 |
+ <% end %> |
|
27 |
+ <% end %> |
|
28 |
+ <% end %> |
|
29 |
+<% end %> |
@@ -0,0 +1,26 @@ |
||
1 |
+<%= content_tag(:li) do %> |
|
2 |
+ <%= content_tag(:div, class: 'reward-image ') do %> |
|
3 |
+ <%= image_tag reward.img %><br> |
|
4 |
+ <%= content_tag(:p, content_tag(:small, reward.title)) %> |
|
5 |
+ <% end %> |
|
6 |
+ <%= content_tag(:p, reward.description) %> |
|
7 |
+ <% if dashboard == false %> |
|
8 |
+ <%= content_tag(:p, class: 'rewards-details ') do %> |
|
9 |
+ |
|
10 |
+ <%= content_tag(:span, (t 'mission.agents')+': ', class: 'reward-agent-title') %> |
|
11 |
+ <% agent_counter = 1 %> |
|
12 |
+ <% reward.mission_agents.each do |agent| %> |
|
13 |
+ <%= content_tag(:span, (link_to agent.role.to_s, mission_agent_details_path(agent: agent.id, id: agent.mission)) , class: 'reward-agent-role') %> |
|
14 |
+ <% if agent_counter < reward.mission_agents.count %> |
|
15 |
+ <%= ', ' %> |
|
16 |
+ <% end %> |
|
17 |
+ <% agent_counter = agent_counter + 1 %> |
|
18 |
+ <% end %> |
|
19 |
+ <% end %> |
|
20 |
+ <% else %> |
|
21 |
+ <%= content_tag(:p, class: 'rewards-details centered') do %> |
|
22 |
+ <%= link_to (t 'reward.received'), '#', class: 'btn btn-success' %> |
|
23 |
+ <%= link_to (t 'reward.not_receveid'), '#', class: 'btn btn-danger' %> |
|
24 |
+ <% end %> |
|
25 |
+ <% end %> |
|
26 |
+<% end %> |
@@ -14,20 +14,11 @@ |
||
14 | 14 |
|
15 | 15 |
<% end %> |
16 | 16 |
<%= content_tag(:div, class: 'span4') do %> |
17 |
+ <% # Rewards %> |
|
17 | 18 |
<%= content_tag(:h4, ((t 'mission.rewards') + ':') ) %> |
18 | 19 |
<%= content_tag(:ul, class: 'rewards') do %> |
19 |
- <%= content_tag(:li) do %> |
|
20 |
- <%= content_tag(:div, class: 'reward-badge ') do %> |
|
21 |
- <%= image_tag "badges/beta_tester.png", size: "150x150" %><br> |
|
22 |
- <%= content_tag(:p, content_tag(:small, 'Beta Tester Badge')) %> |
|
23 |
- <% end %> |
|
24 |
- <%= content_tag(:p, 'O badge de beta tester é entregue para todos que ajudam a testar os novos recursos do Avalanche Network.') %> |
|
25 |
- <%= content_tag(:p) do %> |
|
26 |
- <%= content_tag(:span, (t 'mission.agents')+': ', class: 'reward-agent-title') %> |
|
27 |
- <% @mission.mission_agents.each do |agent| %> |
|
28 |
- <%= content_tag(:span, (link_to agent.role.to_s, '#') , class: 'reward-agent-role') %>, |
|
29 |
- <% end %> |
|
30 |
- <% end %> |
|
20 |
+ <% @mission.rewards.each do |reward| %> |
|
21 |
+ <%= render :partial => 'reward', locals: {reward: reward, dashboard: false } %> |
|
31 | 22 |
<% end %> |
32 | 23 |
<% end %> |
33 | 24 |
<% end %> |
@@ -106,4 +106,20 @@ |
||
106 | 106 |
<% end %> |
107 | 107 |
<% end %> |
108 | 108 |
<% end %> |
109 |
+ <% # Rewards %> |
|
110 |
+ <% content_tag(:div, class: 'row') do %> |
|
111 |
+ <%= content_tag(:div, class: 'span12') do %> |
|
112 |
+ <%= content_tag(:h4, ((t 'mission.rewards') + ':') ) %> |
|
113 |
+ <% end %> |
|
114 |
+ <% end %> |
|
115 |
+ <% content_tag(:div, class: 'row') do %> |
|
116 |
+ <%= content_tag(:ul, class: 'rewards') do %> |
|
117 |
+ <% @mission.rewards.each do |reward| %> |
|
118 |
+ <%= content_tag(:div, class: 'span4') do %> |
|
119 |
+ <%= render :partial => 'reward', locals: {reward: reward, dashboard: false } %> |
|
120 |
+ <% end %> |
|
121 |
+ <% end %> |
|
122 |
+ <% end %> |
|
123 |
+ <% end %> |
|
124 |
+ |
|
109 | 125 |
<% end %> |
@@ -24,11 +24,20 @@ |
||
24 | 24 |
<%= render :partial => 'step_quick_list', locals: {agent: agent} %> |
25 | 25 |
|
26 | 26 |
<% # Rewards %> |
27 |
- <%= content_tag(:div, class: 'thumbnail-content') do%> |
|
28 |
- <%= content_tag(:h4, (t 'mission.rewards')) %> |
|
29 |
- <%= content_tag(:div, class: 'reward-badge ') do %> |
|
30 |
- <%= image_tag "badges/beta_tester.png", size: "150x150" %><br> |
|
31 |
- <%= content_tag(:p, content_tag(:small, 'Beta Tester Badge')) %> |
|
27 |
+ <% if agent.rewards.first %> |
|
28 |
+ <%= content_tag(:div, class: 'thumbnail-content') do%> |
|
29 |
+ <%= content_tag(:h4, (t 'mission.rewards')) %> |
|
30 |
+ <%= content_tag(:div, class: 'reward-image ') do %> |
|
31 |
+ <%= image_tag agent.rewards.first.img %><br> |
|
32 |
+ <%= content_tag(:p, content_tag(:small, agent.rewards.first.title)) %> |
|
33 |
+ <% end %> |
|
34 |
+ <% end %> |
|
35 |
+ <% else %> |
|
36 |
+ <%= content_tag(:div, class: 'thumbnail-content') do%> |
|
37 |
+ <%= content_tag(:h4, (t 'mission.rewards')) %> |
|
38 |
+ <%= content_tag(:div, class: 'reward-blank ') do %> |
|
39 |
+ <%= content_tag(:p, content_tag(:small, (t 'mission.no_rewards'))) %> |
|
40 |
+ <% end %> |
|
32 | 41 |
<% end %> |
33 | 42 |
<% end %> |
34 | 43 |
<% # Selected Agent %> |
@@ -9,6 +9,9 @@ Bundler.require(*Rails.groups) |
||
9 | 9 |
|
10 | 10 |
module Avalanche2 |
11 | 11 |
class Application < Rails::Application |
12 |
+ |
|
13 |
+ config.autoload_paths += %W(#{config.root}/lib) |
|
14 |
+ |
|
12 | 15 |
# Settings in config/environments/* take precedence over those specified here. |
13 | 16 |
# Application configuration should go into files in config/initializers |
14 | 17 |
# -- all .rb files in that directory are automatically loaded. |
@@ -36,6 +36,7 @@ Avalanche2::Application.routes.draw do |
||
36 | 36 |
|
37 | 37 |
# Agents |
38 | 38 |
get 'dashboard' => 'agents#dashboard', as: :dashboard |
39 |
+ get 'dashboard/rewards' => 'agents#rewards', as: :user_rewards |
|
39 | 40 |
get 'agents' => 'agents#list', as: :agent_list |
40 | 41 |
get 'agent/:id' => 'agents#show', as: :show_agent |
41 | 42 |
|
@@ -0,0 +1,13 @@ |
||
1 |
+class CreateRewards < ActiveRecord::Migration |
|
2 |
+ def change |
|
3 |
+ create_table :rewards do |t| |
|
4 |
+ t.references :mission, index: true |
|
5 |
+ t.references :mission_agents, index: true |
|
6 |
+ t.string :title |
|
7 |
+ t.text :description |
|
8 |
+ t.string :img |
|
9 |
+ |
|
10 |
+ t.timestamps |
|
11 |
+ end |
|
12 |
+ end |
|
13 |
+end |
@@ -0,0 +1,12 @@ |
||
1 |
+class CreateUserRewards < ActiveRecord::Migration |
|
2 |
+ def change |
|
3 |
+ create_table :user_rewards do |t| |
|
4 |
+ t.references :reward, index: true |
|
5 |
+ t.references :user, index: true |
|
6 |
+ t.boolean :received |
|
7 |
+ t.datetime :date_received |
|
8 |
+ |
|
9 |
+ t.timestamps |
|
10 |
+ end |
|
11 |
+ end |
|
12 |
+end |
@@ -0,0 +1,5 @@ |
||
1 |
+class AddRewardsToMission < ActiveRecord::Migration |
|
2 |
+ def change |
|
3 |
+ add_reference :missions, :rewards, index: true |
|
4 |
+ end |
|
5 |
+end |
@@ -0,0 +1,5 @@ |
||
1 |
+class AddRewardsToMissionAgent < ActiveRecord::Migration |
|
2 |
+ def change |
|
3 |
+ add_reference :mission_agents, :rewards, index: true |
|
4 |
+ end |
|
5 |
+end |
@@ -0,0 +1,8 @@ |
||
1 |
+class CreateMissionAgentRewards < ActiveRecord::Migration |
|
2 |
+ def change |
|
3 |
+ create_table :mission_agents_rewards, id: false do |t| |
|
4 |
+ t.belongs_to :mission_agent, index: true |
|
5 |
+ t.belongs_to :reward, index: true |
|
6 |
+ end |
|
7 |
+ end |
|
8 |
+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: 20150222233545) do |
|
14 |
+ActiveRecord::Schema.define(version: 20150224042225) do |
|
15 | 15 |
|
16 | 16 |
# These are extensions that must be enabled in order to support this database |
17 | 17 |
enable_extension "plpgsql" |
@@ -102,13 +102,23 @@ ActiveRecord::Schema.define(version: 20150222233545) do |
||
102 | 102 |
t.datetime "created_at" |
103 | 103 |
t.datetime "updated_at" |
104 | 104 |
t.string "slug" |
105 |
+ t.integer "rewards_id" |
|
105 | 106 |
end |
106 | 107 |
|
107 | 108 |
add_index "mission_agents", ["agent_steps_id"], name: "index_mission_agents_on_agent_steps_id", using: :btree |
108 | 109 |
add_index "mission_agents", ["mission_candidates_id"], name: "index_mission_agents_on_mission_candidates_id", using: :btree |
109 | 110 |
add_index "mission_agents", ["mission_id"], name: "index_mission_agents_on_mission_id", using: :btree |
111 |
+ add_index "mission_agents", ["rewards_id"], name: "index_mission_agents_on_rewards_id", using: :btree |
|
110 | 112 |
add_index "mission_agents", ["user_id"], name: "index_mission_agents_on_user_id", using: :btree |
111 | 113 |
|
114 |
+ create_table "mission_agents_rewards", id: false, force: true do |t| |
|
115 |
+ t.integer "mission_agent_id" |
|
116 |
+ t.integer "reward_id" |
|
117 |
+ end |
|
118 |
+ |
|
119 |
+ add_index "mission_agents_rewards", ["mission_agent_id"], name: "index_mission_agents_rewards_on_mission_agent_id", using: :btree |
|
120 |
+ add_index "mission_agents_rewards", ["reward_id"], name: "index_mission_agents_rewards_on_reward_id", using: :btree |
|
121 |
+ |
|
112 | 122 |
create_table "mission_candidates", force: true do |t| |
113 | 123 |
t.integer "user_id" |
114 | 124 |
t.integer "mission_agent_id" |
@@ -135,10 +145,25 @@ ActiveRecord::Schema.define(version: 20150222233545) do |
||
135 | 145 |
t.datetime "updated_at" |
136 | 146 |
t.string "slug" |
137 | 147 |
t.datetime "end_date" |
148 |
+ t.integer "rewards_id" |
|
138 | 149 |
end |
139 | 150 |
|
140 | 151 |
add_index "missions", ["mission_agents_id"], name: "index_missions_on_mission_agents_id", using: :btree |
141 | 152 |
add_index "missions", ["owner_id"], name: "index_missions_on_owner_id", using: :btree |
153 |
+ add_index "missions", ["rewards_id"], name: "index_missions_on_rewards_id", using: :btree |
|
154 |
+ |
|
155 |
+ create_table "rewards", force: true do |t| |
|
156 |
+ t.integer "mission_id" |
|
157 |
+ t.integer "mission_agents_id" |
|
158 |
+ t.string "title" |
|
159 |
+ t.text "description" |
|
160 |
+ t.string "img" |
|
161 |
+ t.datetime "created_at" |
|
162 |
+ t.datetime "updated_at" |
|
163 |
+ end |
|
164 |
+ |
|
165 |
+ add_index "rewards", ["mission_agents_id"], name: "index_rewards_on_mission_agents_id", using: :btree |
|
166 |
+ add_index "rewards", ["mission_id"], name: "index_rewards_on_mission_id", using: :btree |
|
142 | 167 |
|
143 | 168 |
create_table "step_submissions", force: true do |t| |
144 | 169 |
t.integer "agent_step_id" |
@@ -206,6 +231,18 @@ ActiveRecord::Schema.define(version: 20150222233545) do |
||
206 | 231 |
t.boolean "file_processing", default: false, null: false |
207 | 232 |
end |
208 | 233 |
|
234 |
+ create_table "user_rewards", force: true do |t| |
|
235 |
+ t.integer "reward_id" |
|
236 |
+ t.integer "user_id" |
|
237 |
+ t.boolean "received" |
|
238 |
+ t.datetime "date_received" |
|
239 |
+ t.datetime "created_at" |
|
240 |
+ t.datetime "updated_at" |
|
241 |
+ end |
|
242 |
+ |
|
243 |
+ add_index "user_rewards", ["reward_id"], name: "index_user_rewards_on_reward_id", using: :btree |
|
244 |
+ add_index "user_rewards", ["user_id"], name: "index_user_rewards_on_user_id", using: :btree |
|
245 |
+ |
|
209 | 246 |
create_table "users", force: true do |t| |
210 | 247 |
t.string "email", default: "", null: false |
211 | 248 |
t.string "encrypted_password", default: "", null: false |
@@ -93,17 +93,18 @@ rails g model submission_content submission_content:references submission_id:int |
||
93 | 93 |
# Text Submission |
94 | 94 |
rails g model submission_text submission_content:references content accepted:boolean validation:references |
95 | 95 |
|
96 |
+# Rewards |
|
97 |
+rails g model reward mission:references mission_agents:references title:string description:text img:string |
|
98 |
+rails g model user_reward reward:references user:references received:boolean date_received:datetime |
|
99 |
+rails g migration AddRewardsToMission rewards:references |
|
100 |
+rails g migration AddRewardsToMissionAgent rewards:references |
|
101 |
+ |
|
102 |
+ |
|
96 | 103 |
``` |
97 | 104 |
|
98 | 105 |
## Undone Commands |
99 | 106 |
|
100 | 107 |
```shell |
101 |
-# Reward Model |
|
102 |
-rails g model reward mission:references mission_agents:references title:string description:text img:string |
|
103 |
- |
|
104 |
-rails g model user_reward reward:references received:boolean date_received:datetime |
|
105 |
- |
|
106 |
-rails g model |
|
107 | 108 |
|
108 | 109 |
``` |
109 | 110 |
|
@@ -0,0 +1,15 @@ |
||
1 |
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html |
|
2 |
+ |
|
3 |
+one: |
|
4 |
+ mission_id: |
|
5 |
+ mission_agents_id: |
|
6 |
+ title: MyString |
|
7 |
+ description: MyText |
|
8 |
+ img: MyString |
|
9 |
+ |
|
10 |
+two: |
|
11 |
+ mission_id: |
|
12 |
+ mission_agents_id: |
|
13 |
+ title: MyString |
|
14 |
+ description: MyText |
|
15 |
+ img: MyString |
@@ -0,0 +1,13 @@ |
||
1 |
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html |
|
2 |
+ |
|
3 |
+one: |
|
4 |
+ reward_id: |
|
5 |
+ user_id: |
|
6 |
+ received: false |
|
7 |
+ date_received: 2015-02-24 00:18:55 |
|
8 |
+ |
|
9 |
+two: |
|
10 |
+ reward_id: |
|
11 |
+ user_id: |
|
12 |
+ received: false |
|
13 |
+ date_received: 2015-02-24 00:18:55 |
@@ -0,0 +1,7 @@ |
||
1 |
+require 'test_helper' |
|
2 |
+ |
|
3 |
+class RewardTest < ActiveSupport::TestCase |
|
4 |
+ # test "the truth" do |
|
5 |
+ # assert true |
|
6 |
+ # end |
|
7 |
+end |
@@ -0,0 +1,7 @@ |
||
1 |
+require 'test_helper' |
|
2 |
+ |
|
3 |
+class UserRewardTest < ActiveSupport::TestCase |
|
4 |
+ # test "the truth" do |
|
5 |
+ # assert true |
|
6 |
+ # end |
|
7 |
+end |