Incorporate Ryan Daigle's patch (thanks Ryan!) to fix errors parsing non-US-style dates on the tickler show_from field. Refactor date parsing calls to use a new method in the base action controller.

git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@295 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
lukemelia 2006-07-28 19:03:34 +00:00
parent e0e407d99a
commit c606e646b3
5 changed files with 20 additions and 7 deletions

View file

@ -71,7 +71,11 @@ class ApplicationController < ActionController::Base
def get_admin_user
@admin = User.find(:first, :conditions => [ "is_admin = ?", true ])
end
def parse_date_per_user_prefs( s )
Date.strptime(s, @user.preferences["date_format"])
end
def init_data_for_sidebar
@projects = @user.projects
@contexts = @user.contexts

View file

@ -51,7 +51,7 @@ class ContextController < ApplicationController
@item.attributes = params["todo"]
if @item.due?
@item.due = Date.strptime(params["todo"]["due"], @user.preferences["date_format"])
@item.due = parse_date_per_user_prefs(params["todo"]["due"])
else
@item.due = ""
end

View file

@ -19,11 +19,16 @@ class DeferredController < ApplicationController
end
def create
@item = Deferred.new
@item.attributes = params["todo"]
if params["todo"]["show_from"]
@item.show_from = parse_date_per_user_prefs(params["todo"]["show_from"])
end
@item = Deferred.create(params["todo"])
@item.user_id = @user.id
if @item.due?
@item.due = Date.strptime(params["todo"]["due"], @user.preferences["date_format"])
@item.due = parse_date_per_user_prefs(params["todo"]["due"])
else
@item.due = ""
end
@ -52,8 +57,12 @@ class DeferredController < ApplicationController
@original_item_context_id = @item.context_id
@item.attributes = params["item"]
if params["item"]["show_from"]
@item.show_from = parse_date_per_user_prefs(params["item"]["show_from"])
end
if @item.due?
@item.due = Date.strptime(params["item"]["due"], @user.preferences["date_format"])
@item.due = parse_date_per_user_prefs(params["item"]["due"])
else
@item.due = ""
end

View file

@ -73,7 +73,7 @@ class ProjectController < ApplicationController
@item.attributes = params["todo"]
if @item.due?
@item.due = Date.strptime(params["todo"]["due"], @user.preferences["date_format"])
@item.due = parse_date_per_user_prefs(params["todo"]["due"])
else
@item.due = ""
end

View file

@ -57,7 +57,7 @@ class TodoController < ApplicationController
@on_page = "home"
if @item.due?
@item.due = Date.strptime(params["todo"]["due"], @user.preferences["date_format"])
@item.due = parse_date_per_user_prefs(params["todo"]["due"])
else
@item.due = ""
end
@ -138,7 +138,7 @@ class TodoController < ApplicationController
@item.attributes = params["item"]
if @item.due?
@item.due = Date.strptime(params["item"]["due"], @user.preferences["date_format"])
@item.due = parse_date_per_user_prefs(params["item"]["due"])
else
@item.due = ""
end