Class: Decidim::Admin::UpdateOrganizationTosVersion

Inherits:
Command
  • Object
show all
Defined in:
app/commands/decidim/admin/update_organization_tos_version.rb

Overview

A command with the business logic for updating the current organization tos_version attribute.

Instance Method Summary collapse

Constructor Details

#initialize(organization, page, form) ⇒ UpdateOrganizationTosVersion

Public: Initializes the command.

organization - The Organization that will be updated. page - A static_page instance (slug = “terms-and-conditions”). form - A form object with the params.



13
14
15
16
17
# File 'app/commands/decidim/admin/update_organization_tos_version.rb', line 13

def initialize(organization, page, form)
  @organization = organization
  @page = page
  @form = form
end

Instance Method Details

#callObject

Executes the command. Broadcasts these events:

  • :ok when everything is valid.

  • :invalid if the form wasn’t valid or not the TOS page.

Returns nothing.



25
26
27
28
29
30
31
32
# File 'app/commands/decidim/admin/update_organization_tos_version.rb', line 25

def call
  return broadcast(:invalid) if @form.nil?
  return broadcast(:invalid) if @page.nil?
  return broadcast(:invalid) unless @page.slug == "terms-and-conditions"

  update_organization_tos_version
  broadcast(:ok)
end