diff --git a/app/controllers/concerns/commentable_actions.rb b/app/controllers/concerns/commentable_actions.rb index ef5e60dcb..ee69ac809 100644 --- a/app/controllers/concerns/commentable_actions.rb +++ b/app/controllers/concerns/commentable_actions.rb @@ -129,16 +129,16 @@ module CommentableActions when '4' 1.year.ago else - Date.parse(params[:advanced_search][:date_min]) rescue nil + Date.parse(params[:advanced_search][:date_min]) rescue 100.years.ago end end def search_finish_date - params[:advanced_search][:date_max].try(:to_date) || Date.today + (params[:advanced_search][:date_max].to_date rescue Date.today) || Date.today end def search_date_range - search_start_date.beginning_of_day..search_finish_date.end_of_day + [100.years.ago, search_start_date].max.beginning_of_day..[search_finish_date, Date.today].min.end_of_day end def set_search_order diff --git a/app/models/budget/investment.rb b/app/models/budget/investment.rb index 99e0eb25a..4bfd038c3 100644 --- a/app/models/budget/investment.rb +++ b/app/models/budget/investment.rb @@ -25,6 +25,7 @@ class Budget validates :description, presence: true validates :heading_id, presence: true validates_presence_of :unfeasibility_explanation, if: :unfeasibility_explanation_required? + validates_presence_of :price, if: :price_required? validates :title, length: { in: 4..Budget::Investment.title_max_length } validates :description, length: { maximum: Budget::Investment.description_max_length } @@ -136,6 +137,10 @@ class Budget unfeasible? && valuation_finished? end + def price_required? + feasible? && valuation_finished? + end + def unfeasible_email_pending? unfeasible_email_sent_at.blank? && unfeasible? && valuation_finished? end diff --git a/app/views/budgets/investments/_investment_show.html.erb b/app/views/budgets/investments/_investment_show.html.erb index ebac39186..d97a1fbfb 100644 --- a/app/views/budgets/investments/_investment_show.html.erb +++ b/app/views/budgets/investments/_investment_show.html.erb @@ -103,7 +103,7 @@