fix #1287. Fix various small bugs and some small improvements

This commit is contained in:
Reinier Balt 2012-06-29 16:48:30 +02:00
parent 88729f57ce
commit bd8498f39c
10 changed files with 18 additions and 40 deletions

View file

@ -100,11 +100,7 @@ class ApplicationController < ActionController::Base
end
def count_deferred_todos(todos_parent)
if todos_parent.nil?
count = 0
else
count = todos_parent.todos.deferred.count
end
return todos_parent.nil? ? 0 : eval("@#{todos_parent.class.to_s.downcase}_deferred_counts[#{todos_parent.id}]") || 0
end
# Convert a date object to the format specified in the user's preferences in
@ -284,7 +280,8 @@ class ApplicationController < ActionController::Base
def init_not_done_counts(parents = ['project','context'])
parents.each do |parent|
eval("@#{parent}_not_done_counts = @#{parent}_not_done_counts || current_user.todos.active.count(:group => :#{parent}_id)")
eval("@#{parent}_not_done_counts ||= current_user.todos.active.group('#{parent}_id').count")
eval("@#{parent}_deferred_counts ||= current_user.todos.deferred.group('#{parent}_id').count")
end
end

View file

@ -67,6 +67,7 @@ class ContextsController < ApplicationController
respond_to do |format|
format.js do
@down_count = current_user.contexts.size
init_not_done_counts
end
format.xml do
if @context.new_record?

View file

@ -2,7 +2,7 @@ class IntegrationsController < ApplicationController
require 'mail'
skip_before_filter :login_required, :only => [:cloudmailin, :search_plugin, :google_gadget]
def index
@page_title = 'TRACKS::Integrations'
end
@ -27,11 +27,8 @@ class IntegrationsController < ApplicationController
end
def search_plugin
# TODO: ASSET PATH!!
@icon_data = [File.open(Rails.root + '/app/assets/images/done.png').read].
@icon_data = [File.open(File.join(Rails.root, 'app', 'assets', 'images', 'done.png')).read].
pack('m').gsub(/\n/, '')
render :layout => false
end
def google_gadget

View file

@ -182,7 +182,10 @@ class ProjectsController < ApplicationController
@contexts = current_user.contexts
respond_to do |format|
format.js { @down_count = current_user.projects.size }
format.js do
@down_count = current_user.projects.size
init_not_done_counts
end
format.xml do
if @project.new_record?
render_failure @project.errors.to_xml.html_safe, 409

View file

@ -10,26 +10,6 @@ class TodosController < ApplicationController
# :calendar, :auto_complete_for_predecessor, :remove_predecessor, :add_predecessor]
protect_from_forgery :except => :check_deferred
def with_parent_resource_scope(&block)
@feed_title = t('common.actions')
if (params[:context_id])
@context = current_user.contexts.find_by_params(params)
@feed_title = @feed_title + t('todos.feed_title_in_context', :context => @context.name)
Todo.send :where, ['todos.context_id = ?', @context.id] do
yield
end
elsif (params[:project_id])
@project = current_user.projects.find_by_params(params)
@feed_title = @feed_title + t('todos.feed_title_in_project', :project => @project.name)
@project_feed = true
Todo.send :where, ['todos.project_id = ?', @project.id] do
yield
end
else
yield
end
end
def index
@source_view = params['_source_view'] || 'todo'

View file

@ -200,7 +200,7 @@ module ApplicationHelper
return content_tag(:li, t('sidebar.list_empty')).html_safe
else
return list.inject("") do |html, item|
link = (item.class == "Project") ? link_to_project( item ) : link_to_context(item)
link = item.is_a?(Project) ? link_to_project( item ) : link_to_context(item)
html << content_tag(:li, link + " (" + count_undone_todos_phrase(item)+")")
end.html_safe
end

View file

@ -26,12 +26,12 @@ class Todo < ActiveRecord::Base
scope :active, :conditions => { :state => 'active' }
scope :active_or_hidden, :conditions => ["todos.state = ? OR todos.state = ?", 'active', 'project_hidden']
scope :not_completed, :conditions => ['NOT (todos.state = ?)', 'completed']
scope :completed, :conditions => ["NOT (todos.completed_at IS NULL)"]
scope :deferred, :conditions => ["todos.completed_at IS NULL AND NOT (todos.show_from IS NULL)"]
scope :completed, :conditions => ["todos.state = ?", 'completed']
scope :deferred, :conditions => ["todos.state = ?", 'deferred']
scope :blocked, :conditions => ['todos.state = ?', 'pending']
scope :pending, :conditions => ['todos.state = ?', 'pending']
scope :deferred_or_blocked, :conditions => ["(todos.completed_at IS NULL AND NOT(todos.show_from IS NULL)) OR (todos.state = ?)", "pending"]
scope :not_deferred_or_blocked, :conditions => ["(todos.completed_at IS NULL) AND (todos.show_from IS NULL) AND (NOT todos.state = ?)", "pending"]
scope :deferred_or_blocked, :conditions => ["(todos.state = ?) OR (todos.state = ?)", "deferred", "pending"]
scope :not_deferred_or_blocked, :conditions => ["(NOT todos.state=?) AND (NOT todos.state = ?)", "deferred", "pending"]
scope :hidden,
:joins => "INNER JOIN contexts c_hidden ON c_hidden.id = todos.context_id",
:conditions => ["todos.state = ? OR (c_hidden.hide = ? AND (todos.state = ? OR todos.state = ? OR todos.state = ?))",

View file

@ -26,7 +26,7 @@
</script>
<link rel="shortcut icon" href="<%= image_path ('favicon.ico') %>" />
<%= auto_discovery_link_tag(:rss, {:controller => "todos", :action => "index", :format => 'rss', :token => "#{current_user.token}"}, {:title => t('layouts.next_actions_rss_feed')}) %>
<link rel="search" type="application/opensearchdescription+xml" title="Tracks" href="<%= search_plugin_path %>" />
<link rel="search" type="application/opensearchdescription+xml" title="Tracks" href="<%= search_plugin_path(:format => :xml) %>" />
<title><%= @page_title %></title>
</head>

View file

@ -68,14 +68,14 @@ Tracksapp::Application.routes.draw do
match 'calendar' => "todos#calendar"
match 'done' => "stats#done", :as => 'done_overview'
match 'data' => "data#index"
match 'data' => "data#index"
match 'data/csv_notes' => 'data#csv_notes'
match 'data/yaml_export' => 'data#yaml_export'
match 'integrations' => "integrations#index"
match 'integrations/rest_api' => "integrations#rest_api", :as => 'rest_api_docs'
match 'integrations/cloudmailin' => 'integrations#cloudmailin'
match 'integrations/search_plugin.xml' => "integrations#search_plugin", :as => 'search_plugin'
match 'integrations/search_plugin' => "integrations#search_plugin", :as => 'search_plugin'
match 'integrations/google_gadget.xml' => 'integrations#google_gadget', :as => 'google_gadget'
match 'integrations/get_applescript1.js' => 'integrations#get_applescript1'
match 'integrations/get_applescript2.js' => 'integrations#get_applescript2'