comparison app/controllers/attachments_controller.rb @ 967:19884e9d5eff bug_521

Only count downloads from non-bots
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Wed, 17 Oct 2012 10:42:48 +0100
parents 35782bf2eb58
children bb32da3bea34
comparison
equal deleted inserted replaced
957:35782bf2eb58 967:19884e9d5eff
14 # You should have received a copy of the GNU General Public License 14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software 15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 class AttachmentsController < ApplicationController 18 class AttachmentsController < ApplicationController
19
20 include AttachmentsHelper
21 helper :attachments
19 22
20 before_filter :find_project 23 before_filter :find_project
21 before_filter :file_readable, :read_authorize, :except => :destroy 24 before_filter :file_readable, :read_authorize, :except => :destroy
22 before_filter :delete_authorize, :only => :destroy 25 before_filter :delete_authorize, :only => :destroy
23 before_filter :active_authorize, :only => :toggle_active 26 before_filter :active_authorize, :only => :toggle_active
48 end 51 end
49 end 52 end
50 53
51 def download 54 def download
52 # cc: formerly this happened only if "@attachment.container.is_a?(Version)" 55 # cc: formerly this happened only if "@attachment.container.is_a?(Version)"
53 # or Project. Not good for us, we want to tally all downloads 56 # or Project. Not good for us, we want to tally all downloads [by humans]
54 @attachment.increment_download 57 if not user_is_search_bot?
58 @attachment.increment_download
59 end
55 60
56 # images are sent inline 61 # images are sent inline
57 send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename), 62 send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
58 :type => detect_content_type(@attachment), 63 :type => detect_content_type(@attachment),
59 :disposition => (@attachment.image? ? 'inline' : 'attachment') 64 :disposition => (@attachment.image? ? 'inline' : 'attachment')