Apply patch from Reinier to be able to specify notes when adding a todo via the XML RPC API. Fixes #385. Thanks, Reinier!

git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@598 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
lukemelia 2007-09-26 11:40:14 +00:00
parent 9f5862d842
commit b334b51ec4
2 changed files with 8 additions and 7 deletions

View file

@ -1,10 +1,10 @@
class TodoApi < ActionWebService::API::Base class TodoApi < ActionWebService::API::Base
api_method :new_todo, api_method :new_todo,
:expects => [{:username => :string}, {:token => :string}, {:context_id => :int}, {:description => :string}], :expects => [{:username => :string}, {:token => :string}, {:context_id => :int}, {:description => :string}, {:notes => :string}],
:returns => [:int] :returns => [:int]
api_method :new_rich_todo, api_method :new_rich_todo,
:expects => [{:username => :string}, {:token => :string}, {:default_context_id => :int}, {:description => :string}], :expects => [{:username => :string}, {:token => :string}, {:default_context_id => :int}, {:description => :string}, {:notes => :string}],
:returns => [:int] :returns => [:int]
api_method :list_contexts, api_method :list_contexts,

View file

@ -5,14 +5,14 @@ class BackendController < ApplicationController
skip_before_filter :login_required skip_before_filter :login_required
def new_todo(username, token, context_id, description) def new_todo(username, token, context_id, description, notes)
check_token(username, token) check_token(username, token)
check_context_belongs_to_user(context_id) check_context_belongs_to_user(context_id)
item = create_todo(description, context_id) item = create_todo(description, context_id, nil, notes)
item.id item.id
end end
def new_rich_todo(username, token, default_context_id, description) def new_rich_todo(username, token, default_context_id, description, notes)
check_token(username,token) check_token(username,token)
description,context = split_by_char('@',description) description,context = split_by_char('@',description)
description,project = split_by_char('>',description) description,project = split_by_char('>',description)
@ -39,7 +39,7 @@ class BackendController < ApplicationController
project_id = found_project.id unless found_project.nil? project_id = found_project.id unless found_project.nil?
end end
todo = create_todo(description, context_id, project_id) todo = create_todo(description, context_id, project_id, notes)
todo.id todo.id
end end
@ -71,9 +71,10 @@ class BackendController < ApplicationController
end end
end end
def create_todo(description, context_id, project_id = nil) def create_todo(description, context_id, project_id = nil, notes="")
item = @user.todos.build item = @user.todos.build
item.description = description item.description = description
item.notes = notes
item.context_id = context_id item.context_id = context_id
item.project_id = project_id unless project_id.nil? item.project_id = project_id unless project_id.nil?
item.save item.save