Add Goals seeds and translations

Extracted from the official United Nations Sustainable Development
Goals website [1].

[1] https://www.un.org/sustainabledevelopment/sustainable-development-goals/
This commit is contained in:
Senén Rodero Rodríguez
2020-11-12 14:26:03 +01:00
committed by Javi Martín
parent cb78a254f4
commit cbe84450ac
9 changed files with 124 additions and 8 deletions

View File

@@ -1,5 +1,5 @@
class SDG::Goal < ApplicationRecord class SDG::Goal < ApplicationRecord
validates :code, presence: true, uniqueness: true validates :code, presence: true, uniqueness: true, inclusion: { in: 1..17 }
def title def title
I18n.t("sdg.goals.goal_#{code}.title") I18n.t("sdg.goals.goal_#{code}.title")

View File

@@ -4,3 +4,51 @@ en:
goal_1: goal_1:
title: "No Poverty" title: "No Poverty"
description: "End poverty in all its forms, everywhere." description: "End poverty in all its forms, everywhere."
goal_2:
title: "Zero Hunger"
description: "Zero Hunger"
goal_3:
title: "Good Health and Well-Being"
description: "Ensure healthy lives and promote well-being for all at all ages."
goal_4:
title: "Quality Education"
description: "Quality Education"
goal_5:
title: "Gender Equality"
description: "Achieve gender equality and empower all women and girls."
goal_6:
title: "Clean Water and Sanitation"
description: "Ensure access to water and sanitation for all."
goal_7:
title: "Affordable and Clean Energy"
description: "Ensure access to affordable, reliable, sustainable and modern energy."
goal_8:
title: "Decent Work and Economic Growth"
description: "Promote inclusive and sustainable economic growth, employment and decent work for all."
goal_9:
title: "Industry, Innovation and Infrastructure"
description: "Build resilient infrastructure, promote sustainable industrialization and foster innovation."
goal_10:
title: "Reduced Inequalities"
description: "Reduce inequality within and among countries."
goal_11:
title: "Sustainable Cities and Communities"
description: "Make cities inclusive, safe, resilient and sustainable."
goal_12:
title: "Responsible Consumption and Production"
description: "Ensure sustainable consumption and production patterns."
goal_13:
title: "Climate Action"
description: "Take urgent action to combat climate change and its impacts."
goal_14:
title: "Life Below Water"
description: "Conserve and sustainably use the oceans, seas and marine resources."
goal_15:
title: "Life on Land"
description: "Sustainably manage forests, combat desertification, halt and reverse land degradation, halt biodiversity loss."
goal_16:
title: "Peace, Justice and Strong Institution"
description: "Promote just, peaceful and inclusive societies."
goal_17:
title: "Partnerships For the Goals"
description: "Revitalize the global partnership for Sustainable Development."

View File

