app/models/decidim/plans/plan.rb in decidim-plans-0.16.6 vs app/models/decidim/plans/plan.rb in decidim-plans-0.16.7
- old
+ new
@@ -35,10 +35,16 @@
has_many :attached_proposals, foreign_key: :decidim_plan_id, dependent: :destroy
has_many :proposals, through: :attached_proposals
has_many :contents, foreign_key: :decidim_plan_id, dependent: :destroy
+ has_many :taggings,
+ class_name: "Decidim::Plans::PlanTagging",
+ foreign_key: :decidim_plan_id,
+ dependent: :destroy
+ has_many :tags, through: :taggings
+
scope :open, -> { where(state: "open") }
scope :accepted, -> { where(state: "accepted") }
scope :rejected, -> { where(state: "rejected") }
scope :evaluating, -> { where(state: "evaluating") }
scope :withdrawn, -> { where(state: "withdrawn") }
@@ -102,9 +108,17 @@
# Public: Checks if the plan has been closed or not.
#
# Returns Boolean.
def closed?
closed_at.present?
+ end
+
+ # Public: Checks if the plan has been closed AND not yet answered. This is
+ # interpreted as the plan waiting to be evaluated.
+ #
+ # Returns Boolean.
+ def waiting_for_evaluation?
+ closed? && !answered?
end
# Public: Checks if the organization has given an answer for the plan.
#
# Returns Boolean.