myexperiment-hackers
[Top][All Lists]
Advanced

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

[myexperiment-hackers] [3793] branches/packs/app/controllers/application


From: noreply
Subject: [myexperiment-hackers] [3793] branches/packs/app/controllers/application_controller.rb: add activities to attribution creation
Date: Tue, 19 Nov 2013 13:43:45 +0000 (UTC)

Revision
3793
Author
dgc
Date
2013-11-19 13:43:44 +0000 (Tue, 19 Nov 2013)

Log Message

add activities to attribution creation

Modified Paths

Diff

Modified: branches/packs/app/controllers/application_controller.rb (3792 => 3793)


--- branches/packs/app/controllers/application_controller.rb	2013-11-19 01:18:57 UTC (rev 3792)
+++ branches/packs/app/controllers/application_controller.rb	2013-11-19 13:43:44 UTC (rev 3793)
@@ -397,21 +397,32 @@
     
     # Then create new attributions:
     
-    # Workflows
-    attributor_workflow_ids = parse_comma_seperated_string(params[:attributions_workflows])
-    attributor_type = 'Workflow'
-    attributor_workflow_ids.each do |id|
-      a = Attribution.new(:attributor_type => attributor_type, :attributor_id => id, :attributable_type => attributable.class.to_s, :attributable_id  => attributable.id)
-      a.save
+    attributor_targets = []
+
+    # Collect workflow attributions
+
+    parse_comma_seperated_string(params[:attributions_workflows]).each do |id|
+      attributor_targets << Workflow.find(id)
     end
-    
-    # Files
-    attributor_file_ids = parse_comma_seperated_string(params[:attributions_files])
-    attributor_type = 'Blob'
-    attributor_file_ids.each do |id|
-      a = Attribution.new(:attributor_type => attributor_type, :attributor_id => id, :attributable_type => attributable.class.to_s, :attributable_id  => attributable.id)
-      a.save
+
+    # Collect file attributions
+
+    parse_comma_seperated_string(params[:attributions_files]).each do |id|
+      attributor_targets << Blob.find(id)
     end
+
+    # Add attribution records
+
+    attributor_targets.each do |attributor|
+
+      attribution_record = Attribution.new(
+          :attributor => attributor,
+          :attributable => attributable)
+
+      if attribution_record.save
+        Activity.create_activities(:subject => current_user, :action ="" 'create', :object => attribution_record)
+      end
+    end
     
   end
  

reply via email to

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