Browse Source

association loading in documents/show

git-svn-id: http://redmine.rubyforge.org/svn/trunk@24 e93f8b46-1217-0410-a6f0-8f06a7374b81
tags/0.3.0
Jean-Philippe Lang 17 years ago
parent
commit
dc26a9cd39

+ 10
- 10
redmine/app/controllers/documents_controller.rb View File

@@ -16,10 +16,11 @@
# 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
@@ -48,18 +49,17 @@ class DocumentsController < ApplicationController
@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

+ 4
- 4
redmine/app/views/documents/show.rhtml View File

@@ -18,11 +18,11 @@
<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>

Loading…
Cancel
Save