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)
|
||||
end
|
||||
|
||||
def sdg
|
||||
@goals = SDG::Goal.order(:code)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
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" %>
|
||||
<%= link_to t("admin.stats.show.incomplete_verifications"),
|
||||
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 class="clear"></div>
|
||||
|
||||
@@ -1373,6 +1373,7 @@ en:
|
||||
proposal_notifications: Proposal notifications
|
||||
incomplete_verifications: Incomplete verifications
|
||||
polls: Polls
|
||||
sdg: SDG
|
||||
graph:
|
||||
debate_created: Debates
|
||||
visit: Visits
|
||||
@@ -1423,6 +1424,7 @@ en:
|
||||
debates: "Debates"
|
||||
polls: "Polls"
|
||||
proposals: "Proposals"
|
||||
title: "Sustainable Development Goals - Stats"
|
||||
tags:
|
||||
create: Create topic
|
||||
destroy: Delete topic
|
||||
|
||||
@@ -1372,6 +1372,7 @@ es:
|
||||
proposal_notifications: Notificaciones de propuestas
|
||||
incomplete_verifications: Verificaciones incompletas
|
||||
polls: Votaciones
|
||||
sdg: ODS
|
||||
graph:
|
||||
debate_created: Debates
|
||||
visit: Visitas
|
||||
@@ -1422,6 +1423,7 @@ es:
|
||||
debates: "Debates"
|
||||
polls: "Votaciones"
|
||||
proposals: "Propuestas"
|
||||
title: "Objetivos de Desarrollo Sostenible - Estadísticas"
|
||||
tags:
|
||||
create: Crear tema
|
||||
destroy: Eliminar tema
|
||||
|
||||
@@ -204,6 +204,7 @@ namespace :admin do
|
||||
get :proposal_notifications, on: :collection
|
||||
get :direct_messages, on: :collection
|
||||
get :polls, on: :collection
|
||||
get :sdg, on: :collection
|
||||
end
|
||||
|
||||
namespace :legislation do
|
||||
|
||||
@@ -395,4 +395,29 @@ describe "Stats", :admin do
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user