Skip to content

Commit

Permalink
Allow getting datasets categories names from module settings
Browse files Browse the repository at this point in the history
  • Loading branch information
entantoencuanto committed Feb 12, 2020
1 parent 3d2370e commit a1a77b4
Showing 1 changed file with 8 additions and 24 deletions.
32 changes: 8 additions & 24 deletions db/seeds/modules/gobierto_data/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,11 @@
module GobiertoSeeds
class Recipe
DEFAULT_CATEGORY_NAMES = [
"Sector público",
"Transporte",
"Medio ambiente",
"Ciencia y tecnología",
"Economía",
"Medio Rural",
"Demografía",
"Hacienda",
"Educación",
"Cultura y ocio",
"Turismo",
"Empleo",
"Sociedad y bienestar",
"Urbanismo e infraestructuras",
"Comercio",
"Legislación y justicia",
"Salud",
"Seguridad",
"Industria",
"Energía",
"Deporte",
"Vivienda"
{
ca: "General",
en: "General",
es: "General"
}
].freeze

def self.run(site)
Expand Down Expand Up @@ -63,9 +46,10 @@ def self.run(site)
if vocabulary.new_record?
vocabulary.name_translations = { ca: "Categoria de conjunt de dades", en: "Dataset Category", es: "Categoría de conjunto de datos" }
vocabulary.save
DEFAULT_CATEGORY_NAMES.each do |category_name|
default_category_names = site.gobierto_data_settings.default_dataset_category_names || DEFAULT_CATEGORY_NAMES
default_category_names.each do |category_name|
vocabulary.terms.create(
name_translations: Hash[site.configuration.available_locales.product([category_name])]
name_translations: category_name.with_indifferent_access.slice(*site.configuration.available_locales)
)
end
end
Expand Down

0 comments on commit a1a77b4

Please sign in to comment.