Refactor concept of current budget
When there was only one budget this implementation worked fine Nowadays there can be multiple budgets, and therefore the definition of the current_budget has changed. It is no longer a budget that has not finished, but rather, the last budget created that is not in the initial drafting phase. Budgets in the drafting phase are not considered the current_budget, but rather a budget that is still being prepared and that soon will become the current_budget
This commit is contained in:
@@ -31,7 +31,9 @@ class Budget < ActiveRecord::Base
|
||||
scope :reviewing_ballots, -> { where(phase: "reviewing_ballots") }
|
||||
scope :finished, -> { where(phase: "finished") }
|
||||
|
||||
scope :current, -> { where.not(phase: "finished") }
|
||||
def self.current
|
||||
where.not(phase: "drafting").last
|
||||
end
|
||||
|
||||
def description
|
||||
send("description_#{phase}").try(:html_safe)
|
||||
@@ -93,10 +95,6 @@ class Budget < ActiveRecord::Base
|
||||
balloting_process? || finished?
|
||||
end
|
||||
|
||||
def current?
|
||||
!finished?
|
||||
end
|
||||
|
||||
def heading_price(heading)
|
||||
heading_ids.include?(heading.id) ? heading.price : -1
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user