mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-04 06:51:48 +01:00
Applied lolindrath's patch (ticket #12), which fixes the calculation of dates for the completed page so that it works with all the database formats. Thanks, lolindrath!
Also put back _done.rhtml partial after accidentally removing it. Thank goodness for Subversion revisions... git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@88 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
6cd9335de8
commit
f772114c66
2 changed files with 42 additions and 6 deletions
|
|
@ -34,11 +34,21 @@ class TodoController < ApplicationController
|
|||
# Use days declaration? 1.day.ago?
|
||||
def completed
|
||||
@page_title = "TRACKS::Completed tasks"
|
||||
today_query = "DATE_SUB(CURDATE(),INTERVAL 1 DAY) <= completed"
|
||||
week_query = "DATE_SUB(CURDATE(),INTERVAL 2 DAY) >= completed
|
||||
AND DATE_SUB(CURDATE(),INTERVAL 7 DAY) <= completed"
|
||||
month_query = "DATE_SUB(CURDATE(),INTERVAL 8 DAY) >= completed
|
||||
AND DATE_SUB(CURDATE(),INTERVAL 31 DAY) <= completed"
|
||||
today_date = Date::today() - 1
|
||||
today_query = today_date.strftime("'%Y-%m-%d'") + " <= completed"
|
||||
|
||||
week_begin = Date::today() - 2
|
||||
week_end = Date::today() - 7
|
||||
|
||||
week_query = week_begin.strftime("'%Y-%m-%d'") + " >= completed
|
||||
AND " + week_end.strftime("'%Y-%m-%d'") + " <= completed"
|
||||
|
||||
month_begin = Date::today() - 8
|
||||
month_end = Date::today() - 31
|
||||
|
||||
month_query = month_begin.strftime("'%Y-%m-%d'") + " >= completed
|
||||
AND " + month_end.strftime("'%Y-%m-%d'") + " <= completed"
|
||||
|
||||
@done_today = Todo.find_by_sql( "SELECT * FROM todos WHERE done = 1 AND #{today_query}
|
||||
ORDER BY completed DESC;" )
|
||||
@done_this_week = Todo.find_by_sql( "SELECT * FROM todos WHERE done = 1 AND #{week_query}
|
||||
|
|
@ -51,7 +61,8 @@ class TodoController < ApplicationController
|
|||
#
|
||||
def completed_archive
|
||||
@page_title = "TRACKS::Archived completed tasks"
|
||||
archive_query = "DATE_SUB(CURDATE(),INTERVAL 32 DAY) >= completed"
|
||||
archive_date = Date::today() - 32
|
||||
archive_query = archive_date.strftime("'%Y-%m-%d'") + " >= completed"
|
||||
@done_archive = Todo.find_by_sql( "SELECT * FROM todos WHERE done = 1 AND #{archive_query}
|
||||
ORDER BY completed DESC;" )
|
||||
end
|
||||
|
|
|
|||
25
tracks/app/views/todo/_done.rhtml
Normal file
25
tracks/app/views/todo/_done.rhtml
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<% @done_item = done %>
|
||||
<tr>
|
||||
<% if @done_item.completed %>
|
||||
<td valign="top"><%= image_tag( "done", :width=>"16", :height=>"16", :border=>"0") %></td>
|
||||
<td valign="top"><span class="grey"><%= format_date( @done_item.completed ) %></span></td>
|
||||
<td valign="top"><%= " " + @done_item.description + " "%>
|
||||
|
||||
<% if @done_item.project_id %>
|
||||
<%= "(" + @done_item.context['name'] + ", " + @done_item.project['name'] + ")" %>
|
||||
<% else %>
|
||||
<%= "(" + @done_item.context['name'] + ")" %>
|
||||
<% end %>
|
||||
|
||||
<% if @done_item.due %>
|
||||
<%= " - was due on " + format_date( @done_item.due ) %>
|
||||
<% end %>
|
||||
|
||||
<% if @done_item.notes? %>
|
||||
<%= "<a href=\"javascript:Element.toggle('" + @done_item.id.to_s + "')\" title=\"Show notes\">" + image_tag( "notes", :width=>"10", :height=>"10", :border=>"0") + "</a>" %>
|
||||
<% m_notes = markdown( @done_item.notes ) %>
|
||||
<%= "<div class=\"notes\" id=\"" + @done_item.id.to_s + "\" style=\"display:none\">" + m_notes + "</div>" %>
|
||||
<% end %>
|
||||
</td>
|
||||
<% end %>
|
||||
</tr>
|
||||
Loading…
Add table
Add a link
Reference in a new issue