diff --git a/app/assets/stylesheets/proposal.scss b/app/assets/stylesheets/proposal.scss
index c755be9f0..c5d02c38c 100644
--- a/app/assets/stylesheets/proposal.scss
+++ b/app/assets/stylesheets/proposal.scss
@@ -340,5 +340,16 @@
a {
font-size: 16px;
}
+
+ }
+
+ .community-totals {
+ span {
+ color: #898989;
+ }
+
+ p {
+ color: #898989;
+ }
}
}
diff --git a/app/controllers/proposals_dashboard_controller.rb b/app/controllers/proposals_dashboard_controller.rb
index 04e79b9f4..de842190f 100644
--- a/app/controllers/proposals_dashboard_controller.rb
+++ b/app/controllers/proposals_dashboard_controller.rb
@@ -47,6 +47,10 @@ class ProposalsDashboardController < Dashboard::BaseController
authorize! :dashboard, proposal
end
+ def community
+ authorize! :dashboard, proposal
+ end
+
def supports
authorize! :dashboard, proposal
render json: ProposalSupportsQuery.for(params)
diff --git a/app/helpers/proposals_dashboard_helper.rb b/app/helpers/proposals_dashboard_helper.rb
index 85e4da22e..a68c324f7 100644
--- a/app/helpers/proposals_dashboard_helper.rb
+++ b/app/helpers/proposals_dashboard_helper.rb
@@ -9,6 +9,11 @@ module ProposalsDashboardHelper
nil
end
+ def community_menu_class
+ return 'is-active' if controller_name == 'proposals_dashboard' && action_name == 'community'
+ nil
+ end
+
def progress_menu_active?
is_proposed_action_request? || (controller_name == 'proposals_dashboard' && action_name == 'progress')
end
diff --git a/app/models/community.rb b/app/models/community.rb
index fb3e5dc7c..de1ba9e87 100644
--- a/app/models/community.rb
+++ b/app/models/community.rb
@@ -15,6 +15,30 @@ class Community < ActiveRecord::Base
proposal.present?
end
+ def latest_activity
+ activity = []
+
+ most_recent_comment = Comment.where(commentable: topics).order(updated_at: :desc).take(1).first
+ activity << most_recent_comment.updated_at unless most_recent_comment.nil?
+
+ most_recent_topic = topics.order(updated_at: :desc).take(1).first
+ activity << most_recent_topic.updated_at unless most_recent_topic.nil?
+
+ activity.max
+ end
+
+ def comments_count
+ Comment.where(commentable: topics).count
+ end
+
+ def debates_count
+ topics.count
+ end
+
+ def participants_count
+ participants.count
+ end
+
private
def users_who_commented
diff --git a/app/views/proposals_dashboard/_menu.html.erb b/app/views/proposals_dashboard/_menu.html.erb
index 7c77e48c2..d70a2b948 100644
--- a/app/views/proposals_dashboard/_menu.html.erb
+++ b/app/views/proposals_dashboard/_menu.html.erb
@@ -42,4 +42,12 @@
<% end %>
<% end %>
+
+
+ <%= link_to community_proposal_dashboard_index_path(proposal.to_param),
+ class: community_menu_class do %>
+
+ <%= t('.community') %>
+ <% end %>
+
diff --git a/app/views/proposals_dashboard/_topic.html.erb b/app/views/proposals_dashboard/_topic.html.erb
new file mode 100644
index 000000000..becd154c6
--- /dev/null
+++ b/app/views/proposals_dashboard/_topic.html.erb
@@ -0,0 +1,8 @@
+
+ <%= topic.title %>
+
+ <%= l(topic.updated_at.to_date) %>
+ -
+ <%= topic.author.name %>
+
+
diff --git a/app/views/proposals_dashboard/community.html.erb b/app/views/proposals_dashboard/community.html.erb
new file mode 100644
index 000000000..6a4a1997c
--- /dev/null
+++ b/app/views/proposals_dashboard/community.html.erb
@@ -0,0 +1,39 @@
+<% content_for :action_title, t('proposals_dashboard.menu.community') %>
+
+
+
+ <%= link_to t('.access_community'), community_path(proposal.community), class: 'button hollow' %>
+ <% unless proposal.community.latest_activity.nil? %>
+
<%= t('.latest_activity', at: l(proposal.community.latest_activity.to_date)) %>
+ <% end %>
+
+
+
+
+
<%= number_with_delimiter(proposal.community.participants_count, delimiter: '.') %>
+
<%= t('.participants') %>
+
+
+
+
+
<%= number_with_delimiter(proposal.community.debates_count, delimiter: '.') %>
+
<%= t('.debates') %>
+
+
+
+
+
<%= number_with_delimiter(proposal.community.comments_count, delimiter: '.') %>
+
<%= t('.comments') %>
+
+
+
+<% if proposal.community.topics.any? %>
+
+
<%= t('.latest_topics') %>
+
+
+
+
+ <%= render partial: 'topic', collection: proposal.community.topics %>
+
+<% end %>
diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml
index fa120c136..7ef4513d3 100644
--- a/config/locales/en/general.yml
+++ b/config/locales/en/general.yml
@@ -508,6 +508,7 @@ en:
my_proposal: My proposal
progress: Progress
resources: Resources
+ community: Community
polls: Polls
form:
request: Request
@@ -550,6 +551,13 @@ en:
other: "%{count} days"
unlocked_resource: Resource unlocked
ideal_time: Ideal time
+ community:
+ access_community: Access the community
+ latest_activity: "Latest activity of the community: %{at}"
+ participants: Participants
+ debates: Debates
+ comments: Comments
+ latest_topics: Latest topics
dashboard:
polls:
index:
diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml
index 00492bf6b..791fcb31b 100644
--- a/config/locales/es/general.yml
+++ b/config/locales/es/general.yml
@@ -508,6 +508,7 @@ es:
my_proposal: Mi propuesta
progress: Progreso
resources: Recursos
+ community: Comunidad
polls: Encuestas
form:
request: Solicitar
@@ -550,6 +551,13 @@ es:
other: "%{count} días"
unlocked_resource: Recurso desbloqueado
ideal_time: Tiempo ideal
+ community:
+ access_community: Acceder a la comunidad
+ latest_activity: "Última actividad de la comunidad: %{at}"
+ participants: Participantes
+ debates: Debates
+ comments: Comentarios
+ latest_topics: Últimos debates
dashboard:
polls:
index:
diff --git a/config/routes/proposal.rb b/config/routes/proposal.rb
index c23734adb..e933e32f1 100644
--- a/config/routes/proposal.rb
+++ b/config/routes/proposal.rb
@@ -9,6 +9,7 @@ resources :proposals do
get :supports
get :successful_supports
get :progress
+ get :community
get :achievements
end