myexperiment-hackers
[Top][All Lists]
Advanced

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

[myexperiment-hackers] [3624] branches/packs/lib/authorization.rb: Added


From: noreply
Subject: [myexperiment-hackers] [3624] branches/packs/lib/authorization.rb: Added function to determine who is authorized for a particular action on an object
Date: Wed, 21 Aug 2013 13:39:45 +0000 (UTC)

Revision
3624
Author
dgc
Date
2013-08-21 13:39:45 +0000 (Wed, 21 Aug 2013)

Log Message

Added function to determine who is authorized for a particular action on an object

Modified Paths

Diff

Modified: branches/packs/lib/authorization.rb (3623 => 3624)


--- branches/packs/lib/authorization.rb	2013-08-21 13:39:02 UTC (rev 3623)
+++ branches/packs/lib/authorization.rb	2013-08-21 13:39:45 UTC (rev 3624)
@@ -493,5 +493,17 @@
 
     scope
   end
+
+  # This function calculates which agents are authorized to perform a given
+  # action on a given object.  E.g. "Who can edit this workflow"?
+
+  def self.authorized_for_object(action, object)
+    case action
+    when :view, :download, :edit
+      [object.contributor] + Permission.all(:conditions => { action ="" true, :policy_id => object.contribution.policy_id } ).map { |p| p.contributor }
+    else
+      raise "Unknown action: #{action}"
+    end
+  end
 end
 

reply via email to

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