Sha256: 32f80877e4e6f897c312e47ed438b5d601b8e7e189dde63344f22c0b0b84dfb4

Contents?: true

Size: 1.57 KB

Versions: 8

Compression:

Stored size: 1.57 KB

Contents

# frozen_string_literal: true

module Decidim
  module Admin
    # A form object used to update the current organization from the admin
    # dashboard.
    #
    class OrganizationForm < Form
      include TranslatableAttributes

      mimic :organization

      attribute :name, String
      attribute :reference_prefix, String
      attribute :twitter_handler, String
      attribute :facebook_handler, String
      attribute :instagram_handler, String
      attribute :youtube_handler, String
      attribute :github_handler, String
      attribute :default_locale, String
      attribute :homepage_image
      attribute :logo
      attribute :favicon
      attribute :official_url
      attribute :official_img_header
      attribute :official_img_footer
      attribute :show_statistics

      translatable_attribute :description, String
      translatable_attribute :welcome_text, String

      validates :name, presence: true
      validates :default_locale, presence: true
      validates :default_locale, inclusion: { in: :available_locales }

      validates :official_img_header,
                file_size: { less_than_or_equal_to: ->(_record) { Decidim.maximum_attachment_size } },
                file_content_type: { allow: ["image/jpeg", "image/png"] }
      validates :official_img_footer,
                file_size: { less_than_or_equal_to: ->(_record) { Decidim.maximum_attachment_size } },
                file_content_type: { allow: ["image/jpeg", "image/png"] }

      private

      def available_locales
        current_organization.available_locales
      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/organization_form.rb
decidim-0.3.2 decidim-admin/app/forms/decidim/admin/organization_form.rb
decidim-admin-0.3.1 app/forms/decidim/admin/organization_form.rb
decidim-0.3.1 decidim-admin/app/forms/decidim/admin/organization_form.rb
decidim-admin-0.3.0 app/forms/decidim/admin/organization_form.rb
decidim-0.3.0 decidim-admin/app/forms/decidim/admin/organization_form.rb
decidim-admin-0.2.0 app/forms/decidim/admin/organization_form.rb
decidim-0.2.0 decidim-admin/app/forms/decidim/admin/organization_form.rb