Sha256: 04a055df3bacbc9c98c9616a415fb079ce77674a4595df2d737763444c895966

Contents?: true

Size: 1.42 KB

Versions: 18

Compression:

Stored size: 1.42 KB

Contents

# frozen_string_literal: true

module Decidim
  # Interaction between a user and an organization can be done via an Assembly.
  # It's a unit of action from the Organization point of view that groups
  # several features (proposals, debates...) that can be enabled or disabled.
  class Assembly < ApplicationRecord
    include Decidim::HasAttachments
    include Decidim::Participable
    include Decidim::Publicable
    include Decidim::Scopable

    belongs_to :organization,
               foreign_key: "decidim_organization_id",
               class_name: "Decidim::Organization"
    belongs_to :scope,
               foreign_key: "decidim_scope_id",
               class_name: "Decidim::Scope",
               optional: true
    has_many :categories,
             foreign_key: "decidim_participatory_space_id",
             foreign_type: "decidim_participatory_space_type",
             dependent: :destroy,
             as: :participatory_space

    has_many :features, as: :participatory_space

    validates :slug, presence: true
    validates :slug, uniqueness: { scope: :organization }

    mount_uploader :hero_image, Decidim::HeroImageUploader
    mount_uploader :banner_image, Decidim::BannerImageUploader

    # Scope to return only the promoted assemblies.
    #
    # Returns an ActiveRecord::Relation.
    def self.promoted
      where(promoted: true)
    end

    def hashtag
      attributes["hashtag"].to_s.delete("#")
    end
  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
decidim-assemblies-0.6.8 app/models/decidim/assembly.rb
decidim-0.6.8 decidim-assemblies/app/models/decidim/assembly.rb
decidim-assemblies-0.6.7 app/models/decidim/assembly.rb
decidim-0.6.7 decidim-assemblies/app/models/decidim/assembly.rb
decidim-assemblies-0.6.6 app/models/decidim/assembly.rb
decidim-0.6.6 decidim-assemblies/app/models/decidim/assembly.rb
decidim-assemblies-0.6.5 app/models/decidim/assembly.rb
decidim-0.6.5 decidim-assemblies/app/models/decidim/assembly.rb
decidim-assemblies-0.6.4 app/models/decidim/assembly.rb
decidim-0.6.4 decidim-assemblies/app/models/decidim/assembly.rb
decidim-assemblies-0.6.3 app/models/decidim/assembly.rb
decidim-0.6.3 decidim-assemblies/app/models/decidim/assembly.rb
decidim-assemblies-0.6.2 app/models/decidim/assembly.rb
decidim-0.6.2 decidim-assemblies/app/models/decidim/assembly.rb
decidim-assemblies-0.6.1 app/models/decidim/assembly.rb
decidim-0.6.1 decidim-assemblies/app/models/decidim/assembly.rb
decidim-assemblies-0.6.0 app/models/decidim/assembly.rb
decidim-0.6.0 decidim-assemblies/app/models/decidim/assembly.rb