##// END OF EJS Templates
Fixed: No mime-types in documents/files downloading...
Jean-Philippe Lang -
r885:843d04f0e3fa
parent child
Show More
@@ -1,71 +1,71
1 1 # redMine - project management software
2 2 # Copyright (C) 2006-2007 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 class DocumentsController < ApplicationController
19 19 layout 'base'
20 20 before_filter :find_project, :authorize
21 21
22 22 def show
23 23 @attachments = @document.attachments.find(:all, :order => "created_on DESC")
24 24 end
25 25
26 26 def edit
27 27 @categories = Enumeration::get_values('DCAT')
28 28 if request.post? and @document.update_attributes(params[:document])
29 29 flash[:notice] = l(:notice_successful_update)
30 30 redirect_to :action => 'show', :id => @document
31 31 end
32 32 end
33 33
34 34 def destroy
35 35 @document.destroy
36 36 redirect_to :controller => 'projects', :action => 'list_documents', :id => @project
37 37 end
38 38
39 39 def download
40 40 @attachment = @document.attachments.find(params[:attachment_id])
41 41 @attachment.increment_download
42 send_file @attachment.diskfile, :filename => @attachment.filename
42 send_file @attachment.diskfile, :filename => @attachment.filename, :type => @attachment.content_type
43 43 rescue
44 44 render_404
45 45 end
46 46
47 47 def add_attachment
48 48 # Save the attachments
49 49 @attachments = []
50 50 params[:attachments].each { |file|
51 51 next unless file.size > 0
52 52 a = Attachment.create(:container => @document, :file => file, :author => logged_in_user)
53 53 @attachments << a unless a.new_record?
54 54 } if params[:attachments] and params[:attachments].is_a? Array
55 55 Mailer.deliver_attachments_added(@attachments) if !@attachments.empty? && Setting.notified_events.include?('document_added')
56 56 redirect_to :action => 'show', :id => @document
57 57 end
58 58
59 59 def destroy_attachment
60 60 @document.attachments.find(params[:attachment_id]).destroy
61 61 redirect_to :action => 'show', :id => @document
62 62 end
63 63
64 64 private
65 65 def find_project
66 66 @document = Document.find(params[:id])
67 67 @project = @document.project
68 68 rescue ActiveRecord::RecordNotFound
69 69 render_404
70 70 end
71 71 end
@@ -1,60 +1,60
1 1 # redMine - project management software
2 2 # Copyright (C) 2006 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 class VersionsController < ApplicationController
19 19 layout 'base'
20 20 before_filter :find_project, :authorize
21 21
22 22 cache_sweeper :version_sweeper, :only => [ :edit, :destroy ]
23 23
24 24 def edit
25 25 if request.post? and @version.update_attributes(params[:version])
26 26 flash[:notice] = l(:notice_successful_update)
27 27 redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
28 28 end
29 29 end
30 30
31 31 def destroy
32 32 @version.destroy
33 33 redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
34 34 rescue
35 35 flash[:error] = "Unable to delete version"
36 36 redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
37 37 end
38 38
39 39 def download
40 40 @attachment = @version.attachments.find(params[:attachment_id])
41 41 @attachment.increment_download
42 send_file @attachment.diskfile, :filename => @attachment.filename
42 send_file @attachment.diskfile, :filename => @attachment.filename, :type => @attachment.content_type
43 43 rescue
44 44 render_404
45 45 end
46 46
47 47 def destroy_file
48 48 @version.attachments.find(params[:attachment_id]).destroy
49 49 flash[:notice] = l(:notice_successful_delete)
50 50 redirect_to :controller => 'projects', :action => 'list_files', :id => @project
51 51 end
52 52
53 53 private
54 54 def find_project
55 55 @version = Version.find(params[:id])
56 56 @project = @version.project
57 57 rescue ActiveRecord::RecordNotFound
58 58 render_404
59 59 end
60 60 end
General Comments 0
You need to be logged in to leave comments. Login now