@@ -1,3 +1,7 @@ |
||
1 | 1 |
// Place all the styles related to the agents controller here. |
2 | 2 |
// They will automatically be included in application.css. |
3 | 3 |
// You can use Sass (SCSS) here: http://sass-lang.com/ |
4 |
+ |
|
5 |
+.thumbnails.mission-list { |
|
6 |
+ margin-top: 20px; |
|
7 |
+} |
@@ -68,6 +68,10 @@ bottom: 0; |
||
68 | 68 |
margin-bottom: 35px; |
69 | 69 |
} |
70 | 70 |
|
71 |
+.cover-center .alert { |
|
72 |
+ text-align: left; |
|
73 |
+} |
|
74 |
+ |
|
71 | 75 |
.cover-center fieldset { |
72 | 76 |
margin-bottom: 5px; |
73 | 77 |
text-align: left; |
@@ -238,6 +238,34 @@ |
||
238 | 238 |
padding: 15px; |
239 | 239 |
} |
240 | 240 |
|
241 |
+.thumbnail-selected-agent-slot { |
|
242 |
+ background-color: @light-gray; |
|
243 |
+ text-align: center; |
|
244 |
+ padding-left: 8px; |
|
245 |
+ padding-right: 8px; |
|
246 |
+ padding-top: 4px; |
|
247 |
+ padding-bottom: 4px; |
|
248 |
+ height: 52px; |
|
249 |
+ text-align: left; |
|
250 |
+ .avatar { |
|
251 |
+ |
|
252 |
+ } |
|
253 |
+ .name { |
|
254 |
+ font-family: Avenir-Medium; |
|
255 |
+ font-size: 18px; |
|
256 |
+ color: #1D1D26; |
|
257 |
+ line-height: 21px; |
|
258 |
+ margin-bottom: 0px; |
|
259 |
+ } |
|
260 |
+ .bio { |
|
261 |
+ font-family: Helvetica-LightOblique; |
|
262 |
+ font-size: 14px; |
|
263 |
+ color: #1D1D26; |
|
264 |
+ line-height: 17px; |
|
265 |
+ margin-top: 0px; |
|
266 |
+ } |
|
267 |
+} |
|
268 |
+ |
|
241 | 269 |
// Mission Agent Status |
242 | 270 |
|
243 | 271 |
.mission-agent-status { |
@@ -1,7 +1,11 @@ |
||
1 | 1 |
class AgentsController < ApplicationController |
2 | 2 |
|
3 | 3 |
def dashboard |
4 |
- @agent_missions = current_user.mission_agents |
|
4 |
+ if user_signed_in? |
|
5 |
+ @agent_missions = current_user.mission_agents |
|
6 |
+ else |
|
7 |
+ redirect_to(new_user_session_path, alert: (t 'agent.not_logged_in')) |
|
8 |
+ end |
|
5 | 9 |
end |
6 | 10 |
|
7 | 11 |
def list |
@@ -4,9 +4,11 @@ class MissionsController < ApplicationController |
||
4 | 4 |
# GET /missions |
5 | 5 |
# GET /missions.json |
6 | 6 |
def index |
7 |
- @featured_missions = Mission.last |
|
7 |
+ @featured_missions = Mission.where("status = ? OR status = ?", 1, 2).last |
|
8 | 8 |
@open_missions = Mission.where("status = ? OR status = ?", 1, 2) |
9 |
+ @open_missions.delete_if { |m| m == @featured_missions } |
|
9 | 10 |
@finished_missions = Mission.where("status = ? OR status = ?", 3, 4) |
11 |
+ @finished_missions.delete_if { |m| m == @featured_missions } |
|
10 | 12 |
end |
11 | 13 |
|
12 | 14 |
def mission_control |
@@ -21,19 +21,19 @@ module MissionsHelper |
||
21 | 21 |
|
22 | 22 |
def mission_agent_counter(mission, position = 'pull-left') |
23 | 23 |
content_tag(:div, class: 'mission-counter ' + position) do |
24 |
- '<i class="icon-agent"></i><span>'.html_safe + mission.agent_position_count.to_s + '/' + mission.confirmed_agent_count.to_s + '</span>'.html_safe |
|
24 |
+ '<i class="icon-agent"></i><span>'.html_safe + mission.agent_count_stats + '</span>'.html_safe |
|
25 | 25 |
end |
26 | 26 |
end |
27 | 27 |
|
28 | 28 |
def mission_steps_counter(mission, position = 'center_position') |
29 | 29 |
content_tag(:div, class: 'mission-counter '+ position) do |
30 |
- '<i class="icon-task"></i><span>'.html_safe + mission.agent_position_count.to_s + '/' + mission.confirmed_agent_count.to_s + '</span>'.html_safe |
|
30 |
+ '<i class="icon-task"></i><span>'.html_safe + mission.step_count_stats + '</span>'.html_safe |
|
31 | 31 |
end |
32 | 32 |
end |
33 | 33 |
|
34 | 34 |
def mission_time_left(mission, position = 'pull-left') |
35 |
- content_tag(:div, class: 'mission-time-left '+ position) do |
|
36 |
- content_tag(:div, '45 '.to_s) + content_tag(:div, (t 'mission.days_left')) |
|
35 |
+ content_tag(:div, class: 'mission-counter mission-time-left '+ position) do |
|
36 |
+ content_tag(:div, mission.days_left.html_safe) + content_tag(:div, (t 'mission.days_left')) |
|
37 | 37 |
end |
38 | 38 |
end |
39 | 39 |
|
@@ -12,12 +12,55 @@ class Mission < ActiveRecord::Base |
||
12 | 12 |
mount_uploader :cover_img, MissionCoverUploader |
13 | 13 |
process_in_background :cover_img |
14 | 14 |
|
15 |
- def agent_position_count |
|
16 |
- return self.mission_agents.count |
|
15 |
+ def agent_count |
|
16 |
+ return self.mission_agents.count |
|
17 | 17 |
end |
18 | 18 |
|
19 | 19 |
def confirmed_agent_count |
20 |
- return self.mission_agents.count |
|
20 |
+ confirmed_agents = 0 |
|
21 |
+ self.mission_agents.each do |agent| |
|
22 |
+ if agent.user != nil |
|
23 |
+ confirmed_agents = confirmed_agents + 1 |
|
24 |
+ end |
|
25 |
+ end |
|
26 |
+ return confirmed_agents |
|
27 |
+ end |
|
28 |
+ |
|
29 |
+ def agent_count_stats |
|
30 |
+ return String.new("#{self.confirmed_agent_count}/#{self.agent_count}") |
|
31 |
+ end |
|
32 |
+ |
|
33 |
+ def step_count |
|
34 |
+ total_steps = 0 |
|
35 |
+ self.mission_agents.each do |agent| |
|
36 |
+ total_steps = total_steps + agent.agent_steps.count |
|
37 |
+ end |
|
38 |
+ return total_steps |
|
39 |
+ end |
|
40 |
+ |
|
41 |
+ def completed_steps_count |
|
42 |
+ completed_steps = 0 |
|
43 |
+ self.mission_agents.each do |agent| |
|
44 |
+ agent.agent_steps.each do |step| |
|
45 |
+ if step.completed |
|
46 |
+ completed_steps = completed_steps + 1 |
|
47 |
+ end |
|
48 |
+ end |
|
49 |
+ end |
|
50 |
+ return completed_steps |
|
51 |
+ end |
|
52 |
+ |
|
53 |
+ def step_count_stats |
|
54 |
+ return String.new("#{self.completed_steps_count}/#{self.step_count}") |
|
55 |
+ end |
|
56 |
+ |
|
57 |
+ def is_agent(user) |
|
58 |
+ if user |
|
59 |
+ if self.mission_agents.find_all_by_user_id(user.id).count > 0 |
|
60 |
+ return true |
|
61 |
+ end |
|
62 |
+ end |
|
63 |
+ return false |
|
21 | 64 |
end |
22 | 65 |
|
23 | 66 |
def check_for_completion |
@@ -32,4 +75,18 @@ class Mission < ActiveRecord::Base |
||
32 | 75 |
return true |
33 | 76 |
end |
34 | 77 |
|
78 |
+ def days_left |
|
79 |
+ if self.status == 3 || self.status == 4 |
|
80 |
+ return '0' |
|
81 |
+ elsif self.status == 1 && self.end_date == nil |
|
82 |
+ return '?' |
|
83 |
+ elsif self.end_date |
|
84 |
+ time_dif = self.end_date - Time.now |
|
85 |
+ days_left = time_dif / 60 / 60 / 24 |
|
86 |
+ return days_left.round.to_s |
|
87 |
+ else |
|
88 |
+ return '∞' |
|
89 |
+ end |
|
90 |
+ end |
|
91 |
+ |
|
35 | 92 |
end |
@@ -3,7 +3,7 @@ |
||
3 | 3 |
<%= content_tag(:div, class: 'cover-center compact-form') do%> |
4 | 4 |
<%= image_tag('avalanche_network_logo_full_small.png', size: '208x150', class: 'centered')%> |
5 | 5 |
<%= bootstrap_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> |
6 |
- <% bootstrap_flash %> |
|
6 |
+ <%= bootstrap_flash %> |
|
7 | 7 |
<%= f.alert_message "Please fix the errors below."%> |
8 | 8 |
<%= content_tag(:fieldset) do %> |
9 | 9 |
<%= f.text_field :first_name, hide_label: true, placeholder: (t 'registration.first_name'), required:true, autofocus: true, class: 'input-block-level' %> |
@@ -4,7 +4,7 @@ |
||
4 | 4 |
<%= content_tag(:div, class: 'cover-center compact-form') do%> |
5 | 5 |
<%= image_tag('avalanche_network_logo_full_small.png', size: '208x150', class: 'centered')%> |
6 | 6 |
<%= bootstrap_form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %> |
7 |
- <% bootstrap_flash %> |
|
7 |
+ <%= bootstrap_flash %> |
|
8 | 8 |
<%= f.alert_message "Please fix the errors below."%> |
9 | 9 |
<%= content_tag(:fieldset) do %> |
10 | 10 |
<%= f.email_field :email, required: true, hide_label: true, placeholder: (t 'registration.email'), autofocus: true, class: "input-block-level" %> |
@@ -7,10 +7,12 @@ |
||
7 | 7 |
<%= content_tag(:h3, link_to(mission.title, mission)) %> |
8 | 8 |
<%= content_tag(:p, mission.owner.full_name, class: 'mission-director-name') %> |
9 | 9 |
<%= content_tag(:p, mission.objective, class: 'thumbnail-mission-description') %> |
10 |
+ <% end %> |
|
11 |
+ <%= content_tag(:div, class: 'thumbnail-content mission-status-timer') do%> |
|
10 | 12 |
<%= content_tag(:div) do %> |
11 |
- <%= mission_agent_counter(mission) %> |
|
13 |
+ <% mission_agent_counter(mission, 'center_position') %> |
|
12 | 14 |
<%= status(mission.status) %> |
13 |
- <%= mission_steps_counter(mission) %> |
|
15 |
+ <%= mission_time_left(mission) %> |
|
14 | 16 |
<% end %> |
15 | 17 |
<% end %> |
16 | 18 |
<% end %> |
@@ -37,7 +37,7 @@ |
||
37 | 37 |
<% end %> |
38 | 38 |
<% end %> |
39 | 39 |
<%= content_tag(:div, class: 'span4 mission-stats') do %> |
40 |
- <%= content_tag(:span,'145', class: 'mission-timer timer-large') %> |
|
40 |
+ <%= content_tag(:span, mission.days_left.html_safe, class: 'mission-timer timer-large') %> |
|
41 | 41 |
<%= content_tag(:br) %> |
42 | 42 |
<%= content_tag(:div, (t 'mission.days_left'), class: 'timer-legend') %> |
43 | 43 |
<div class="progress-bar progress-bar-mission-stats"> |
@@ -64,8 +64,14 @@ |
||
64 | 64 |
<% end %> |
65 | 65 |
<% end %> |
66 | 66 |
<%= content_tag(:div, '', class: 'clearfix') %> |
67 |
- <%= content_tag(:div, class: 'mission-call-to-action') do %> |
|
68 |
- <%= link_to (t 'mission.join'), '#', class: 'btn btn-large' %> |
|
67 |
+ <% if !@mission.is_agent(current_user) && current_user != @mission.owner %> |
|
68 |
+ <%= content_tag(:div, class: 'mission-call-to-action') do %> |
|
69 |
+ <% if user_signed_in? %> |
|
70 |
+ <%= link_to (t 'mission.join'), mission_agents_list_path(@mission, anchor: "mission-tab"), class: 'btn btn-large' %> |
|
71 |
+ <% else %> |
|
72 |
+ <%= link_to (t 'mission.join'), new_user_session_path, class: 'btn btn-large' %> |
|
73 |
+ <% end %> |
|
74 |
+ <% end %> |
|
69 | 75 |
<% end %> |
70 | 76 |
<%= content_tag(:div, '', class: 'clearfix', id: 'mission-tab') %> |
71 | 77 |
<% end %> |
@@ -3,7 +3,7 @@ |
||
3 | 3 |
<%= content_tag(:div, class: 'span12') do %> |
4 | 4 |
<%= content_tag(:ul, class: 'nav nav-tabs') do %> |
5 | 5 |
<% if user_signed_in? %> |
6 |
- <% if current_user = @mission.owner %> |
|
6 |
+ <% if current_user == @mission.owner %> |
|
7 | 7 |
<%= content_tag(:li, (link_to (t 'mission.mission_control'), mission_control_path(@mission, anchor: "mission-tab")), class: ('active' if params[:action] == 'mission_control' )) %> |
8 | 8 |
<% end %> |
9 | 9 |
<% end %> |
@@ -26,9 +26,10 @@ |
||
26 | 26 |
<%= content_tag(:p, @featured_missions.owner.full_name, class: 'mission-director-name') %> |
27 | 27 |
<%= content_tag(:p, @featured_missions.objective, class: 'box-mission-description') %> |
28 | 28 |
<%= content_tag(:div) do %> |
29 |
- <%= mission_agent_counter(@featured_missions) %> |
|
29 |
+ <% mission_agent_counter(@featured_missions) %> |
|
30 | 30 |
<%= status(@featured_missions.status) %> |
31 |
- <%= mission_steps_counter(@featured_missions) %> |
|
31 |
+ <% mission_steps_counter(@featured_missions) %> |
|
32 |
+ <%= mission_time_left(@featured_missions) %> |
|
32 | 33 |
<% end %> |
33 | 34 |
<% end %> |
34 | 35 |
<% end %> |
@@ -53,11 +53,30 @@ |
||
53 | 53 |
<% end %> |
54 | 54 |
<% end %> |
55 | 55 |
<% # Selected Agent %> |
56 |
- <%= content_tag(:div, class: 'thumbnail-content thumbnail-line-top') do%> |
|
57 |
- <%= content_tag(:h4, (t 'mission.no_agent_selected')+'') %> |
|
58 |
- <% end %> |
|
59 |
- <%= content_tag(:div, class: 'thumbnail-open-agent-slot') do %> |
|
60 |
- <%= link_to (t 'mission.apply_for_position'), take_agent_role_path(@mission, agent), class: 'btn' %> |
|
56 |
+ <% if agent.user == nil %> |
|
57 |
+ <%= content_tag(:div, class: 'thumbnail-content thumbnail-line-top') do%> |
|
58 |
+ <%= content_tag(:h4, (t 'mission.no_agent_selected')+'') %> |
|
59 |
+ <% end %> |
|
60 |
+ <%= content_tag(:div, class: 'thumbnail-open-agent-slot') do %> |
|
61 |
+ <%= link_to (t 'mission.apply_for_position'), take_agent_role_path(@mission, agent), class: 'btn' %> |
|
62 |
+ <% end %> |
|
63 |
+ <% else %> |
|
64 |
+ <%= content_tag(:div, class: 'thumbnail-content thumbnail-line-top') do%> |
|
65 |
+ <%= content_tag(:h4, (t 'mission.agent_selected')+'') %> |
|
66 |
+ <% end %> |
|
67 |
+ <%= content_tag(:div, class: 'thumbnail-selected-agent-slot') do %> |
|
68 |
+ <%= content_tag(:div, class: 'avatar pull-right') do %> |
|
69 |
+ <% if agent.user.avatar.file != nil %> |
|
70 |
+ <%= image_tag agent.user.avatar.to_s, size: "52x52", :class => 'img-circle' %> |
|
71 |
+ <% else %> |
|
72 |
+ <%= image_tag "user.png", size: "52x52", :class => 'img-circle' %> |
|
73 |
+ <% end %> |
|
74 |
+ <% end %> |
|
75 |
+ <%= content_tag(:div, class: '') do %> |
|
76 |
+ <%= content_tag(:p, agent.user.full_name, class: 'name') %> |
|
77 |
+ <%= content_tag(:p, 'Hacker from São Paulo Brazil. Avalanche programer and Designer.', class: 'bio') %> |
|
78 |
+ <% end %> |
|
79 |
+ <% end %> |
|
61 | 80 |
<% end %> |
62 | 81 |
<% end %> |
63 | 82 |
<% end %> |