Diff
Modified: branches/events/app/controllers/citations_controller.rb (3115 => 3116)
--- branches/events/app/controllers/citations_controller.rb 2012-08-25 16:09:10 UTC (rev 3115)
+++ branches/events/app/controllers/citations_controller.rb 2012-08-25 16:09:52 UTC (rev 3116)
@@ -47,6 +47,8 @@
respond_to do |format|
if @citation.save
+
+ Activity.create(:subject => current_user, :action ="" 'create', :objekt => @citation, :auth => @workflow)
flash[:notice] = 'Citation was successfully created.'
format.html { redirect_to workflow_citation_url(@workflow, @citation) }
else
@@ -59,6 +61,7 @@
def update
respond_to do |format|
if @citation.update_attributes(params[:citation])
+ Activity.create(:subject => current_user, :action ="" 'edit', :objekt => @citation, :auth => @workflow)
flash[:notice] = 'Citation was successfully updated.'
format.html { redirect_to workflow_citation_url(@workflow, @citation) }
else
Modified: branches/events/app/helpers/application_helper.rb (3115 => 3116)
--- branches/events/app/helpers/application_helper.rb 2012-08-25 16:09:10 UTC (rev 3115)
+++ branches/events/app/helpers/application_helper.rb 2012-08-25 16:09:52 UTC (rev 3116)
@@ -556,6 +556,8 @@
thing = thing.bookmarkable
when "Comment"
thing = thing.commentable
+ when "Citation"
+ thing = thing.workflow
end
if thing
@@ -573,6 +575,10 @@
link_aux(activity.objekt, activity.objekt_label)
end
+ def auth_link(activity)
+ link_aux(activity.auth, activity.auth.label)
+ end
+
conditions_expr = []
conditions_operands = []
@@ -628,7 +634,10 @@
when "BlobVersion create": "#{subject_link(activity)} uploaded a new version of #{objekt_link(activity)}"
when "BlobVersion edit": "#{subject_link(activity)} edited version #{activity.extra} of #{objekt_link(activity)}"
when "Bookmark create": "#{subject_link(activity)} favourited #{objekt_link(activity)}"
+ 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 "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)}"
Modified: branches/events/config/routes.rb (3115 => 3116)
--- branches/events/config/routes.rb 2012-08-25 16:09:10 UTC (rev 3115)
+++ branches/events/config/routes.rb 2012-08-25 16:09:52 UTC (rev 3116)
@@ -12,7 +12,8 @@
:controller => 'linked_data', :action ="" 'attributions', :conditions => { :method => :get }
map.connect '/:contributable_type/:contributable_id/citations/:citation_id.:format',
- :controller => 'linked_data', :action ="" 'citations', :conditions => { :method => :get }
+ :controller => 'linked_data', :action ="" 'citations', :conditions => { :method => :get },
+ :requirements => { :citation_id => /[0-9]*/ }
map.connect '/:contributable_type/:contributable_id/comments/:comment_id.:format',
:controller => 'linked_data', :action ="" 'comments', :conditions => { :method => :get }
Modified: branches/events/lib/rest.rb (3115 => 3116)
--- branches/events/lib/rest.rb 2012-08-25 16:09:10 UTC (rev 3115)
+++ branches/events/lib/rest.rb 2012-08-25 16:09:52 UTC (rev 3116)
@@ -2116,11 +2116,17 @@
ob.tag = tag if tag
if subject
- return rest_response(401, :reason => "Not authorised for the specified resource") unless Authorization.check(action, Rating, opts[:user], subject)
+ return rest_response(401, :reason => "Not authorised for the specified resource") unless Authorization.check(action, Tagging, opts[:user], subject)
ob.taggable = subject
end
- return rest_response(400, :object => ob) unless ob.save
+ success = ob.save
+
+ if success && action == "create"
+ 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 (3115 => 3116)
--- branches/events/test/functional/api_controller_test.rb 2012-08-25 16:09:10 UTC (rev 3115)
+++ branches/events/test/functional/api_controller_test.rb 2012-08-25 16:09:52 UTC (rev 3116)
@@ -865,6 +865,8 @@
existing_taggings = Tagging.find(:all)
+ existing_activities = Activity.all
+
rest_request(:post, 'tagging', "<?xml version='1.0'?>
<tagging>
<subject resource='#{workflow_url}'/>
@@ -873,6 +875,13 @@
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("my test tag", new_activities.first.objekt.tag.name)
+
extra_taggings = Tagging.find(:all) - existing_taggings
assert_equal(extra_taggings.length, 1)
Modified: branches/events/vendor/plugins/acts_as_taggable_redux/lib/tag.rb (3115 => 3116)
--- branches/events/vendor/plugins/acts_as_taggable_redux/lib/tag.rb 2012-08-25 16:09:10 UTC (rev 3115)
+++ branches/events/vendor/plugins/acts_as_taggable_redux/lib/tag.rb 2012-08-25 16:09:52 UTC (rev 3116)
@@ -32,7 +32,15 @@
# Tag a taggable with this tag, optionally add user to add owner to tagging
def tag(taggable, user_id = nil)
- taggings.create :taggable => taggable, :user_id => user_id
+
+ tagging = Tagging.create(:taggable => taggable, :user_id => user_id)
+
+ taggings << tagging
+
+ if user_id
+ Activity.create(:subject => User.find(user_id), :action ="" 'create', :objekt => tagging, :auth => taggable)
+ end
+
taggings.reset
@tagged = nil
end