lib/orange-more/administration/cartons/user.rb in orange-0.1.2 vs lib/orange-more/administration/cartons/user.rb in orange-0.1.4

- old
+ new

@@ -1,17 +1,27 @@ require 'orange-core/carton' -module Orange - class User < Orange::Carton - id - admin do - title :name - text :open_id - end - - # Currently, all users allowed at all times. - # Future support for roles to be built here. - def allowed?(packet) +class OrangeUser < Orange::Carton + id + admin do + title :name + text :open_id + end + + has n, :orange_sites, :through => Resource + + def allowed?(packet) + subsite_access = packet['subsite'].blank? ? false : self.orange_sites.first(:id => packet['subsite'].id) + site_access = self.orange_sites.first(:id => packet['site'].id) + if(site_access) true + elsif !packet['subsite'].blank? && subsite_access + true + else + false end end +end + +class OrangeSite + has n, :orange_users, :through => Resource end \ No newline at end of file