Sha256: 3849088b9e077a4f047187993be56d8f8a184d99f6bf09487ac0514f0222804f

Contents?: true

Size: 694 Bytes

Versions: 9

Compression:

Stored size: 694 Bytes

Contents

# frozen_string_literal: true
require "decidim/translatable_attributes"

module Decidim
  module System
    # A form object used to update organizations from the system dashboard.
    #
    class UpdateOrganizationForm < Form
      include TranslatableAttributes

      mimic :organization

      attribute :name, String
      attribute :host, String

      validate :validate_organization_uniqueness

      private

      def validate_organization_uniqueness
        errors.add(:name, :taken) if Decidim::Organization.where(name: name).where.not(id: id).exists?
        errors.add(:host, :taken) if Decidim::Organization.where(host: host).where.not(id: id).exists?
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
decidim-system-0.0.5 app/forms/decidim/system/update_organization_form.rb
decidim-0.0.5 decidim-system/app/forms/decidim/system/update_organization_form.rb
decidim-0.0.4 decidim-system/app/forms/decidim/system/update_organization_form.rb
decidim-system-0.0.3 app/forms/decidim/system/update_organization_form.rb
decidim-0.0.3 decidim-system/app/forms/decidim/system/update_organization_form.rb
decidim-system-0.0.2 app/forms/decidim/system/update_organization_form.rb
decidim-0.0.2 decidim-system/app/forms/decidim/system/update_organization_form.rb
decidim-system-0.0.1 app/forms/decidim/system/update_organization_form.rb
decidim-0.0.1 decidim-system/app/forms/decidim/system/update_organization_form.rb