SHARE
TWEET

Untitled

a guest Apr 20th, 2018 106 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. ruby script/generate scaffold User username:string password:string
  3. ruby script/generate scaffold Portlet Portletname:string user:references
  4. ruby script/generate scaffold Group groupname:string user:references
  5. ruby script/generate scaffold Member group:references user:references
  6. ruby script/generate resource upermit Portlet:references user:references
  7. ruby script/generate resource gpermit Portlet:references group:references
  8.  
  9.  
  10. The Portlet model just call authorize to a portlet based on the user.
  11.  
  12.   def self.permit(portlet, user)
  13.     return false if portlet.nil? or user.nil?
  14.     if Upermit.permit_user(portlet,user) or Gpermit.permit_user(portlet,user)
  15.       true
  16.     else
  17.       false
  18.     end
  19.   end
  20.  
  21.  
  22. In the Gpermits Model:
  23.  
  24.   def self.permit_user(Portlet, user)
  25.     return false if Portlet.nil? or user.nil?
  26.     Gpermit.get_groups(Portlet) do |group|
  27.       Group.get_members(group) do |member|
  28.         return true if user == member
  29.       end
  30.     end
  31.   end
  32.  
  33.   def self.get_groups(Portlet)
  34.     return false if Portlet.nil?
  35.     find_by_Portlet_id(Portlet)
  36.   end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top