Correct some queries, look at incoming requests in search, explicit pending false in activate_contact
This commit is contained in:
parent
b1c0facfe6
commit
aef5abf631
5 changed files with 17 additions and 10 deletions
|
|
@ -11,7 +11,7 @@ class AspectsController < ApplicationController
|
|||
def index
|
||||
@posts = current_user.visible_posts(:_type => "StatusMessage").paginate :page => params[:page], :per_page => 15, :order => 'created_at DESC'
|
||||
@post_hashes = hashes_for_posts @posts
|
||||
@contacts = current_user.contacts
|
||||
@contacts = current_user.contacts(:pending => false)
|
||||
@aspect_hashes = hashes_for_aspects @aspects.all, @contacts, :limit => 8
|
||||
@aspect = :all
|
||||
|
||||
|
|
@ -62,11 +62,11 @@ class AspectsController < ApplicationController
|
|||
|
||||
def show
|
||||
@aspect = current_user.aspect_by_id params[:id]
|
||||
@contacts = current_user.contacts
|
||||
@contacts = current_user.contacts(:pending => false)
|
||||
unless @aspect
|
||||
render :file => "#{Rails.root}/public/404.html", :layout => false, :status => 404
|
||||
else
|
||||
@aspect_contacts = hashes_for_contacts @aspect.contacts
|
||||
@aspect_contacts = hashes_for_contacts @aspect.contacts(:pending => false)
|
||||
@aspect_contacts_count = @aspect_contacts.count
|
||||
|
||||
@posts = @aspect.posts.find_all_by__type("StatusMessage", :order => 'created_at desc').paginate :page => params[:page], :per_page => 15
|
||||
|
|
@ -79,7 +79,7 @@ class AspectsController < ApplicationController
|
|||
|
||||
def manage
|
||||
@aspect = :manage
|
||||
@contacts = current_user.contacts
|
||||
@contacts = current_user.contacts(:pending => false)
|
||||
@remote_requests = Request.hashes_for_person(current_user.person)
|
||||
@aspect_hashes = hashes_for_aspects @aspects, @contacts
|
||||
end
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class PeopleController < ApplicationController
|
|||
def hashes_for_people people, aspects
|
||||
ids = people.map{|p| p.id}
|
||||
requests = {}
|
||||
Request.all(:to_id.in => ids, :from_id => current_user.person.id).each do |r|
|
||||
Request.all(:from_id.in => ids, :to_id => current_user.person.id).each do |r|
|
||||
requests[r.to_id] = r
|
||||
end
|
||||
contacts = {}
|
||||
|
|
@ -53,7 +53,11 @@ class PeopleController < ApplicationController
|
|||
@aspects_with_person = @contact.aspects
|
||||
end
|
||||
|
||||
@commenting_disabled = (current_user.person.id != @person.id) && !@contact
|
||||
if (@person != current_user.person) && (!@contact || @contact.pending)
|
||||
@commenting_disabled = true
|
||||
else
|
||||
@commenting_disabled = false
|
||||
end
|
||||
|
||||
@posts = current_user.posts_from(@person).paginate :page => params[:page]
|
||||
@post_hashes = hashes_for_posts @posts
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
class Contact
|
||||
include MongoMapper::Document
|
||||
|
||||
key :pending, Boolean
|
||||
key :pending, Boolean, :default => true
|
||||
|
||||
key :user_id, ObjectId
|
||||
belongs_to :user
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@
|
|||
.right{:style=>"display:inline;"}
|
||||
- if person.owner_id == current_user.id
|
||||
= t('.thats_you')
|
||||
- elsif contact
|
||||
- elsif contact && !contact.pending
|
||||
= t('.already_connected')
|
||||
- elsif request
|
||||
- elsif (contact && contact.pending) || request
|
||||
= link_to t('.pending_request'), aspects_manage_path
|
||||
- else
|
||||
- single_aspect_form ||= nil
|
||||
|
|
|
|||
|
|
@ -117,7 +117,10 @@ module Diaspora
|
|||
end
|
||||
|
||||
def activate_contact(person, aspect)
|
||||
new_contact = Contact.create!(:user => self, :person => person, :aspects => [aspect])
|
||||
new_contact = Contact.create!(:user => self,
|
||||
:person => person,
|
||||
:aspects => [aspect],
|
||||
:pending => false)
|
||||
new_contact.aspects << aspect
|
||||
save!
|
||||
aspect.save!
|
||||
|
|
|
|||
Loading…
Reference in a new issue