Changeset 852

Show
Ignore:
Timestamp:
05/16/08 19:38:45
Author:
lrbalt
Message:

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

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/tracks/app/controllers/backend_controller.rb

    r840 r852  
    2020      context,project = split_by_char('>',context) 
    2121    end 
     22#    logger.info("context='#{context}' project='#{project}") 
    2223 
    2324    context_id = default_context_id 
    2425    unless(context.nil?) 
    25       found_context = @user.contexts.find_by_namepart(context) 
     26      found_context = @user.active_contexts.find_by_namepart(context) 
     27      found_context = @user.contexts.find_by_namepart(context) if found_context.nil? 
    2628      context_id = found_context.id unless found_context.nil? 
    2729    end 
     
    3537        found_project.save! 
    3638      else 
    37         found_project = @user.projects.find_by_namepart(project) 
     39        found_project = @user.active_projects.find_by_namepart(project) 
     40        found_project = @user.projects.find_by_namepart(project) if found_project.nil? 
    3841      end 
    3942      project_id = found_project.id unless found_project.nil? 
     
    9093    # starting with @ 
    9194    if parts.length > 2 
    92       2.upto(parts.length-1) { |i| parts[1] += parts[i]
     95      2.upto(parts.length-1) { |i| parts[1] += (separator +parts[i])
    9396    end 
    9497 
  • trunk/tracks/app/models/user.rb

    r747 r852  
    5353              end 
    5454            end 
     55  has_many :active_projects, 
     56           :class_name => 'Project', 
     57           :order => 'projects.position ASC', 
     58           :conditions => [ 'state = ?', 'active' ] 
     59  has_many :active_contexts, 
     60           :class_name => 'Context', 
     61           :order => 'position ASC', 
     62           :conditions => [ 'hide = ?', 'true' ] 
    5563  has_many :todos, 
    5664           :order => 'todos.completed_at DESC, todos.created_at DESC',