Sha256: 62741a00f06809a05c10d091035361d785b1c51ab3e6cdbdab74e406035b5146

Contents?: true

Size: 1.46 KB

Versions: 3

Compression:

Stored size: 1.46 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 :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

3 entries across 3 versions & 2 rubygems

Version Path
decidim-admin-0.0.5 app/forms/decidim/admin/organization_form.rb
decidim-0.0.5 decidim-admin/app/forms/decidim/admin/organization_form.rb
decidim-0.0.4 decidim-admin/app/forms/decidim/admin/organization_form.rb