diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/holiday.rb | 8 | ||||
-rw-r--r-- | app/models/info_request.rb | 7 | ||||
-rw-r--r-- | app/models/public_body.rb | 7 |
3 files changed, 14 insertions, 8 deletions
diff --git a/app/models/holiday.rb b/app/models/holiday.rb index cf67e6963..422ddf291 100644 --- a/app/models/holiday.rb +++ b/app/models/holiday.rb @@ -21,20 +21,20 @@ # Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: holiday.rb,v 1.8 2009-09-17 21:30:15 francis Exp $ +# $Id: holiday.rb,v 1.9 2009-10-02 22:56:35 francis Exp $ class Holiday < ActiveRecord::Base # Calculate the date on which a request made on a given date falls due. # i.e. it is due by the end of that day. - def Holiday.due_date_from(start_date) + def Holiday.due_date_from(start_date, working_days = 20) # convert date/times into dates start_date = start_date.to_date # TODO only fetch holidays after the start_date holidays = self.all.collect { |h| h.day }.to_set - # Count forward 20 working days. We start with today as "day zero". The + # Count forward (20) working days. We start with today as "day zero". The # first of the twenty full working days is the next day. We return the # date of the last of the twenty. @@ -47,7 +47,7 @@ class Holiday < ActiveRecord::Base response_required_by = start_date # Now step forward into each of the 20 days. - while days_passed < 20 + while days_passed < working_days response_required_by += 1.day next if response_required_by.wday == 0 || response_required_by.wday == 6 # weekend next if holidays.include?(response_required_by) diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 17a19d0e4..10e26d48d 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -24,7 +24,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: info_request.rb,v 1.208 2009-10-01 12:01:26 francis Exp $ +# $Id: info_request.rb,v 1.209 2009-10-02 22:56:35 francis Exp $ require 'digest/sha1' require File.join(File.dirname(__FILE__),'../../vendor/plugins/acts_as_xapian/lib/acts_as_xapian') @@ -558,8 +558,9 @@ public return Holiday.due_date_from(last_sent.outgoing_message.last_sent_at) end - def days_overdue - return Time.now.to_date - date_response_required_by.to_date + # Are we more than 20 working days overdue? + def working_days_20_overdue? + return Holiday.due_date_from(date_response_required_by.to_date, 20) <= Time.now.to_date end # Where the initial request is sent to diff --git a/app/models/public_body.rb b/app/models/public_body.rb index aef2d66a9..dd386d593 100644 --- a/app/models/public_body.rb +++ b/app/models/public_body.rb @@ -26,7 +26,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: public_body.rb,v 1.159 2009-09-17 21:10:05 francis Exp $ +# $Id: public_body.rb,v 1.160 2009-10-02 22:56:35 francis Exp $ require 'csv' require 'set' @@ -281,6 +281,11 @@ class PublicBody < ActiveRecord::Base end end + # Schools are allowed more time in holidays, so we change some wordings + def is_school? + return self.has_tag?('school') + end + # The "internal admin" is a special body for internal use. def PublicBody.internal_admin_body pb = PublicBody.find_by_url_name("internal_admin_authority") |