Sha256: 91aa7ef4fb531cc651d79e8596c2975dfbbba30cfec05dc89a5ab10573af6f44

Contents?: true

Size: 875 Bytes

Versions: 44

Compression:

Stored size: 875 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # Attachment can be any type of document or images related to a partcipatory
  # process.
  class ContentBlockAttachment < ApplicationRecord
    include Decidim::HasUploadValidations

    belongs_to :content_block, foreign_key: "decidim_content_block_id", class_name: "Decidim::ContentBlock", inverse_of: :attachments

    has_one_attached :file
    validates_upload :file

    delegate :attached?, to: :file
    delegate :organization, :manifest, to: :content_block

    def uploader
      return if content_block.blank?

      config = manifest.images.find do |image_config|
        image_config[:name].to_s == name.to_s
      end

      return if config.blank?

      config[:uploader].constantize
    end

    def attached_uploader(name)
      return unless name == :file

      uploader.new(self, :file)
    end
  end
end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
decidim-core-0.29.1 app/models/decidim/content_block_attachment.rb
decidim-core-0.28.4 app/models/decidim/content_block_attachment.rb
decidim-core-0.27.9 app/models/decidim/content_block_attachment.rb
decidim-core-0.29.0 app/models/decidim/content_block_attachment.rb
decidim-core-0.28.3 app/models/decidim/content_block_attachment.rb
decidim-core-0.27.8 app/models/decidim/content_block_attachment.rb
decidim-core-0.29.0.rc4 app/models/decidim/content_block_attachment.rb
decidim-core-0.29.0.rc3 app/models/decidim/content_block_attachment.rb
decidim-core-0.29.0.rc2 app/models/decidim/content_block_attachment.rb
decidim-core-0.29.0.rc1 app/models/decidim/content_block_attachment.rb
decidim-core-0.28.2 app/models/decidim/content_block_attachment.rb
decidim-core-0.27.7 app/models/decidim/content_block_attachment.rb
decidim-core-0.28.1 app/models/decidim/content_block_attachment.rb
decidim-core-0.27.6 app/models/decidim/content_block_attachment.rb
decidim-core-0.26.10 app/models/decidim/content_block_attachment.rb
decidim-core-0.26.9 app/models/decidim/content_block_attachment.rb
decidim-core-0.28.0 app/models/decidim/content_block_attachment.rb
decidim-core-0.27.5 app/models/decidim/content_block_attachment.rb
decidim-core-0.28.0.rc5 app/models/decidim/content_block_attachment.rb
decidim-core-0.28.0.rc4 app/models/decidim/content_block_attachment.rb