Send to both Phase and Publication classes the enabled flag and use for enabled? helper method
This commit is contained in:
@@ -20,19 +20,21 @@ class Legislation::Process < ActiveRecord::Base
|
||||
scope :past, -> { where("end_date < ?", Date.current).order('id DESC') }
|
||||
|
||||
def debate_phase
|
||||
Legislation::Process::Phase.new(debate_start_date, debate_end_date)
|
||||
Legislation::Process::Phase.new(debate_start_date, debate_end_date, debate_phase_enabled)
|
||||
end
|
||||
|
||||
def allegations_phase
|
||||
Legislation::Process::Phase.new(allegations_start_date, allegations_end_date)
|
||||
Legislation::Process::Phase.new(allegations_start_date, allegations_end_date, allegations_phase_enabled)
|
||||
end
|
||||
|
||||
def draft_publication
|
||||
Legislation::Process::Publication.new(draft_publication_date)
|
||||
Legislation::Process::Publication.new(draft_publication_date, draft_publication_enabled)
|
||||
end
|
||||
|
||||
def result_publication
|
||||
Legislation::Process::Publication.new(result_publication_date)
|
||||
Legislation::Process::Publication.new(result_publication_date, result_publication_enabled)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def total_comments
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
|
||||
class Legislation::Process::Phase
|
||||
|
||||
def initialize(start_date, end_date)
|
||||
def initialize(start_date, end_date, enabled)
|
||||
@start_date = start_date
|
||||
@end_date = end_date
|
||||
@enabled = enabled
|
||||
end
|
||||
|
||||
def enabled?
|
||||
@start_date.present? && @end_date.present?
|
||||
@enabled
|
||||
end
|
||||
|
||||
def started?
|
||||
|
||||
@@ -2,12 +2,13 @@
|
||||
|
||||
class Legislation::Process::Publication
|
||||
|
||||
def initialize(publication_date)
|
||||
def initialize(publication_date, enabled)
|
||||
@publication_date = publication_date
|
||||
@enabled = enabled
|
||||
end
|
||||
|
||||
def enabled?
|
||||
@publication_date.present?
|
||||
@enabled
|
||||
end
|
||||
|
||||
def started?
|
||||
|
||||
Reference in New Issue
Block a user