Mercurial > hg > soundsoftware-site
diff app/controllers/attachments_controller.rb @ 318:f7c525dc7585 luisf
Merge from branch "live"
author | luisf <luis.figueira@eecs.qmul.ac.uk> |
---|---|
date | Mon, 28 Mar 2011 18:17:06 +0100 |
parents | 3ecf99348b9f |
children | 350acce374a2 |
line wrap: on
line diff
--- a/app/controllers/attachments_controller.rb Thu Mar 24 13:59:03 2011 +0000 +++ b/app/controllers/attachments_controller.rb Mon Mar 28 18:17:06 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?