Send to both Phase and Publication classes the enabled flag and use for enabled? helper method

This commit is contained in:
Bertocq
2017-06-13 23:47:14 +02:00
parent bae9d105fa
commit cb7358bb97
3 changed files with 12 additions and 8 deletions

View File

@@ -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

View File

@@ -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?

View File

@@ -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?