aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/holiday_controller.rb26
-rw-r--r--app/views/holiday/due_date.rhtml6
2 files changed, 32 insertions, 0 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 ") %>
+