diff app/controllers/attachments_controller.rb @ 443:350acce374a2 cannam

Merge from branch "cannam-pre-20110113-merge"
author Chris Cannam
date Mon, 06 Jun 2011 14:55:38 +0100
parents cbce1fd3b1b7 3ecf99348b9f
children 251b380117ce 5e80956cc792
line wrap: on
line diff
--- a/app/controllers/attachments_controller.rb	Mon Jun 06 14:41:04 2011 +0100
+++ b/app/controllers/attachments_controller.rb	Mon Jun 06 14:55:38 2011 +0100
@@ -16,9 +16,11 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 class AttachmentsController < ApplicationController
+
   before_filter :find_project
   before_filter :file_readable, :read_authorize, :except => :destroy
   before_filter :delete_authorize, :only => :destroy
+  before_filter :active_authorize, :only => :toggle_active
 
   verify :method => :post, :only => :destroy
 
@@ -54,6 +56,12 @@
     redirect_to :controller => 'projects', :action => 'show', :id => @project
   end
 
+  def toggle_active
+    @attachment.active = !@attachment.active?
+    @attachment.save!
+    render :layout => false
+  end
+
 private
   def find_project
     @attachment = Attachment.find(params[:id])
@@ -77,6 +85,10 @@
     @attachment.deletable? ? true : deny_access
   end
 
+  def active_authorize
+    true
+  end
+
   def detect_content_type(attachment)
     content_type = attachment.content_type
     if content_type.blank?