Sha256: 5b0639ea020b4899879ce026877d43d5ccb1c9973e035691c974c2f997d1434d

Contents?: true

Size: 849 Bytes

Versions: 6

Compression:

Stored size: 849 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Admin
    class UpdateExternalDomainAllowlist < Decidim::Command
      attr_reader :form, :organization

      delegate :current_user, to: :form

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

      def call
        return broadcast(:invalid) if form.invalid?

        Decidim.traceability.perform_action!("update_external_domain", @organization, current_user) do
          save_domains!
        end

        broadcast(:ok)
      end

      private

      def save_domains!
        organization.external_domain_allowlist = form.external_domains.filter_map do |external_domain_form|
          external_domain_form.value unless external_domain_form.deleted
        end.flatten

        organization.save!
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
decidim-admin-0.29.1 app/commands/decidim/admin/update_external_domain_allowlist.rb
decidim-admin-0.29.0 app/commands/decidim/admin/update_external_domain_allowlist.rb
decidim-admin-0.29.0.rc4 app/commands/decidim/admin/update_external_domain_allowlist.rb
decidim-admin-0.29.0.rc3 app/commands/decidim/admin/update_external_domain_allowlist.rb
decidim-admin-0.29.0.rc2 app/commands/decidim/admin/update_external_domain_allowlist.rb
decidim-admin-0.29.0.rc1 app/commands/decidim/admin/update_external_domain_allowlist.rb