32 lines
853 B
Ruby
32 lines
853 B
Ruby
ActiveAdmin.register JamRuby::User, :as => 'Referrals' do
|
|
|
|
menu :label => 'Referrals', :parent => 'Affiliates'
|
|
|
|
config.batch_actions = false
|
|
config.clear_action_items!
|
|
config.filters = false
|
|
|
|
index do
|
|
column 'User' do |oo| link_to(oo.name, oo.admin_url, {:title => oo.name}) end
|
|
column 'Email' do |oo| oo.email end
|
|
column 'Created' do |oo| oo.created_at end
|
|
column 'Partner' do |oo| oo.affiliate_referral.display_name end
|
|
end
|
|
|
|
controller do
|
|
|
|
def scoped_collection
|
|
rel = end_of_association_chain
|
|
.includes([:affiliate_referral])
|
|
.order('created_at DESC')
|
|
if (ref_id = params[AffiliatePartner::PARAM_REFERRAL]).present?
|
|
qq = ['affiliate_referral_id = ?', ref_id]
|
|
else
|
|
qq = ['affiliate_referral_id IS NOT NULL']
|
|
end
|
|
@users ||= rel.where(qq)
|
|
end
|
|
|
|
end
|
|
end
|