aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/holiday_controller.rb26
-rw-r--r--app/views/holiday/due_date.rhtml6
-rw-r--r--config/routes.rb6
3 files changed, 37 insertions, 1 deletions
diff --git a/app/controllers/holiday_controller.rb b/app/controllers/holiday_controller.rb
new file mode 100644
index 000000000..215d6b5b7
--- /dev/null
+++ b/app/controllers/holiday_controller.rb
@@ -0,0 +1,26 @@
+# app/controllers/holiday_controller.rb:
+# Calculate dates
+#
+# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
+# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+#
+# $Id: holiday_controller.rb,v 1.1 2009-03-16 15:55:03 tony Exp $
+
+class HolidayController < ApplicationController
+
+ # This will be tidied up into a proper calendar display etc. For now
+ # we have a very basic page that allows us to see what a due date will
+ # be given a start date. This isn't exposed anywhere yet.
+ def due_date
+ if params[:holiday]
+ @request_date = Date.strptime(params[:holiday]) or raise "Invalid date"
+ @due_date = Holiday.due_date_from(@request_date)
+ @skipped = Holiday.all(
+ :conditions => [ 'day >= ? AND day <= ?',
+ @request_date.strftime("%F"), @due_date.strftime("%F")
+ ]
+ ).collect { |h| h.day }.sort
+ end
+ end
+
+end
diff --git a/app/views/holiday/due_date.rhtml b/app/views/holiday/due_date.rhtml
new file mode 100644
index 000000000..6f8c2e51a
--- /dev/null
+++ b/app/views/holiday/due_date.rhtml
@@ -0,0 +1,6 @@
+<% @title = "Due Date" %>
+
+<p>Request made: <%= @request_date %>
+<p>Response due: <%= @due_date %>
+<p>Skipping: <%= @skipped.join(" and ") %>
+
diff --git a/config/routes.rb b/config/routes.rb
index f60d5a611..410519e0a 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -4,7 +4,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: routes.rb,v 1.84 2009-03-10 12:04:55 tony Exp $
+# $Id: routes.rb,v 1.85 2009-03-16 15:55:05 tony Exp $
ActionController::Routing::Routes.draw do |map|
@@ -88,6 +88,10 @@ ActionController::Routing::Routes.draw do |map|
help.help_general '/help/:action', :action => :action
end
+ map.with_options :controller => 'holiday' do |holiday|
+ holiday.due_date "/due_date/:holiday", :action => 'due_date'
+ end
+
# NB: We don't use routes to *construct* admin URLs, as they need to be relative
# paths to work on the live site proxied over HTTPS to secure.mysociety.org
map.connect '/admin/', :controller => 'admin_general', :action => 'index'