Commits

jplang  committed f60df70

association loading in documents/show

  • Participants
  • Parent commits 3fab638

Comments (0)

Files changed (2)

File redmine/app/controllers/documents_controller.rb

 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 class DocumentsController < ApplicationController
-	layout 'base'
-	before_filter :find_project, :authorize
-  
-  def show
+  layout 'base'
+  before_filter :find_project, :authorize
+
+  def show
+    @attachments = @document.attachments.find(:all, :order => "created_on DESC")
   end
 
   def edit
       @attachment.author_id = self.logged_in_user.id if self.logged_in_user
       @attachment.save
     end
-    render :action => 'show'
+    redirect_to :action => 'show', :id => @document
   end
   
   def destroy_attachment
     @document.attachments.find(params[:attachment_id]).destroy
-    render :action => 'show'
+    redirect_to :action => 'show', :id => @document
   end
 
 private
-	def find_project
+  def find_project
     @document = Document.find(params[:id])
-		@project = @document.project
-	end  
-  
+    @project = @document.project
+  end  
 end

File redmine/app/views/documents/show.rhtml

 
 <br /><br />
 
-<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>
   <td><%= link_to attachment.filename, :action => 'download', :id => @document, :attachment_id => attachment %></td>
-  <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>