@@ -4,3 +4,51 @@ es:
goal_1: goal_1:
title: "Fin de la pobreza" title: "Fin de la pobreza"
description: "Poner fin a la pobreza en todas sus formas en todo el mundo." description: "Poner fin a la pobreza en todas sus formas en todo el mundo."
goal_2:
title: "Hambre Cero"
description: "Poner fin al hambre."
goal_3:
title: "Salud y Bienestar"
description: "Garantizar una vida sana y promover el bienestar para todos en todas las edades."
goal_4:
title: "Educación de Calidad"
description: "Garantizar una educación inclusiva, equitativa y de calidad y promover oportunidades de aprendizaje durante toda la vida para todos."
goal_5:
title: "Igualdad de Género"
description: "Lograr la igualdad entre los géneros y empoderar a todas las mujeres y las niñas."
goal_6:
title: "Agua Limpia y Saneamiento"
description: "Garantizar la disponibilidad de agua y su gestión sostenible y el saneamiento para todos."
goal_7:
title: "Energía Sostenible y No Contaminante"
description: "Garantizar el acceso a una energía asequible, segura, sostenible y moderna."
goal_8:
title: "Trabajo Decente y Crecimiento Económico"
description: "Promover el crecimiento económico inclusivo y sostenible, el empleo y el trabajo decente para todos."
goal_9:
title: "Industria, Innovación e Infraestructuras"
description: "Construir infraestructuras resilientes, promover la industrialización sostenible y fomentar la innovación."
goal_10:
title: "Reducción de las Desigualdades"
description: "Reducir la desigualdad en y entre los países."
goal_11:
title: "Ciudades y Comunidades Sostenibles"
description: "Lograr que las ciudades sean más inclusivas, seguras, resilientes y sostenibles."
goal_12:
title: "Producción y Consumo Responsables"
description: "Garantizar modalidades de consumo y producción sostenibles"
goal_13:
title: "Acción Por el Clima"
description: "Adoptar medidas urgentes para combatir el cambio climático y sus efectos."
goal_14:
title: "Vida Submarina"
description: "Conservar y utilizar sosteniblemente los océanos, los mares y los recursos marinos."
goal_15:
title: "Vida de Ecosistemas Terrestres"
description: "Gestionar sosteniblemente los bosques, luchar contra la desertificación, detener e invertir la degradación de las tierras, detener la pérdida de biodiversidad."
goal_16:
title: "Paz, Justicia e Instituciones Sólidas"
description: "Promover sociedades justas, pacíficas e inclusivas."
goal_17:
title: "Alianzas para Lograr los Objetivos"
description: "Revitalizar la Alianza Mundial para el Desarrollo Sostenible."

View File

@@ -43,5 +43,6 @@ require_relative "dev_seeds/admin_notifications"
require_relative "dev_seeds/legislation_proposals" require_relative "dev_seeds/legislation_proposals"
require_relative "dev_seeds/milestones" require_relative "dev_seeds/milestones"
require_relative "dev_seeds/pages" require_relative "dev_seeds/pages"
require_relative "dev_seeds/sdg"
log "All dev seeds created successfuly 👍" log "All dev seeds created successfuly 👍"

3
db/dev_seeds/sdg.rb Normal file
View File

@@ -0,0 +1,3 @@
section "Creating Sustainable Development Goals" do
load Rails.root.join("db", "sdg.rb")
end

3
db/sdg.rb Normal file
View File

@@ -0,0 +1,3 @@
(1..17).each do |code|
SDG::Goal.where(code: code).first_or_create!
end

View File

@@ -16,3 +16,6 @@ WebSection.where(name: "help_page").first_or_create!
# Default custom pages # Default custom pages
load Rails.root.join("db", "pages.rb") load Rails.root.join("db", "pages.rb")
# Sustainable Development Goals
load Rails.root.join("db", "sdg.rb")

View File

@@ -1,14 +1,26 @@
require "rails_helper" require "rails_helper"
describe SDG::Goal do describe SDG::Goal do
it "is valid" do describe "validations" do
expect(build(:sdg_goal)).to be_valid it "is valid with an existent code" do
goal = SDG::Goal.where(code: "1").first_or_initialize
expect(goal).to be_valid
end end
it "is not valid without a code" do it "is not valid without a code" do
expect(build(:sdg_goal, code: nil)).not_to be_valid expect(build(:sdg_goal, code: nil)).not_to be_valid
end end
it "is not valid with a nonexistent code" do
[0, 18].each do |code|
goal = SDG::Goal.where(code: code).first_or_initialize
expect(goal).not_to be_valid
end
end
end
it "translates title" do it "translates title" do
goal = SDG::Goal.where(code: "1").first_or_create! goal = SDG::Goal.where(code: "1").first_or_create!

View File

@@ -5,8 +5,6 @@ describe "Goals", :js do
describe "Index" do describe "Index" do
scenario "Visit the index" do scenario "Visit the index" do
SDG::Goal.where(code: "1").first_or_create!
visit sdg_management_root_path visit sdg_management_root_path
within("#side_menu") do within("#side_menu") do