]> source.dussan.org Git - redmine.git/commitdiff
association loading in documents/show
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 8 Oct 2006 10:42:50 +0000 (10:42 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 8 Oct 2006 10:42:50 +0000 (10:42 +0000)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@24 e93f8b46-1217-0410-a6f0-8f06a7374b81

redmine/app/controllers/documents_controller.rb
redmine/app/views/documents/show.rhtml

index e8c8e2d03575c49e59d7db71fab955354d306808..f2693577e7a2fd206c9930c635468be0a7b5d0d8 100644 (file)
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.\r
 \r
 class DocumentsController < ApplicationController\r
-       layout 'base'\r
-       before_filter :find_project, :authorize\r
-  
-  def show
+  layout 'base'\r
+  before_filter :find_project, :authorize\r
+
+  def show\r
+    @attachments = @document.attachments.find(:all, :order => "created_on DESC")
   end
 
   def edit\r
@@ -48,18 +49,17 @@ class DocumentsController < ApplicationController
       @attachment.author_id = self.logged_in_user.id if self.logged_in_user\r
       @attachment.save\r
     end\r
-    render :action => 'show'\r
+    redirect_to :action => 'show', :id => @document\r
   end\r
   \r
   def destroy_attachment\r
     @document.attachments.find(params[:attachment_id]).destroy\r
-    render :action => 'show'\r
+    redirect_to :action => 'show', :id => @document\r
   end
 \r
 private\r
-       def find_project\r
+  def find_project\r
     @document = Document.find(params[:id])\r
-               @project = @document.project\r
-       end  
-  
+    @project = @document.project\r
+  end  
 end
index 136621331790e5af2d1475df5b0f7096e3fbd567..89693de890d7aacc183a75565438ebf4514779a9 100644 (file)
 \r
 <br /><br />\r
 \r
-<table border="0" cellspacing="1" cellpadding="2" width="100%">  
-<% for attachment in @document.attachments %>
-  <tr style="background-color:#CEE1ED">
+<table class="listTableContent">  
+<% for attachment in @attachments %>
+  <tr class="<%= cycle("odd", "even") %>">
+  <td><%= format_date(attachment.created_on) %></td>\r
   <td><%= link_to attachment.filename, :action => 'download', :id => @document, :attachment_id => attachment %></td>\r
-  <td align="center"><%= format_date(attachment.created_on) %></td>
   <td align="center"><%= attachment.author.display_name %></td>
   <td><%= human_size(attachment.filesize) %><br /><%= lwr(:label_download, attachment.downloads) %></td>\r
   \r