myexperiment-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myexperiment-hackers] [3117] branches/events: added rating activity


From: noreply
Subject: [myexperiment-hackers] [3117] branches/events: added rating activity
Date: Sat, 25 Aug 2012 16:23:53 +0000 (UTC)

Revision
3117
Author
dgc
Date
2012-08-25 16:23:52 +0000 (Sat, 25 Aug 2012)

Log Message

added rating activity

Modified Paths

Diff

Modified: branches/events/app/controllers/blobs_controller.rb (3116 => 3117)


--- branches/events/app/controllers/blobs_controller.rb	2012-08-25 16:09:52 UTC (rev 3116)
+++ branches/events/app/controllers/blobs_controller.rb	2012-08-25 16:23:52 UTC (rev 3117)
@@ -281,7 +281,8 @@
     else
       Rating.delete_all(["rateable_type = ? AND rateable_id = ? AND user_id = ?", @blob.class.to_s, @blob.id, current_user.id])
       
-      Rating.create(:rateable => @blob, :user => current_user, :rating => params[:rating])
+      rating = Rating.create(:rateable => @blob, :user => current_user, :rating => params[:rating])
+      Activity.create(:subject => current_user, :action ="" 'create', :objekt => rating, :auth => @blob, :extra => params[:rating].to_i)
       
       respond_to do |format|
         format.html { 

Modified: branches/events/app/controllers/workflows_controller.rb (3116 => 3117)


--- branches/events/app/controllers/workflows_controller.rb	2012-08-25 16:09:52 UTC (rev 3116)
+++ branches/events/app/controllers/workflows_controller.rb	2012-08-25 16:23:52 UTC (rev 3117)
@@ -87,7 +87,8 @@
     else
       Rating.delete_all(["rateable_type = ? AND rateable_id = ? AND user_id = ?", @workflow.class.to_s, @workflow.id, current_user.id])
       
-      Rating.create(:rateable => @workflow, :user => current_user, :rating => params[:rating])
+      rating = Rating.create(:rateable => @workflow, :user => current_user, :rating => params[:rating])
+      Activity.create(:subject => current_user, :action ="" 'create', :objekt => rating, :auth => @workflow, :extra => params[:rating].to_i)
       
       respond_to do |format|
         format.html { 

Modified: branches/events/app/helpers/application_helper.rb (3116 => 3117)


--- branches/events/app/helpers/application_helper.rb	2012-08-25 16:09:52 UTC (rev 3116)
+++ branches/events/app/helpers/application_helper.rb	2012-08-25 16:23:52 UTC (rev 3117)
@@ -637,8 +637,9 @@
         when "Citation create":        "#{subject_link(activity)} added the citation #{objekt_link(activity)} to #{auth_link(activity)}"
         when "Citation edit":          "#{subject_link(activity)} edited the citation #{objekt_link(activity)} on #{auth_link(activity)}"
         when "Comment create":         "#{subject_link(activity)} commented on #{objekt_link(activity)}"
+        when "Pack create":            "#{subject_link(activity)} created #{objekt_link(activity)}"
+        when "Rating create":          "#{subject_link(activity)} rated #{auth_link(activity)} with #{activity.extra}"
         when "Tagging create":         "#{subject_link(activity)} tagged #{auth_link(activity)} with "#{activity.objekt.tag.name}""
-        when "Pack create":            "#{subject_link(activity)} created #{objekt_link(activity)}"
         when "Workflow create":        "#{subject_link(activity)} uploaded #{objekt_link(activity)}"
         when "Workflow edit":          "#{subject_link(activity)} edited #{objekt_link(activity)}"
         when "WorkflowVersion create": "#{subject_link(activity)} uploaded a new version of #{objekt_link(activity)}"

Modified: branches/events/lib/rest.rb (3116 => 3117)


--- branches/events/lib/rest.rb	2012-08-25 16:09:52 UTC (rev 3116)
+++ branches/events/lib/rest.rb	2012-08-25 16:23:52 UTC (rev 3117)
@@ -2060,7 +2060,13 @@
       ob.rateable = subject
     end
 
-    return rest_response(400, :object => ob) unless ob.save
+    success = ob.save
+
+    if success
+      Activity.create(:subject => opts[:user], :action ="" 'create', :objekt => ob, :auth => subject)
+    end
+
+    return rest_response(400, :object => ob) unless success
   end
 
   rest_get_request(ob, opts[:user], { "id" => ob.id.to_s })

Modified: branches/events/test/functional/api_controller_test.rb (3116 => 3117)


--- branches/events/test/functional/api_controller_test.rb	2012-08-25 16:09:52 UTC (rev 3116)
+++ branches/events/test/functional/api_controller_test.rb	2012-08-25 16:23:52 UTC (rev 3117)
@@ -722,6 +722,8 @@
 
     existing_ratings = Rating.find(:all)
 
+    existing_activities = Activity.all
+
     rest_request(:post, 'rating', "<?xml version='1.0'?>
       <rating>
         <rating>4</rating>
@@ -730,6 +732,14 @@
 
     assert_response(:success)
 
+    new_activities = Activity.all - existing_activities
+
+    assert_equal(1, new_activities.length)
+    assert_equal("John Smith", new_activities.first.subject.name)
+    assert_equal("create", new_activities.first.action)
+    assert_equal("Unique tags", new_activities.first.objekt.rateable.title)
+    assert_equal("Unique tags", new_activities.first.auth.title)
+
     extra_ratings = Rating.find(:all) - existing_ratings 
     
     assert_equal(extra_ratings.length, 1)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]