diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2009-11-26 20:12:20 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2009-11-26 20:12:20 +0000 |
commit | 43fd27fd0ce4111501c36a6ef162aed61bf3318c (patch) | |
tree | 6a805a37c06baaba9a1c2935f32b22e6bca2cafb /app | |
parent | f3bcb705f74622afae785d9df793a0bbed3a11d3 (diff) | |
download | redmine-43fd27fd0ce4111501c36a6ef162aed61bf3318c.tar.gz redmine-43fd27fd0ce4111501c36a6ef162aed61bf3318c.zip |
Show last update datetime (last attachment added) on document list (#4232).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3095 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/documents_controller.rb | 2 | ||||
-rw-r--r-- | app/models/document.rb | 8 | ||||
-rw-r--r-- | app/views/documents/_document.rhtml | 2 |
3 files changed, 10 insertions, 2 deletions
diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb index c9eecf4f7..9d9c5a7d0 100644 --- a/app/controllers/documents_controller.rb +++ b/app/controllers/documents_controller.rb @@ -28,7 +28,7 @@ class DocumentsController < ApplicationController documents = @project.documents.find :all, :include => [:attachments, :category] case @sort_by when 'date' - @grouped = documents.group_by {|d| d.created_on.to_date } + @grouped = documents.group_by {|d| d.updated_on.to_date } when 'title' @grouped = documents.group_by {|d| d.title.first.upcase} when 'author' diff --git a/app/models/document.rb b/app/models/document.rb index a96c278d0..1318e823d 100644 --- a/app/models/document.rb +++ b/app/models/document.rb @@ -34,4 +34,12 @@ class Document < ActiveRecord::Base self.category ||= DocumentCategory.default end end + + def updated_on + unless @updated_on + a = attachments.find(:first, :order => 'created_on DESC') + @updated_on = (a && a.created_on) || created_on + end + @updated_on + end end diff --git a/app/views/documents/_document.rhtml b/app/views/documents/_document.rhtml index 47b450000..94a64ac80 100644 --- a/app/views/documents/_document.rhtml +++ b/app/views/documents/_document.rhtml @@ -1,3 +1,3 @@ <p><%= link_to h(document.title), :controller => 'documents', :action => 'show', :id => document %><br /> <% unless document.description.blank? %><%=h(truncate(document.description, :length => 250)) %><br /><% end %> -<em><%= format_time(document.created_on) %></em></p>
\ No newline at end of file +<em><%= format_time(document.updated_on) %></em></p>
\ No newline at end of file |