diff --git a/tracks/app/controllers/todos_controller.rb b/tracks/app/controllers/todos_controller.rb
index 20e508de..e837418d 100644
--- a/tracks/app/controllers/todos_controller.rb
+++ b/tracks/app/controllers/todos_controller.rb
@@ -239,15 +239,30 @@ class TodosController < ApplicationController
# /todos/tag/[tag_name] shows all the actions tagged with tag_name
#
def tag
+
@tag = tag_name = params[:name]
- tag_collection = Tag.find_by_name(tag_name).todos
- if tag_collection.empty?
- @todos = []
+
+ if Tag.find_by_name(tag_name).nil?
+ # TODO: This doesn't work - you get kicked back to the index
+ # with a generic "Error occured on the server error"
+ notify :error, "Tag \'#{@tag}\' does not exist", 2.0
+ @not_done_todos = []
else
- @todos = tag_collection.find(:all, :conditions => ['taggings.user_id = ? and state = ?', @user.id, 'active'])
+ tag_collection = Tag.find_by_name(tag_name).todos
+ @not_done_todos = tag_collection.find(:all, :conditions => ['taggings.user_id = ? and state = ?', @user.id, 'active'])
end
- @count = @todos.size unless @todos.empty?
+ @contexts = @user.contexts.find(:all, :include => [ :todos ])
+ @contexts_to_show = @contexts.reject {|x| x.hide? }
+
+ @page_title = "TRACKS::Tagged with \'#{@tag}\'"
+ # If you've set no_completed to zero, the completed items box
+ # isn't shown on the home page
+ max_completed = @user.prefs.show_number_completed
+ @done = @user.completed_todos.find(:all, :limit => max_completed, :include => [ :context, :project, :tags ]) unless max_completed == 0
+ # Set count badge to number of items with this tag
+ @not_done_todos.empty? ? @count = 0 : @count = @not_done_todos.size
+
end
private
@@ -410,7 +425,7 @@ class TodosController < ApplicationController
render
end
end
-
+
def render_rss_feed
lambda do
render_rss_feed_for @todos, :feed => Todo.feed_options(@user),
diff --git a/tracks/app/views/todos/tag.rhtml b/tracks/app/views/todos/tag.rhtml
index 7e8f9b3b..2361fa15 100644
--- a/tracks/app/views/todos/tag.rhtml
+++ b/tracks/app/views/todos/tag.rhtml
@@ -1,19 +1,17 @@
-
-
+
>
- All actions tagged with '<%= @tag %>'
+ No actions found
-
-
-
Currently there are no actions tagged with <%= @tag %>
-
- <%= render :partial => "todos/todo", :collection => @todos, :locals => { :parent_container_type => "tag" } %>
-
-
-
-
-
+
Currently there are no incomplete actions with the tag '<%= @tag %>', but the tag exists, so you may have completed actions with that tag.
+
+
+ <%= render :partial => "contexts/context", :collection => @contexts_to_show,
+ :locals => { :collapsible => true } %>
+ <% unless @done.nil? -%>
+ <%= render :partial => "todos/completed",
+ :locals => { :done => @done, :collapsible => true, :append_descriptor => nil } %>
+ <% end -%>
diff --git a/tracks/db/schema.rb b/tracks/db/schema.rb
index 261979e3..30fe9b8b 100644
--- a/tracks/db/schema.rb
+++ b/tracks/db/schema.rb
@@ -1,136 +1,134 @@
-# This file is autogenerated. Instead of editing this file, please use the
-# migrations feature of ActiveRecord to incrementally modify your database, and
-# then regenerate this schema definition.
-
-ActiveRecord::Schema.define(:version => 30) do
-
- create_table "contexts", :force => true do |t|
- t.column "name", :string, :default => "", :null => false
- t.column "position", :integer, :null => false
- t.column "hide", :boolean, :default => false
- t.column "user_id", :integer, :default => 1
- t.column "created_at", :datetime
- t.column "updated_at", :datetime
- end
-
- add_index "contexts", ["user_id"], :name => "index_contexts_on_user_id"
- add_index "contexts", ["user_id", "name"], :name => "index_contexts_on_user_id_and_name"
-
- create_table "notes", :force => true do |t|
- t.column "user_id", :integer, :null => false
- t.column "project_id", :integer, :null => false
- t.column "body", :text
- t.column "created_at", :datetime
- t.column "updated_at", :datetime
- end
-
- create_table "open_id_associations", :force => true do |t|
- t.column "server_url", :binary
- t.column "handle", :string
- t.column "secret", :binary
- t.column "issued", :integer
- t.column "lifetime", :integer
- t.column "assoc_type", :string
- end
-
- create_table "open_id_nonces", :force => true do |t|
- t.column "nonce", :string
- t.column "created", :integer
- end
-
- create_table "open_id_settings", :force => true do |t|
- t.column "setting", :string
- t.column "value", :binary
- end
-
- create_table "preferences", :force => true do |t|
- t.column "user_id", :integer, :null => false
- t.column "date_format", :string, :limit => 40, :default => "%d/%m/%Y", :null => false
- t.column "week_starts", :integer, :default => 0, :null => false
- t.column "show_number_completed", :integer, :default => 5, :null => false
- t.column "staleness_starts", :integer, :default => 7, :null => false
- t.column "show_completed_projects_in_sidebar", :boolean, :default => true, :null => false
- t.column "show_hidden_contexts_in_sidebar", :boolean, :default => true, :null => false
- t.column "due_style", :integer, :default => 0, :null => false
- t.column "admin_email", :string, :default => "butshesagirl@rousette.org.uk", :null => false
- t.column "refresh", :integer, :default => 0, :null => false
- t.column "verbose_action_descriptors", :boolean, :default => false, :null => false
- t.column "show_hidden_projects_in_sidebar", :boolean, :default => true, :null => false
- t.column "time_zone", :string, :default => "London", :null => false
- t.column "show_project_on_todo_done", :boolean, :default => false, :null => false
- t.column "title_date_format", :string, :default => "%A, %d %B %Y", :null => false
- end
-
- add_index "preferences", ["user_id"], :name => "index_preferences_on_user_id"
-
- create_table "projects", :force => true do |t|
- t.column "name", :string, :default => "", :null => false
- t.column "position", :integer, :null => false
- t.column "user_id", :integer, :default => 1
- t.column "description", :text
- t.column "state", :string, :limit => 20, :default => "active", :null => false
- t.column "created_at", :datetime
- t.column "updated_at", :datetime
- end
-
- add_index "projects", ["user_id"], :name => "index_projects_on_user_id"
- add_index "projects", ["user_id", "name"], :name => "index_projects_on_user_id_and_name"
-
- create_table "sessions", :force => true do |t|
- t.column "session_id", :string
- t.column "data", :text
- t.column "updated_at", :datetime
- end
-
- add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id"
-
- create_table "taggings", :force => true do |t|
- t.column "taggable_id", :integer
- t.column "tag_id", :integer
- t.column "taggable_type", :string
- t.column "user_id", :integer
- end
-
- add_index "taggings", ["tag_id", "taggable_id", "taggable_type"], :name => "index_taggings_on_tag_id_and_taggable_id_and_taggable_type"
-
- create_table "tags", :force => true do |t|
- t.column "name", :string
- t.column "created_at", :datetime
- t.column "updated_at", :datetime
- end
-
- add_index "tags", ["name"], :name => "index_tags_on_name"
-
- create_table "todos", :force => true do |t|
- t.column "context_id", :integer, :null => false
- t.column "project_id", :integer
- t.column "description", :string, :default => "", :null => false
- t.column "notes", :text
- t.column "created_at", :datetime
- t.column "due", :date
- t.column "completed_at", :datetime
- t.column "user_id", :integer, :default => 1
- t.column "show_from", :date
- t.column "state", :string, :limit => 20, :default => "immediate", :null => false
- end
-
- add_index "todos", ["user_id", "state"], :name => "index_todos_on_user_id_and_state"
- add_index "todos", ["user_id", "project_id"], :name => "index_todos_on_user_id_and_project_id"
- add_index "todos", ["project_id"], :name => "index_todos_on_project_id"
- add_index "todos", ["context_id"], :name => "index_todos_on_context_id"
- add_index "todos", ["user_id", "context_id"], :name => "index_todos_on_user_id_and_context_id"
-
- create_table "users", :force => true do |t|
- t.column "login", :string, :limit => 80, :default => "", :null => false
- t.column "password", :string, :limit => 40, :default => "", :null => false
- t.column "word", :string
- t.column "is_admin", :boolean, :default => false, :null => false
- t.column "first_name", :string
- t.column "last_name", :string
- t.column "auth_type", :string, :default => "database", :null => false
- t.column "open_id_url", :string
- end
-
- add_index "users", ["login"], :name => "index_users_on_login"
-
-end
+# This file is autogenerated. Instead of editing this file, please use the
+# migrations feature of ActiveRecord to incrementally modify your database, and
+# then regenerate this schema definition.
+
+ActiveRecord::Schema.define(:version => 30) do
+
+ create_table "contexts", :force => true do |t|
+ t.column "name", :string, :default => "", :null => false
+ t.column "position", :integer, :default => 0, :null => false
+ t.column "hide", :boolean, :default => false
+ t.column "user_id", :integer, :default => 1
+ t.column "created_at", :datetime
+ t.column "updated_at", :datetime
+ end
+
+ add_index "contexts", ["user_id", "name"], :name => "index_contexts_on_user_id_and_name"
+
+ create_table "notes", :force => true do |t|
+ t.column "user_id", :integer, :default => 0, :null => false
+ t.column "project_id", :integer, :default => 0, :null => false
+ t.column "body", :text
+ t.column "created_at", :datetime
+ t.column "updated_at", :datetime
+ end
+
+ create_table "open_id_associations", :force => true do |t|
+ t.column "server_url", :binary
+ t.column "handle", :string
+ t.column "secret", :binary
+ t.column "issued", :integer
+ t.column "lifetime", :integer
+ t.column "assoc_type", :string
+ end
+
+ create_table "open_id_nonces", :force => true do |t|
+ t.column "nonce", :string
+ t.column "created", :integer
+ end
+
+ create_table "open_id_settings", :force => true do |t|
+ t.column "setting", :string
+ t.column "value", :binary
+ end
+
+ create_table "preferences", :force => true do |t|
+ t.column "user_id", :integer, :default => 0, :null => false
+ t.column "date_format", :string, :limit => 40, :default => "%d/%m/%Y", :null => false
+ t.column "week_starts", :integer, :default => 0, :null => false
+ t.column "show_number_completed", :integer, :default => 5, :null => false
+ t.column "staleness_starts", :integer, :default => 7, :null => false
+ t.column "show_completed_projects_in_sidebar", :boolean, :default => true, :null => false
+ t.column "show_hidden_contexts_in_sidebar", :boolean, :default => true, :null => false
+ t.column "due_style", :integer, :default => 0, :null => false
+ t.column "admin_email", :string, :default => "butshesagirl@rousette.org.uk", :null => false
+ t.column "refresh", :integer, :default => 0, :null => false
+ t.column "verbose_action_descriptors", :boolean, :default => false, :null => false
+ t.column "show_hidden_projects_in_sidebar", :boolean, :default => true, :null => false
+ t.column "time_zone", :string, :default => "London", :null => false
+ t.column "show_project_on_todo_done", :boolean, :default => false, :null => false
+ t.column "title_date_format", :string, :default => "%A, %d %B %Y", :null => false
+ end
+
+ add_index "preferences", ["user_id"], :name => "index_preferences_on_user_id"
+
+ create_table "projects", :force => true do |t|
+ t.column "name", :string, :default => "", :null => false
+ t.column "position", :integer, :default => 0, :null => false
+ t.column "user_id", :integer, :default => 1
+ t.column "description", :text
+ t.column "state", :string, :limit => 20, :default => "active", :null => false
+ t.column "created_at", :datetime
+ t.column "updated_at", :datetime
+ end
+
+ add_index "projects", ["user_id", "name"], :name => "index_projects_on_user_id_and_name"
+
+ create_table "sessions", :force => true do |t|
+ t.column "session_id", :string
+ t.column "data", :text
+ t.column "updated_at", :datetime
+ end
+
+ add_index "sessions", ["session_id"], :name => "sessions_session_id_index"
+
+ create_table "taggings", :force => true do |t|
+ t.column "taggable_id", :integer
+ t.column "tag_id", :integer
+ t.column "taggable_type", :string
+ t.column "user_id", :integer
+ end
+
+ add_index "taggings", ["tag_id", "taggable_id", "taggable_type"], :name => "index_taggings_on_tag_id_and_taggable_id_and_taggable_type"
+
+ create_table "tags", :force => true do |t|
+ t.column "name", :string
+ t.column "created_at", :datetime
+ t.column "updated_at", :datetime
+ end
+
+ add_index "tags", ["name"], :name => "index_tags_on_name"
+
+ create_table "todos", :force => true do |t|
+ t.column "context_id", :integer, :default => 0, :null => false
+ t.column "project_id", :integer
+ t.column "description", :string, :default => "", :null => false
+ t.column "notes", :text
+ t.column "created_at", :datetime
+ t.column "due", :date
+ t.column "completed_at", :datetime
+ t.column "user_id", :integer, :default => 1
+ t.column "show_from", :date
+ t.column "state", :string, :limit => 20, :default => "immediate", :null => false
+ end
+
+ add_index "todos", ["user_id", "state"], :name => "index_todos_on_user_id_and_state"
+ add_index "todos", ["user_id", "project_id"], :name => "index_todos_on_user_id_and_project_id"
+ add_index "todos", ["project_id"], :name => "index_todos_on_project_id"
+ add_index "todos", ["context_id"], :name => "index_todos_on_context_id"
+ add_index "todos", ["user_id", "context_id"], :name => "index_todos_on_user_id_and_context_id"
+
+ create_table "users", :force => true do |t|
+ t.column "login", :string, :limit => 80, :default => "", :null => false
+ t.column "password", :string, :limit => 40, :default => "", :null => false
+ t.column "word", :string
+ t.column "is_admin", :boolean, :default => false, :null => false
+ t.column "first_name", :string
+ t.column "last_name", :string
+ t.column "auth_type", :string, :default => "database", :null => false
+ t.column "open_id_url", :string
+ end
+
+ add_index "users", ["login"], :name => "index_users_on_login"
+
+end