diff options
-rw-r--r-- | app/controllers/holiday_controller.rb | 3 | ||||
-rw-r--r-- | app/models/holiday.rb | 11 | ||||
-rw-r--r-- | app/models/info_request.rb | 8 | ||||
-rw-r--r-- | config/general.yml-example | 3 |
4 files changed, 21 insertions, 4 deletions
diff --git a/app/controllers/holiday_controller.rb b/app/controllers/holiday_controller.rb index 3a37b8d32..9430c0756 100644 --- a/app/controllers/holiday_controller.rb +++ b/app/controllers/holiday_controller.rb @@ -15,7 +15,8 @@ class HolidayController < ApplicationController if params[:holiday] @request_date = Date.strptime(params[:holiday]) or raise "Invalid date" days_later = MySociety::Config.get('REPLY_LATE_AFTER_DAYS', 20) - @due_date = Holiday.due_date_from_working_days(@request_date, days_later) + working_or_calendar_days = MySociety::Config.get('WORKING_OR_CALENDAR_DAYS', 'working') + @due_date = Holiday.due_date_from(@request_date, days_later, working_or_calendar_days) @skipped = Holiday.all( :conditions => [ 'day >= ? AND day <= ?', @request_date.strftime("%F"), @due_date.strftime("%F") diff --git a/app/models/holiday.rb b/app/models/holiday.rb index efa516e1c..2a697a7a2 100644 --- a/app/models/holiday.rb +++ b/app/models/holiday.rb @@ -32,6 +32,17 @@ class Holiday < ActiveRecord::Base date.wday == 0 || date.wday == 6 || holidays.include?(date) end + def Holiday.due_date_from(start_date, days, type_of_days) + case type_of_days + when "working" + Holiday.due_date_from_working_days(start_date, days) + when "calendar" + Holiday.due_date_from_calendar_days(start_date, days) + else + raise "Unexpected value for type_of_days: #{type_of_days}" + end + end + # Calculate the date on which a request made on a given date falls due when # days are given in working days # i.e. it is due by the end of that day. diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 05f9195b3..aa4f7537a 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -688,7 +688,8 @@ public # things, e.g. fees, not properly covered. def date_response_required_by days_later = MySociety::Config.get('REPLY_LATE_AFTER_DAYS', 20) - return Holiday.due_date_from_working_days(self.date_initial_request_last_sent_at, days_later) + working_or_calendar_days = MySociety::Config.get('WORKING_OR_CALENDAR_DAYS', 'working') + return Holiday.due_date_from(self.date_initial_request_last_sent_at, days_later, working_or_calendar_days) end # This is a long stop - even with UK public interest test extensions, 40 # days is a very long time. @@ -696,12 +697,13 @@ public last_sent = last_event_forming_initial_request very_late_days_later = MySociety::Config.get('REPLY_VERY_LATE_AFTER_DAYS', 40) school_very_late_days_later = MySociety::Config.get('SPECIAL_REPLY_VERY_LATE_AFTER_DAYS', 60) + working_or_calendar_days = MySociety::Config.get('WORKING_OR_CALENDAR_DAYS', 'working') if self.public_body.is_school? # schools have 60 working days maximum (even over a long holiday) - return Holiday.due_date_from_working_days(self.date_initial_request_last_sent_at, school_very_late_days_later) + return Holiday.due_date_from(self.date_initial_request_last_sent_at, school_very_late_days_later, working_or_calendar_days) else # public interest test ICO guidance gives 40 working maximum - return Holiday.due_date_from_working_days(self.date_initial_request_last_sent_at, very_late_days_later) + return Holiday.due_date_from(self.date_initial_request_last_sent_at, very_late_days_later, working_or_calendar_days) end end diff --git a/config/general.yml-example b/config/general.yml-example index a6f657d96..fd27b151a 100644 --- a/config/general.yml-example +++ b/config/general.yml-example @@ -30,6 +30,9 @@ REPLY_LATE_AFTER_DAYS: 20 REPLY_VERY_LATE_AFTER_DAYS: 40 # We give some types of authority like schools a bit longer than everyone else SPECIAL_REPLY_VERY_LATE_AFTER_DAYS: 60 +# Whether the days above are given in working or calendar days. Value can be "working" or "calendar". +# Default is "working". +WORKING_OR_CALENDAR_DAYS: working # example public bodies for the home page, semicolon delimited - short_names FRONTPAGE_PUBLICBODY_EXAMPLES: 'tgq' |