Class: Decidim::System::CreateDefaultPages

Inherits:
Rectify::Command
  • Object
show all
Defined in:
decidim-system/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

Constructor Details

#initialize(organization) ⇒ CreateDefaultPages

Public: Initializes the command.

form - A form object with the params.


12
13
14
# File 'decidim-system/app/commands/decidim/system/create_default_pages.rb', line 12

def initialize(organization)
  @organization = organization
end

Instance Method Details

#callObject

Executes the command.

Returns nothing.


19
20
21
22
23
24
25
26
27
28
# File 'decidim-system/app/commands/decidim/system/create_default_pages.rb', line 19

def call
  Decidim::StaticPage::DEFAULT_PAGES.map do |slug|
    Decidim::StaticPage.find_or_create_by!(organization: organization, slug: slug) do |page|
      page.title = localized_attribute(slug, :title)
      page.content = localized_attribute(slug, :content)
      page.show_in_footer = true
      page.allow_public_access = true if slug == "terms-and-conditions"
    end
  end
end