From 9bff41eda08c7793900311d252a3269a891479a3 Mon Sep 17 00:00:00 2001 From: Cedric Hurst Date: Fri, 7 Jul 2017 14:28:07 -0500 Subject: [PATCH] #269 defaulting chapter date range to project review date range (if defined) --- app/controllers/finalists_controller.rb | 2 +- app/controllers/projects_controller.rb | 2 +- app/helpers/application_helper.rb | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/controllers/finalists_controller.rb b/app/controllers/finalists_controller.rb index 8f86db89..898aa943 100644 --- a/app/controllers/finalists_controller.rb +++ b/app/controllers/finalists_controller.rb @@ -6,7 +6,7 @@ class FinalistsController < ApplicationController include ApplicationHelper def index - @start_date, @end_date = extract_timeframe + @start_date, @end_date = extract_timeframe_for_chapter(@chapter) @projects = Project. voted_for_by_members_of(current_chapter). during_timeframe(@start_date, @end_date). diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 843d8621..7dd7613b 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -10,7 +10,7 @@ class ProjectsController < ApplicationController include ApplicationHelper def index - @start_date, @end_date = extract_timeframe + @start_date, @end_date = extract_timeframe_for_chapter(@chapter) @short_listed = params[:short_list] project_filter = ProjectFilter.new(@chapter.projects).during(@start_date, @end_date) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 9d89bed3..45ec41a1 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,7 +1,12 @@ module ApplicationHelper def extract_timeframe start_date = params[:start] - end_date = params[:end] + end_date = params[:end] + end + + def extract_timeframe_for_chapter(chapter) + start_date = params[:start] || chapter.project_review_start.to_s + end_date = params[:start] || chapter.project_review_end.to_s [start_date, end_date] end