##// END OF EJS Templates
added multiple file upload for documents and files modules...
added multiple file upload for documents and files modules git-svn-id: http://redmine.rubyforge.org/svn/trunk@130 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r127:ff65a5b22a54
r127:ff65a5b22a54
Show More
documents_controller.rb
66 lines | 2.3 KiB | text/x-ruby | RubyLexer
/ app / controllers / documents_controller.rb
Jean-Philippe Lang
Initial commit...
r2 # redMine - project management software
# Copyright (C) 2006 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class DocumentsController < ApplicationController
Jean-Philippe Lang
association loading in documents/show...
r22 layout 'base'
before_filter :find_project, :authorize
def show
@attachments = @document.attachments.find(:all, :order => "created_on DESC")
Jean-Philippe Lang
Initial commit...
r2 end
def edit
@categories = Enumeration::get_values('DCAT')
if request.post? and @document.update_attributes(params[:document])
Jean-Philippe Lang
notice messages translation...
r15 flash[:notice] = l(:notice_successful_update)
Jean-Philippe Lang
Initial commit...
r2 redirect_to :action => 'show', :id => @document
end
end
def destroy
@document.destroy
redirect_to :controller => 'projects', :action => 'list_documents', :id => @project
end
def download
@attachment = @document.attachments.find(params[:attachment_id])
@attachment.increment_download
send_file @attachment.diskfile, :filename => @attachment.filename
Jean-Philippe Lang
git-svn-id: http://redmine.rubyforge.org/svn/trunk@51 e93f8b46-1217-0410-a6f0-8f06a7374b81
r49 rescue
flash.now[:notice] = l(:notice_file_not_found)
render :text => "", :layout => true, :status => 404
Jean-Philippe Lang
Initial commit...
r2 end
def add_attachment
Jean-Philippe Lang
added multiple file upload for documents and files modules...
r127 # Save the attachments
params[:attachments].each { |a|
Attachment.create(:container => @document, :file => a, :author => logged_in_user) unless a.size == 0
} if params[:attachments] and params[:attachments].is_a? Array
Jean-Philippe Lang
association loading in documents/show...
r22 redirect_to :action => 'show', :id => @document
Jean-Philippe Lang
Initial commit...
r2 end
def destroy_attachment
@document.attachments.find(params[:attachment_id]).destroy
Jean-Philippe Lang
association loading in documents/show...
r22 redirect_to :action => 'show', :id => @document
Jean-Philippe Lang
Initial commit...
r2 end
private
Jean-Philippe Lang
association loading in documents/show...
r22 def find_project
Jean-Philippe Lang
Initial commit...
r2 @document = Document.find(params[:id])
Jean-Philippe Lang
association loading in documents/show...
r22 @project = @document.project
end
Jean-Philippe Lang
Initial commit...
r2 end