Newer
Older
# Copyright (c) 2010-2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
class ContactsController < ApplicationController
before_filter :authenticate_user!
@contacts = case params[:set]
when "only_sharing"
current_user.contacts.only_sharing
when "all"
current_user.contacts
if params[:a_id]
@aspect = current_user.aspects.find(params[:a_id])
@aspect.contacts
else
current_user.contacts.receiving
end
end
respond_to do |format|
format.html { @contacts = sort_and_paginate_profiles(@contacts) }
format.mobile { @contacts = sort_and_paginate_profiles(@contacts) }
Raphael Sofaer
a validé
@people = Person.for_json.joins(:contacts => :aspect_memberships).
where(:contacts => { :user_id => current_user.id },
:aspect_memberships => { :aspect_id => params[:aspect_ids] })
Raphael Sofaer
a validé
render :json => @people.to_json
@contacts = current_user.contacts.sharing.includes(:aspect_memberships)
render :layout => false
Ilyaaaaaaaaaaaaa Zhitomirskiy
a validé
@people = Person.featured_users
private
def sort_and_paginate_profiles contacts
contacts.
includes(:aspects, :person => :profile).
order('profiles.last_name ASC').
paginate(:page => params[:page], :per_page => 25)
end