From 83df7916da6988132ace419c695124d805c6ba8d Mon Sep 17 00:00:00 2001 From: lukemelia Date: Tue, 6 Nov 2007 05:04:00 +0000 Subject: [PATCH] Added tags to YAML, CSV and XML export. git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@633 a4c988fc-2ded-0310-b66e-134b36920a42 --- tracks/app/controllers/data_controller.rb | 9 +++++++-- tracks/app/views/data/export.rhtml | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tracks/app/controllers/data_controller.rb b/tracks/app/controllers/data_controller.rb index b89857db..7d918627 100644 --- a/tracks/app/controllers/data_controller.rb +++ b/tracks/app/controllers/data_controller.rb @@ -20,6 +20,8 @@ class DataController < ApplicationController all_tables['todos'] = current_user.todos.find(:all) all_tables['contexts'] = current_user.contexts.find(:all) all_tables['projects'] = current_user.projects.find(:all) + all_tables['tags'] = current_user.tags.find(:all) + all_tables['taggings'] = current_user.taggings.find(:all) all_tables['notes'] = current_user.notes.find(:all) result = all_tables.to_yaml @@ -30,7 +32,7 @@ class DataController < ApplicationController def csv_actions content_type = 'text/csv' CSV::Writer.generate(result = "") do |csv| - csv << ["id", "Context", "Project", "Description", "Notes", + csv << ["id", "Context", "Project", "Description", "Notes", "Tags", "Created at", "Due", "Completed at", "User ID", "Show from", "state"] current_user.todos.find(:all, :include => [:context, :project]).each do |todo| @@ -39,7 +41,8 @@ class DataController < ApplicationController csv << [todo.id, todo.context.name, todo.project_id = todo.project_id.nil? ? "" : todo.project.name, todo.description, - todo.notes, todo.created_at.to_formatted_s(:db), + todo.notes, todo.tags.collect{|t| t.name}.join(', '), + todo.created_at.to_formatted_s(:db), todo.due = todo.due? ? todo.due.to_formatted_s(:db) : "", todo.completed_at = todo.completed_at? ? todo.completed_at.to_formatted_s(:db) : "", todo.user_id, @@ -74,6 +77,8 @@ class DataController < ApplicationController result << current_user.todos.find(:all).to_xml result << current_user.contexts.find(:all).to_xml(:skip_instruct => true) result << current_user.projects.find(:all).to_xml(:skip_instruct => true) + result << current_user.tags.find(:all).to_xml(:skip_instruct => true) + result << current_user.taggings.find(:all).to_xml(:skip_instruct => true) result << current_user.notes.find(:all).to_xml(:skip_instruct => true) send_data(result, :filename => "tracks_backup.xml", :type => 'text/xml') end diff --git a/tracks/app/views/data/export.rhtml b/tracks/app/views/data/export.rhtml index 024b6b91..5bb147fa 100644 --- a/tracks/app/views/data/export.rhtml +++ b/tracks/app/views/data/export.rhtml @@ -16,7 +16,7 @@ Download link -YAML file containing all your actions, contexts, projects and notes +YAML file containing all your actions, contexts, projects, tags and notes <%= link_to "YAML file", :controller => 'data', :action => 'yaml_export' %> @@ -28,7 +28,7 @@ <%= link_to "CSV file (notes only)", :controller => 'data', :action => 'csv_notes' %> - XML file containing all your actions, contexts, projects and notes + XML file containing all your actions, contexts, projects, tags and notes <%= link_to "XML file (actions only)", :controller => 'data', :action => 'xml_export' %>