mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-28 04:48:49 +01:00
fixes #699. rich_todo api now first looks for matches with active projects and contexts and if that fails it revert to looking for matches in all projects and contexts
git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@852 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
e8d3b62b1f
commit
6a42901514
2 changed files with 14 additions and 3 deletions
|
|
@ -19,10 +19,12 @@ class BackendController < ApplicationController
|
|||
if(!context.nil? && project.nil?)
|
||||
context,project = split_by_char('>',context)
|
||||
end
|
||||
# logger.info("context='#{context}' project='#{project}")
|
||||
|
||||
context_id = default_context_id
|
||||
unless(context.nil?)
|
||||
found_context = @user.contexts.find_by_namepart(context)
|
||||
found_context = @user.active_contexts.find_by_namepart(context)
|
||||
found_context = @user.contexts.find_by_namepart(context) if found_context.nil?
|
||||
context_id = found_context.id unless found_context.nil?
|
||||
end
|
||||
check_context_belongs_to_user(context_id)
|
||||
|
|
@ -34,7 +36,8 @@ class BackendController < ApplicationController
|
|||
found_project.name = project[4..255+4].strip
|
||||
found_project.save!
|
||||
else
|
||||
found_project = @user.projects.find_by_namepart(project)
|
||||
found_project = @user.active_projects.find_by_namepart(project)
|
||||
found_project = @user.projects.find_by_namepart(project) if found_project.nil?
|
||||
end
|
||||
project_id = found_project.id unless found_project.nil?
|
||||
end
|
||||
|
|
@ -89,7 +92,7 @@ class BackendController < ApplicationController
|
|||
# needed to get 'description @ @home > project' working for contexts
|
||||
# starting with @
|
||||
if parts.length > 2
|
||||
2.upto(parts.length-1) { |i| parts[1] += parts[i] }
|
||||
2.upto(parts.length-1) { |i| parts[1] += (separator +parts[i]) }
|
||||
end
|
||||
|
||||
return safe_strip(parts[0]), safe_strip(parts[1])
|
||||
|
|
|
|||
|
|
@ -52,6 +52,14 @@ class User < ActiveRecord::Base
|
|||
return projects
|
||||
end
|
||||
end
|
||||
has_many :active_projects,
|
||||
:class_name => 'Project',
|
||||
:order => 'projects.position ASC',
|
||||
:conditions => [ 'state = ?', 'active' ]
|
||||
has_many :active_contexts,
|
||||
:class_name => 'Context',
|
||||
:order => 'position ASC',
|
||||
:conditions => [ 'hide = ?', 'true' ]
|
||||
has_many :todos,
|
||||
:order => 'todos.completed_at DESC, todos.created_at DESC',
|
||||
:dependent => :delete_all
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue