lib/decidim/initiatives/participatory_space.rb in decidim-initiatives-0.9.1 vs lib/decidim/initiatives/participatory_space.rb in decidim-initiatives-0.11.0.pre1
- old
+ new
@@ -2,11 +2,10 @@
Decidim.register_participatory_space(:initiatives) do |participatory_space|
participatory_space.context(:public) do |context|
context.engine = Decidim::Initiatives::Engine
context.layout = "layouts/decidim/initiative"
- context.helper = "Decidim::Initiatives::PartialTranslationsHelper"
end
participatory_space.context(:admin) do |context|
context.engine = Decidim::Initiatives::AdminEngine
context.layout = "layouts/decidim/admin/initiatives"
@@ -14,22 +13,22 @@
participatory_space.participatory_spaces do |organization|
Decidim::Initiative.where(organization: organization)
end
- participatory_space.model_class_name = 'Decidim::Initiative'
+ participatory_space.model_class_name = "Decidim::Initiative"
participatory_space.seeds do
- seeds_root = File.join(__dir__, '..', '..', '..', 'db', 'seeds')
+ seeds_root = File.join(__dir__, "..", "..", "..", "db", "seeds")
organization = Decidim::Organization.first
3.times do |n|
type = Decidim::InitiativesType.create!(
title: Decidim::Faker::Localized.sentence(5),
description: Decidim::Faker::Localized.sentence(25),
organization: organization,
- banner_image: File.new(File.join(seeds_root, 'city2.jpeg'))
+ banner_image: File.new(File.join(seeds_root, "city2.jpeg"))
)
organization.top_scopes.each do |scope|
Decidim::InitiativesTypeScope.create(
type: type,
@@ -38,35 +37,38 @@
)
end
end
7.times do
+ Decidim::Initiative.skip_callback(:save, :after, :notify_state_change, raise: false)
+ Decidim::Initiative.skip_callback(:create, :after, :notify_creation, raise: false)
+
initiative = Decidim::Initiative.create!(
title: Decidim::Faker::Localized.sentence(3),
description: Decidim::Faker::Localized.sentence(25),
- scoped_type: Decidim::InitiativesTypeScope.reorder('RANDOM()').first,
- state: 'published',
- signature_type: 'online',
- signature_start_time: DateTime.now - 7.days,
- signature_end_time: DateTime.now + 7.days,
- published_at: DateTime.now - 7.days,
- author: Decidim::User.reorder('RANDOM()').first,
+ scoped_type: Decidim::InitiativesTypeScope.reorder("RANDOM()").first,
+ state: "published",
+ signature_type: "online",
+ signature_start_time: DateTime.current - 7.days,
+ signature_end_time: DateTime.current + 7.days,
+ published_at: DateTime.current - 7.days,
+ author: Decidim::User.reorder("RANDOM()").first,
organization: organization
)
Decidim::Comments::Seed.comments_for(initiative)
- Decidim::Initiatives.default_features.each do |feature_name|
- feature = Decidim::Feature.create!(
- name: Decidim::Features::Namer.new(initiative.organization.available_locales, feature_name).i18n_name,
- manifest_name: feature_name,
+ Decidim::Initiatives.default_components.each do |component_name|
+ component = Decidim::Component.create!(
+ name: Decidim::Components::Namer.new(initiative.organization.available_locales, component_name).i18n_name,
+ manifest_name: component_name,
published_at: Time.current,
participatory_space: initiative
)
- next unless feature_name == :pages
+ next unless component_name == :pages
- Decidim::Pages::CreatePage.call(feature) do
+ Decidim::Pages::CreatePage.call(component) do
on(:invalid) { raise "Can't create page" }
end
end
end
end