Mercurial > hg > soundsoftware-site
diff app/controllers/attachments_controller.rb @ 909:cbb26bc654de redmine-1.3
Update to Redmine 1.3-stable branch (Redmine SVN rev 8964)
author | Chris Cannam |
---|---|
date | Fri, 24 Feb 2012 19:09:32 +0000 |
parents | cbce1fd3b1b7 |
children | 5e80956cc792 433d4f72a19b |
line wrap: on
line diff
--- a/app/controllers/attachments_controller.rb Fri Feb 24 18:36:29 2012 +0000 +++ b/app/controllers/attachments_controller.rb Fri Feb 24 19:09:32 2012 +0000 @@ -20,17 +20,29 @@ before_filter :file_readable, :read_authorize, :except => :destroy before_filter :delete_authorize, :only => :destroy - verify :method => :post, :only => :destroy + accept_api_auth :show, :download def show - if @attachment.is_diff? - @diff = File.new(@attachment.diskfile, "rb").read - render :action => 'diff' - elsif @attachment.is_text? && @attachment.filesize <= Setting.file_max_size_displayed.to_i.kilobyte - @content = File.new(@attachment.diskfile, "rb").read - render :action => 'file' - else - download + respond_to do |format| + format.html { + if @attachment.is_diff? + @diff = File.new(@attachment.diskfile, "rb").read + @diff_type = params[:type] || User.current.pref[:diff_type] || 'inline' + @diff_type = 'inline' unless %w(inline sbs).include?(@diff_type) + # Save diff type as user preference + if User.current.logged? && @diff_type != User.current.pref[:diff_type] + User.current.pref[:diff_type] = @diff_type + User.current.preference.save + end + render :action => 'diff' + elsif @attachment.is_text? && @attachment.filesize <= Setting.file_max_size_displayed.to_i.kilobyte + @content = File.new(@attachment.diskfile, "rb").read + render :action => 'file' + else + download + end + } + format.api end end @@ -46,6 +58,7 @@ end + verify :method => :delete, :only => :destroy def destroy # Make sure association callbacks are called @attachment.container.attachments.delete(@attachment)