Mercurial > hg > soundsoftware-site
diff app/controllers/attachments_controller.rb @ 1116:bb32da3bea34 redmine-2.2-integration
Merge from live
author | Chris Cannam |
---|---|
date | Mon, 07 Jan 2013 14:41:20 +0000 |
parents | 433d4f72a19b 19884e9d5eff |
children | 2f6e71e31b55 |
line wrap: on
line diff
--- a/app/controllers/attachments_controller.rb Mon Jan 07 12:01:42 2013 +0000 +++ b/app/controllers/attachments_controller.rb Mon Jan 07 14:41:20 2013 +0000 @@ -20,6 +20,10 @@ before_filter :file_readable, :read_authorize, :only => [:show, :download, :thumbnail] before_filter :delete_authorize, :only => :destroy before_filter :authorize_global, :only => :upload + before_filter :active_authorize, :only => :toggle_active + + include AttachmentsHelper + helper :attachments accept_api_auth :show, :download, :upload @@ -48,7 +52,9 @@ end def download - if @attachment.container.is_a?(Version) || @attachment.container.is_a?(Project) + # cc: formerly this happened only if "@attachment.container.is_a?(Version)" + # or Project. Not good for us, we want to tally all downloads [by humans] + if not user_is_search_bot? @attachment.increment_download end @@ -106,6 +112,12 @@ redirect_to_referer_or project_path(@project) end + def toggle_active + @attachment.active = !@attachment.active? + @attachment.save! + render :layout => false + end + private def find_project @attachment = Attachment.find(params[:id]) @@ -129,6 +141,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?