Sha256: 678b8a578c49e4290fc4359515e0238f8b11ffa21d64f19a93328aa2eddc8c43
Contents?: true
Size: 1.64 KB
Versions: 4
Compression:
Stored size: 1.64 KB
Contents
# frozen_string_literal: true module Decidim module System # 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. class UpdateOrganization < Rectify::Command # Public: Initializes the command. # # form - A form object with the params. def initialize(id, form) @organization_id = id @form = form end # Executes the command. Broadcasts these events: # # - :ok when everything is valid. # - :invalid if the form wasn't valid and we couldn't proceed. # # Returns nothing. def call return broadcast(:invalid) if form.invalid? transaction do save_organization end broadcast(:ok) rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotUnique broadcast(:invalid) end private attr_reader :form, :organization_id def organization @organization ||= Organization.find(organization_id) end def save_organization organization.name = form.name organization.host = form.host organization.secondary_hosts = form.clean_secondary_hosts organization.force_users_to_authenticate_before_access_organization = form.force_users_to_authenticate_before_access_organization organization.available_authorizations = form.clean_available_authorizations organization.users_registration_mode = form.users_registration_mode organization.smtp_settings = form.encrypted_smtp_settings organization.save! end end end end
Version data entries
4 entries across 4 versions & 1 rubygems