Class: Decidim::System::CreateDefaultPages
- Inherits:
-
Command
- Object
- Command
- Decidim::System::CreateDefaultPages
- Defined in:
- app/commands/decidim/system/create_default_pages.rb
Overview
A command with all the business logic when creating a new organization in the system. It creates the organization and invites the admin to the system.
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(organization) ⇒ CreateDefaultPages
constructor
Public: Initializes the command.
Constructor Details
#initialize(organization) ⇒ CreateDefaultPages
Public: Initializes the command.
form - A form object with the params.
12 13 14 |
# File 'app/commands/decidim/system/create_default_pages.rb', line 12 def initialize(organization) @organization = organization end |
Instance Method Details
#call ⇒ Object
Executes the command. i18n-tasks-use t(‘decidim.system.default_pages.terms-of-service’)
Returns nothing.
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/commands/decidim/system/create_default_pages.rb', line 20 def call Decidim::StaticPage::DEFAULT_PAGES.map do |slug| static_page = Decidim::StaticPage.find_or_create_by!(organization:, slug:) do |page| translated_slug = I18n.t(slug, scope: "decidim.system.default_pages") page.title = localized_attribute(translated_slug, :title) page.content = localized_attribute(translated_slug, :content) page.allow_public_access = true if slug == "terms-of-service" end create_summary_content_blocks_for(static_page) if slug == "terms-of-service" end end |