Sha256: 2f805e51a783d50206b43686bf786bf6f71267fbe9666f3bd6ecb5b7d926cfe4

Contents?: true

Size: 721 Bytes

Versions: 8

Compression:

Stored size: 721 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Admin
    # A form object to create or update pages.
    class StaticPageForm < Form
      include TranslatableAttributes

      attribute :slug, String
      translatable_attribute :title, String
      translatable_attribute :content, String

      mimic :static_page

      validates :slug, presence: true
      validates :title, :content, translatable_presence: true
      validate :slug, :slug_uniqueness

      alias organization current_organization

      private

      def slug_uniqueness
        return unless organization && organization.static_pages.where(slug: slug).where.not(id: id).any?

        errors.add(:slug, :taken)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
decidim-admin-0.3.2 app/forms/decidim/admin/static_page_form.rb
decidim-0.3.2 decidim-admin/app/forms/decidim/admin/static_page_form.rb
decidim-admin-0.3.1 app/forms/decidim/admin/static_page_form.rb
decidim-0.3.1 decidim-admin/app/forms/decidim/admin/static_page_form.rb
decidim-admin-0.3.0 app/forms/decidim/admin/static_page_form.rb
decidim-0.3.0 decidim-admin/app/forms/decidim/admin/static_page_form.rb
decidim-admin-0.2.0 app/forms/decidim/admin/static_page_form.rb
decidim-0.2.0 decidim-admin/app/forms/decidim/admin/static_page_form.rb