Diff
Modified: trunk/app/controllers/application.rb (1889 => 1890)
--- trunk/app/controllers/application.rb 2008-10-27 17:07:06 UTC (rev 1889)
+++ trunk/app/controllers/application.rb 2008-10-28 15:18:41 UTC (rev 1890)
@@ -23,7 +23,14 @@
end
- def allow_statistics_logging
+ # this method is only intended to check if entry
+ # in "viewings" or "downloads" table needs to be
+ # created for current access - and this is *only*
+ # supposed to be working for *contributables*
+ #
+ # NB! The input parameter is the actual contributable OR
+ # the version of it (currently only workflows are versioned)
+ def allow_statistics_logging(contributable_or_version)
# check if the current viewing/download is to be logged
# (i.e. request is sent not by a bot and is legitimate)
allow_logging = true
@@ -34,6 +41,15 @@
end
end
+ # disallow logging of events referring to contributables / versions of them
+ # that have been uploaded by current user;
+ #
+ # however, if there are newer versions of contributable (uploaded not by the original uploader),
+ # we do want to record viewings/downloads of this newer version by the original uploader
+ if allow_logging
+ allow_logging = false if (contributable_or_version.contributor_type == "User" && contributable_or_version.contributor_id == current_user.id)
+ end
+
return allow_logging
end
Modified: trunk/app/controllers/blobs_controller.rb (1889 => 1890)
--- trunk/app/controllers/blobs_controller.rb 2008-10-27 17:07:06 UTC (rev 1889)
+++ trunk/app/controllers/blobs_controller.rb 2008-10-28 15:18:41 UTC (rev 1890)
@@ -37,7 +37,7 @@
# GET /files/1;download
def download
- if allow_statistics_logging
+ if allow_statistics_logging(@blob)
@download = Download.create(:contribution => @blob.contribution, :user => (logged_in? ? current_user : nil), :user_agent => request.env['HTTP_USER_AGENT'])
end
@@ -73,7 +73,7 @@
# GET /files/1
def show
- if allow_statistics_logging
+ if allow_statistics_logging(@blob)
@viewing = Viewing.create(:contribution => @blob.contribution, :user => (logged_in? ? current_user : nil), :user_agent => request.env['HTTP_USER_AGENT'])
end
Modified: trunk/app/controllers/packs_controller.rb (1889 => 1890)
--- trunk/app/controllers/packs_controller.rb 2008-10-27 17:07:06 UTC (rev 1889)
+++ trunk/app/controllers/packs_controller.rb 2008-10-28 15:18:41 UTC (rev 1890)
@@ -48,7 +48,7 @@
# GET /packs/1
def show
- if allow_statistics_logging
+ if allow_statistics_logging(@pack)
@viewing = Viewing.create(:contribution => @pack.contribution, :user => (logged_in? ? current_user : nil), :user_agent => request.env['HTTP_USER_AGENT'])
end
@@ -75,7 +75,7 @@
@pack.create_zip(current_user, image_hash)
- if allow_statistics_logging
+ if allow_statistics_logging(@pack)
@download = Download.create(:contribution => @pack.contribution, :user => (logged_in? ? current_user : nil), :user_agent => request.env['HTTP_USER_AGENT'])
end
Modified: trunk/app/controllers/workflows_controller.rb (1889 => 1890)
--- trunk/app/controllers/workflows_controller.rb 2008-10-27 17:07:06 UTC (rev 1889)
+++ trunk/app/controllers/workflows_controller.rb 2008-10-28 15:18:41 UTC (rev 1890)
@@ -157,7 +157,7 @@
# GET /workflows/1;download
def download
- if allow_statistics_logging
+ if allow_statistics_logging(@viewing_version)
@download = Download.create(:contribution => @workflow.contribution, :user => (logged_in? ? current_user : nil), :user_agent => request.env['HTTP_USER_AGENT'])
end
@@ -227,7 +227,7 @@
# GET /workflows/1
def show
- if allow_statistics_logging
+ if allow_statistics_logging(@viewing_version)
@viewing = Viewing.create(:contribution => @workflow.contribution, :user => (logged_in? ? current_user : nil), :user_agent => request.env['HTTP_USER_AGENT'])
end