Sha256: f3a68faccafd063aa7f00d2f2453884ca32a813016f2487d5a0fb19809b208cd

Contents?: true

Size: 833 Bytes

Versions: 12

Compression:

Stored size: 833 Bytes

Contents

# frozen_string_literal: true

module Decidim
  class Amendment < ApplicationRecord
    STATES = %w(draft evaluating accepted rejected withdrawn).freeze

    belongs_to :amendable, foreign_key: "decidim_amendable_id", foreign_type: "decidim_amendable_type", polymorphic: true
    belongs_to :amender, foreign_key: "decidim_user_id", class_name: "Decidim::User"
    belongs_to :emendation, foreign_key: "decidim_emendation_id", foreign_type: "decidim_emendation_type", polymorphic: true

    validates :state, presence: true, inclusion: { in: STATES }

    def draft?
      state == "draft"
    end

    def evaluating?
      state == "evaluating"
    end

    def rejected?
      state == "rejected"
    end

    def promoted?
      return false unless rejected?

      emendation.linked_promoted_resource.present?
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
decidim-core-0.27.9 app/models/decidim/amendment.rb
decidim-core-0.27.8 app/models/decidim/amendment.rb
decidim-core-0.27.7 app/models/decidim/amendment.rb
decidim-core-0.27.6 app/models/decidim/amendment.rb
decidim-core-0.27.5 app/models/decidim/amendment.rb
decidim-core-0.27.4 app/models/decidim/amendment.rb
decidim-core-0.27.3 app/models/decidim/amendment.rb
decidim-core-0.27.2 app/models/decidim/amendment.rb
decidim-core-0.27.1 app/models/decidim/amendment.rb
decidim-core-0.27.0 app/models/decidim/amendment.rb
decidim-core-0.27.0.rc2 app/models/decidim/amendment.rb
decidim-core-0.27.0.rc1 app/models/decidim/amendment.rb