Class: Decidim::System::CreateDefaultHelpPages
- Inherits:
-
Command
- Object
- Command
- Decidim::System::CreateDefaultHelpPages
- Includes:
- TranslatableAttributes
- Defined in:
- app/commands/decidim/system/create_default_help_pages.rb
Overview
A command that will create default help pages for an organization.
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(organization) ⇒ CreateDefaultHelpPages
constructor
Public: Initializes the command.
- #multi_translation(key) ⇒ Object
- #organization_name ⇒ Object
Constructor Details
#initialize(organization) ⇒ CreateDefaultHelpPages
Public: Initializes the command.
organization - An organization
12 13 14 |
# File 'app/commands/decidim/system/create_default_help_pages.rb', line 12 def initialize(organization) @organization = organization end |
Instance Method Details
#call ⇒ Object
Executes the command.
Returns nothing.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/commands/decidim/system/create_default_help_pages.rb', line 19 def call ActiveRecord::Base.transaction do topic = Decidim::StaticPageTopic.create!( title: multi_translation("decidim.help.main_topic.title", organization: organization_name), description: multi_translation("decidim.help.main_topic.description", organization: organization_name), organization: @organization, show_in_footer: true, weight: 0 ) Decidim::StaticPage.create!( slug: "help", title: multi_translation("decidim.help.main_topic.default_page.title", organization: organization_name), content: multi_translation("decidim.help.main_topic.default_page.content", organization: organization_name), topic:, organization: @organization, weight: 0 ) Decidim.participatory_space_manifests.each do |manifest| scope = "decidim.help.participatory_spaces.#{manifest.name}" next unless I18n.exists?(scope) Decidim::StaticPage.create!( title: multi_translation("#{scope}.title"), content: multi_translation("#{scope}.page"), slug: manifest.name, topic:, organization: @organization ) ContextualHelpSection.set_content(@organization, manifest.name, multi_translation("#{scope}.contextual")) end end end |
#multi_translation(key) ⇒ Object
55 56 57 |
# File 'app/commands/decidim/system/create_default_help_pages.rb', line 55 def multi_translation(key, **) Decidim::TranslationsHelper.multi_translation(key, @organization.available_locales, **) end |
#organization_name ⇒ Object
59 60 61 |
# File 'app/commands/decidim/system/create_default_help_pages.rb', line 59 def organization_name translated_attribute(@organization.name) end |