Added a feed (RSS and TXT) for the actions completed in the past 7 days, as promised on the home page of the Tracks projects site, but hitherto only implemented in my imagination, and not in reality as I'd somehow assumed ;-)

Fixes #323



git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@284 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
bsag 2006-07-17 18:54:12 +00:00
parent 847c283c5b
commit 8c7079dba5
4 changed files with 24 additions and 3 deletions

View file

@ -76,7 +76,11 @@ protected
condition_builder = FindConditionBuilder.new
options = Hash.new
condition_builder.add 'todos.done = ?', false
if params.key?('done')
condition_builder.add 'todos.done = ?', true
else
condition_builder.add 'todos.done = ?', false
end
if params.key?('limit')
options[:limit] = limit = params['limit']
@ -94,6 +98,13 @@ protected
@description << " with a due date #{due_within_date_s} or earlier"
end
if params.key?('done')
done_in_last = params['done'].to_i
condition_builder.add('todos.completed >= ?', done_in_last.days.ago)
@title << " actions completed"
@description << " in the last #{done_in_last.to_s} days"
end
if params.key?('context')
context = @user.contexts.find(params['context'])
condition_builder.add('todos.context_id = ?', context.id)

View file

@ -11,8 +11,12 @@ module FeedHelper
if item.context_id == context.id
result_string << "\n" + context.name.upcase + ":\n" if result_string.empty?
if item.completed
result_string << " [Completed: " + format_date(item.completed) + "] "
end
if item.due
result_string << " [" + format_date(item.due) + "] "
result_string << " [Due: " + format_date(item.due) + "] "
result_string << item.description + " "
else
result_string << " " + item.description + " "

View file

@ -9,13 +9,14 @@ xml.rss("version" => "2.0", "xmlns:dc" => "http://purl.org/dc/elements/1.1/") do
xml.link(url_for(:only_path => false, :controller => 'context', :action => 'show', :name => urlize(i.context.name)))
item_notes = sanitize(markdown( i.notes )) if i.notes?
due = "<div>Due: #{format_date(i.due)}</div>\n" if i.due?
done = "<div>Completed: #{format_date(i.completed)}</div>\n" if i.completed?
context_link = link_to( i.context.name, { :only_path => false, :controller => "context", :action => "show", :name => urlize(i.context.name) } )
project_link = if i.project_id?
link_to (i.project.name, { :only_path => false, :controller => "project", :action => "show", :name => urlize(i.project.name)} )
else
"<em>none</em>"
end
xml.description("#{due||''}#{item_notes||''}\n<div>Project: #{project_link}</div>\n<div>Context: #{context_link}</div>")
xml.description("#{done||''}#{due||''}#{item_notes||''}\n<div>Project: #{project_link}</div>\n<div>Context: #{context_link}</div>")
end
}
end

View file

@ -41,6 +41,11 @@
<%= ical_feed_link({ :due => 6 }) %>
Actions due in 7 days or earlier
</li>
<li>
<%= rss_feed_link({ :done => 7 }) %>
<%= text_feed_link({ :done => 7 }) %>
Actions completed in the last 7 days
</li>
<li>
<%= rss_feed_link({ :action => 'list_contexts_only', :feedtype => 'rss' }) %>
<%= text_feed_link({ :action => 'list_contexts_only', :feedtype => 'text' }) %>