myexperiment-hackers
[Top][All Lists]
Advanced

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

[myexperiment-hackers] [3769] branches/packs/app: added pack activity fo


From: noreply
Subject: [myexperiment-hackers] [3769] branches/packs/app: added pack activity for adding items
Date: Mon, 4 Nov 2013 15:20:52 +0000 (UTC)

Revision
3769
Author
dgc
Date
2013-11-04 15:20:51 +0000 (Mon, 04 Nov 2013)

Log Message

added pack activity for adding items

Modified Paths

Diff

Modified: branches/packs/app/controllers/packs_controller.rb (3768 => 3769)


--- branches/packs/app/controllers/packs_controller.rb	2013-11-03 11:12:46 UTC (rev 3768)
+++ branches/packs/app/controllers/packs_controller.rb	2013-11-04 15:20:51 UTC (rev 3769)
@@ -10,6 +10,7 @@
 class PacksController < ApplicationController
   include ApplicationHelper
   include ResearchObjectsHelper
+  include ActivitiesHelper
   
   ## NOTE: URI must match config/default_settings.yml ro_resource_types
   WORKFLOW_DEFINITION = "http://purl.org/wf4ever/wfdesc#WorkflowDefinition"
@@ -115,6 +116,15 @@
           render :inline => `#{Conf.rdfgen_tool} packs address@hidden
         }
       end
+
+      format.atom {
+        @title = @pack.title
+        @id = @resource = pack_url(@pack)
+        @updated = @pack.updated_at.to_datetime.rfc3339
+        @entries = activities_for_feed(:context => @pack, :user => current_user, :no_combine => true)
+
+        render "activities/feed.atom"
+      }
     end
   end
   

Modified: branches/packs/app/helpers/activities_helper.rb (3768 => 3769)


--- branches/packs/app/helpers/activities_helper.rb	2013-11-03 11:12:46 UTC (rev 3768)
+++ branches/packs/app/helpers/activities_helper.rb	2013-11-04 15:20:51 UTC (rev 3769)
@@ -34,6 +34,10 @@
           polymorphic_path(thing.workflow)
         when "GroupAnnouncement"
           group_announcement_path(thing.network, thing)
+        when "Resource"
+          if ore_path = thing.ore_path
+            polymorphic_path([thing.research_object.context, :items]) + "/" + ore_path
+          end
         else
           polymorphic_path(thing)
       end
@@ -86,6 +90,7 @@
     type_bits << "(activities.objekt_type = 'Comment' AND activities.action = '')"
     type_bits << "(activities.objekt_type = 'GroupAnnouncement' AND activities.action = '')"
     type_bits << "(activities.objekt_type = 'Membership' AND activities.action = '')"
+    type_bits << "(activities.objekt_type = 'Resource' AND activities.action = '')"
 
     # Create the conditions
 
@@ -258,6 +263,10 @@
       link_to(strip_tags(activity.objekt.title), activity.objekt.link, :rel => "nofollow")
     when "GroupAnnouncement create"
       activity_link(activity, :object)
+    when "Resource create"
+      if ore_path = activity.objekt.ore_path
+        "#{activity_link(activity, :subject)} added #{activity_link(activity, :object)}"
+      end
     end
   end
 

Modified: branches/packs/app/models/activity.rb (3768 => 3769)


--- branches/packs/app/models/activity.rb	2013-11-03 11:12:46 UTC (rev 3768)
+++ branches/packs/app/models/activity.rb	2013-11-04 15:20:51 UTC (rev 3769)
@@ -135,6 +135,11 @@
       when "FeedItem"
 
         auth = subject.feed.context
+
+      when "Resource"
+
+        contexts << object.context.pack
+        auth = object
     end
 
     uuid = SecureRandom.uuid

Modified: branches/packs/app/models/pack.rb (3768 => 3769)


--- branches/packs/app/models/pack.rb	2013-11-03 11:12:46 UTC (rev 3768)
+++ branches/packs/app/models/pack.rb	2013-11-04 15:20:51 UTC (rev 3769)
@@ -31,6 +31,8 @@
 
   has_many :versions, :class_name => "PackVersion"
 
+  has_many :activities, :as => :context
+
   belongs_to :license
 
   has_research_object

Modified: branches/packs/app/models/resource.rb (3768 => 3769)


--- branches/packs/app/models/resource.rb	2013-11-03 11:12:46 UTC (rev 3768)
+++ branches/packs/app/models/resource.rb	2013-11-04 15:20:51 UTC (rev 3769)
@@ -16,6 +16,8 @@
   after_save    :touch_research_object
   after_destroy :touch_research_object
 
+  after_create  :generate_create_activity
+
   belongs_to :research_object
 
   belongs_to :content_blob, :dependent => :destroy
@@ -336,4 +338,15 @@
       1
     end
   end
+
+  def generate_create_activity
+
+    if context
+      if match = creator_uri.match("^\/users\/([0-9]+)$")
+        user = User.find(match[1])
+      end
+
+      Activity.create_activities(:subject => user, :action ="" 'create', :object => self)
+    end
+  end
 end

reply via email to

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