Create SDG stats page
This commit is contained in:
5
app/components/admin/stats/sdg_component.html.erb
Normal file
5
app/components/admin/stats/sdg_component.html.erb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<%= back_link_to %>
|
||||||
|
|
||||||
|
<%= header %>
|
||||||
|
|
||||||
|
<%= render Admin::Stats::SDG::GoalComponent.with_collection(goals) %>
|
||||||
15
app/components/admin/stats/sdg_component.rb
Normal file
15
app/components/admin/stats/sdg_component.rb
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
class Admin::Stats::SDGComponent < ApplicationComponent
|
||||||
|
include Header
|
||||||
|
|
||||||
|
attr_reader :goals
|
||||||
|
|
||||||
|
def initialize(goals)
|
||||||
|
@goals = goals
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def title
|
||||||
|
t("admin.stats.sdg.title")
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -90,6 +90,10 @@ class Admin::StatsController < Admin::BaseController
|
|||||||
@participants = ::Poll::Voter.where(poll: @polls)
|
@participants = ::Poll::Voter.where(poll: @polls)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def sdg
|
||||||
|
@goals = SDG::Goal.order(:code)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def voters_in_heading(heading)
|
def voters_in_heading(heading)
|
||||||
|
|||||||
1
app/views/admin/stats/sdg.html.erb
Normal file
1
app/views/admin/stats/sdg.html.erb
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<%= render Admin::Stats::SDGComponent.new(@goals) %>
|
||||||
@@ -14,6 +14,8 @@
|
|||||||
proposal_notifications_admin_stats_path, class: "button hollow" %>
|
proposal_notifications_admin_stats_path, class: "button hollow" %>
|
||||||
<%= link_to t("admin.stats.show.incomplete_verifications"),
|
<%= link_to t("admin.stats.show.incomplete_verifications"),
|
||||||
admin_verifications_path, class: "button hollow" %>
|
admin_verifications_path, class: "button hollow" %>
|
||||||
|
<%= link_to t("admin.stats.show.sdg"),
|
||||||
|
sdg_admin_stats_path, class: "button hollow" if feature?(:sdg) %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
|
|||||||
@@ -1373,6 +1373,7 @@ en:
|
|||||||
proposal_notifications: Proposal notifications
|
proposal_notifications: Proposal notifications
|
||||||
incomplete_verifications: Incomplete verifications
|
incomplete_verifications: Incomplete verifications
|
||||||
polls: Polls
|
polls: Polls
|
||||||
|
sdg: SDG
|
||||||
graph:
|
graph:
|
||||||
debate_created: Debates
|
debate_created: Debates
|
||||||
visit: Visits
|
visit: Visits
|
||||||
@@ -1423,6 +1424,7 @@ en:
|
|||||||
debates: "Debates"
|
debates: "Debates"
|
||||||
polls: "Polls"
|
polls: "Polls"
|
||||||
proposals: "Proposals"
|
proposals: "Proposals"
|
||||||
|
title: "Sustainable Development Goals - Stats"
|
||||||
tags:
|
tags:
|
||||||
create: Create topic
|
create: Create topic
|
||||||
destroy: Delete topic
|
destroy: Delete topic
|
||||||
|
|||||||
@@ -1372,6 +1372,7 @@ es:
|
|||||||
proposal_notifications: Notificaciones de propuestas
|
proposal_notifications: Notificaciones de propuestas
|
||||||
incomplete_verifications: Verificaciones incompletas
|
incomplete_verifications: Verificaciones incompletas
|
||||||
polls: Votaciones
|
polls: Votaciones
|
||||||
|
sdg: ODS
|
||||||
graph:
|
graph:
|
||||||
debate_created: Debates
|
debate_created: Debates
|
||||||
visit: Visitas
|
visit: Visitas
|
||||||
@@ -1422,6 +1423,7 @@ es:
|
|||||||
debates: "Debates"
|
debates: "Debates"
|
||||||
polls: "Votaciones"
|
polls: "Votaciones"
|
||||||
proposals: "Propuestas"
|
proposals: "Propuestas"
|
||||||
|
title: "Objetivos de Desarrollo Sostenible - Estadísticas"
|
||||||
tags:
|
tags:
|
||||||
create: Crear tema
|
create: Crear tema
|
||||||
destroy: Eliminar tema
|
destroy: Eliminar tema
|
||||||
|
|||||||
@@ -204,6 +204,7 @@ namespace :admin do
|
|||||||
get :proposal_notifications, on: :collection
|
get :proposal_notifications, on: :collection
|
||||||
get :direct_messages, on: :collection
|
get :direct_messages, on: :collection
|
||||||
get :polls, on: :collection
|
get :polls, on: :collection
|
||||||
|
get :sdg, on: :collection
|
||||||
end
|
end
|
||||||
|
|
||||||
namespace :legislation do
|
namespace :legislation do
|
||||||
|
|||||||
@@ -395,4 +395,29 @@ describe "Stats", :admin do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "SDG", :js do
|
||||||
|
scenario "Shows SDG stats link when SDG feature is enabled" do
|
||||||
|
Setting["feature.sdg"] = true
|
||||||
|
|
||||||
|
visit admin_stats_path
|
||||||
|
|
||||||
|
expect(page).to have_link "SDG", href: sdg_admin_stats_path
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "Does not show SDG stats link when SDG feature is disbled" do
|
||||||
|
Setting["feature.sdg"] = false
|
||||||
|
|
||||||
|
visit admin_stats_path
|
||||||
|
|
||||||
|
expect(page).not_to have_link "SDG"
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "Renders all goals stats" do
|
||||||
|
visit sdg_admin_stats_path
|
||||||
|
|
||||||
|
expect(page).to have_css "h3", count: SDG::Goal.count
|
||||||
|
expect(page).to have_css ".sdg-goal-stats", count: SDG::Goal.count
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user