Sha256: 76a990e16b511570cd73c3f1f7245b21cc414e2994c59c87c796b2754029e6c1

Contents?: true

Size: 1.02 KB

Versions: 16

Compression:

Stored size: 1.02 KB

Contents

module Orange
  class UserResource < Orange::ModelResource
    use OrangeUser
    call_me :users
    def afterLoad
      orange[:admin].add_link("Settings", :resource => @my_orange_name, :text => 'Users')
    end
    
    def access_allowed?(packet, user)
      u = model_class.first(:open_id => user)
      return false unless u
      u.allowed?(packet)
    end
    
    def user_for(packet)
      model_class.first(:open_id => packet['user.id'])
    end
    
    def onNew(packet, opts = {})
      params = opts
      sites = params.delete 'sites'
      m = model_class.new(params)
      m.save
      sites.each{|k,v| s = OrangeSite.first(:id => k); m.orange_sites << s if s} if sites
      m
    end
    
    def onSave(packet, obj, params ={})
      sites = params.delete 'sites'
      obj.update(params)
      obj.orange_sites = []
      sites.each{|k,v| s = OrangeSite.first(:id => k); obj.orange_sites << s if s} if sites
      obj.save
    end
    
    def find_extras(packet, mode)
      {:sites => OrangeSite.all}
    end
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
orange-more-0.5.8 lib/orange-more/administration/resources/user_resource.rb
orange-more-0.5.7 lib/orange-more/administration/resources/user_resource.rb
orange-0.5.5 lib/orange-more/administration/resources/user_resource.rb
orange-0.5.4 lib/orange-more/administration/resources/user_resource.rb
orange-0.5.3 lib/orange-more/administration/resources/user_resource.rb
orange-0.5.2 lib/orange-more/administration/resources/user_resource.rb
orange-0.5.1 lib/orange-more/administration/resources/user_resource.rb
orange-0.4.0 lib/orange-more/administration/resources/user_resource.rb
orange-0.3.9 lib/orange-more/administration/resources/user_resource.rb
orange-0.3.8 lib/orange-more/administration/resources/user_resource.rb
orange-0.3.7 lib/orange-more/administration/resources/user_resource.rb
orange-0.3.6 lib/orange-more/administration/resources/user_resource.rb
orange-0.3.5 lib/orange-more/administration/resources/user_resource.rb
orange-0.3.4 lib/orange-more/administration/resources/user_resource.rb
orange-0.3.3 lib/orange-more/administration/resources/user_resource.rb
orange-0.3.2 lib/orange-more/administration/resources/user_resource.rb