fixed the querying in the controllers got rid of hashes
This commit is contained in:
parent
d0074d0d8a
commit
004094d66f
34 changed files with 85 additions and 245 deletions
|
|
@ -11,9 +11,9 @@ class AspectsController < ApplicationController
|
|||
|
||||
def index
|
||||
if params[:a_ids]
|
||||
@aspects = current_user.aspects_from_ids(params[:a_ids])
|
||||
@aspects = current_user.aspects.where(:id => params[:a_ids]).includes(:contacts) #linit 16
|
||||
else
|
||||
@aspects = current_user.aspects
|
||||
@aspects = current_user.aspects.includes(:contacts)
|
||||
end
|
||||
|
||||
# redirect to signup
|
||||
|
|
@ -24,13 +24,11 @@ class AspectsController < ApplicationController
|
|||
@aspect_ids = @aspects.map{|a| a.id}
|
||||
post_ids = @aspects.map{|a| a.post_ids}.flatten!
|
||||
|
||||
@posts = Post.where(:id => post_ids, :type => "StatusMessage").paginate(
|
||||
@posts = StatusMessage.joins(:aspects).where(:pending => false,
|
||||
:aspects => {:id => @aspect_ids}).includes(:person, :comments, :photos).select('DISTINCT `posts`.*').paginate(
|
||||
:page => params[:page], :per_page => 15, :order => 'created_at DESC')
|
||||
@post_hashes = hashes_for_posts @posts
|
||||
|
||||
@contacts = current_user.contacts.includes(:person).where(:pending => false)
|
||||
@contact_hashes = hashes_for_contacts @contacts
|
||||
@aspect_hashes = hashes_for_aspects @aspects, @contacts, :limit => 16
|
||||
|
||||
@aspect = :all unless params[:a_ids]
|
||||
|
||||
|
|
@ -77,17 +75,13 @@ class AspectsController < ApplicationController
|
|||
end
|
||||
|
||||
def edit
|
||||
@aspect = current_user.aspects.where(:id => params[:id]).first
|
||||
@aspect = current_user.aspects.where(:id => params[:id]).includes(:contacts).first
|
||||
@contacts = current_user.contacts.where(:pending => false)
|
||||
unless @aspect
|
||||
render :file => "#{Rails.root}/public/404.html", :layout => false, :status => 404
|
||||
else
|
||||
@aspect_ids = [@aspect.id]
|
||||
@aspect_contacts = hashes_for_contacts @aspect.contacts.where(:pending => false)
|
||||
@aspect_contacts_count = @aspect_contacts.count
|
||||
|
||||
@all_contacts = hashes_for_contacts @contacts
|
||||
|
||||
@aspect_contacts_count = @aspect.contacts.count
|
||||
render :layout => false
|
||||
end
|
||||
end
|
||||
|
|
@ -95,8 +89,8 @@ class AspectsController < ApplicationController
|
|||
def manage
|
||||
@aspect = :manage
|
||||
@contacts = current_user.contacts.where(:pending => false)
|
||||
@remote_requests = Request.hashes_for_person(current_user.person)
|
||||
@aspect_hashes = hashes_for_aspects @all_aspects, @contacts
|
||||
@remote_requests = Request.where(:recipient_id => current_user.person.id)
|
||||
@aspects = @all_aspects.includes(:contacts)
|
||||
end
|
||||
|
||||
def update
|
||||
|
|
@ -184,51 +178,4 @@ class AspectsController < ApplicationController
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def hashes_for_contacts contacts
|
||||
contacts.includes(:person).map{|c| {:contact => c, :person => c.person}}
|
||||
end
|
||||
|
||||
def hashes_for_aspects aspects, contacts, opts = {}
|
||||
contact_hashes = hashes_for_contacts contacts
|
||||
aspects.map do |a|
|
||||
hash = {:aspect => a}
|
||||
aspect_contact_hashes = contact_hashes.select{|c|
|
||||
c[:contact].aspects.include?(a)}
|
||||
hash[:contact_count] = aspect_contact_hashes.count
|
||||
if opts[:limit]
|
||||
hash[:contacts] = aspect_contact_hashes.slice(0,opts[:limit])
|
||||
else
|
||||
hash[:contacts] = aspect_contact_hashes
|
||||
end
|
||||
hash
|
||||
end
|
||||
end
|
||||
def hashes_for_posts posts
|
||||
post_ids = []
|
||||
post_person_ids = []
|
||||
posts.each{|p| post_ids << p.id; post_person_ids << p.person_id}
|
||||
|
||||
comment_hash = Comment.hash_from_post_ids post_ids
|
||||
commenters_hash = Person.from_post_comment_hash comment_hash
|
||||
photo_hash = Photo.hash_from_post_ids post_ids
|
||||
|
||||
post_person_ids.uniq!
|
||||
posters = Person.where(:id => post_person_ids)
|
||||
posters_hash = {}
|
||||
posters.each{|poster| posters_hash[poster.id] = poster}
|
||||
|
||||
posts.map do |post|
|
||||
{:post => post,
|
||||
:photos => photo_hash[post.id],
|
||||
:person => posters_hash[post.person_id],
|
||||
:comments => comment_hash[post.id].map do |comment|
|
||||
{:comment => comment,
|
||||
:person => commenters_hash[comment.person_id],
|
||||
}
|
||||
end,
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -26,10 +26,9 @@ class CommentsController < ApplicationController
|
|||
:comment_id => @comment.id,
|
||||
:html => render_to_string(
|
||||
:partial => 'comments/comment',
|
||||
:locals => { :hash => {
|
||||
:comment => @comment,
|
||||
:locals => { :comment => @comment,
|
||||
:person => current_user.person,
|
||||
}}
|
||||
}
|
||||
)
|
||||
}
|
||||
render(:json => json, :status => 201)
|
||||
|
|
|
|||
|
|
@ -64,7 +64,6 @@ class PeopleController < ApplicationController
|
|||
end
|
||||
|
||||
@posts = current_user.posts_from(@person).where(:type => "StatusMessage").paginate :page => params[:page]
|
||||
@post_hashes = hashes_for_posts @posts
|
||||
|
||||
respond_with @person, :locals => {:post_type => :all}
|
||||
|
||||
|
|
|
|||
|
|
@ -156,13 +156,6 @@ class PhotosController < ApplicationController
|
|||
@object_aspect_ids = @parent.aspects.map{|a| a.id}
|
||||
end
|
||||
|
||||
comments_hash = Comment.hash_from_post_ids [@parent.id]
|
||||
person_hash = Person.from_post_comment_hash comments_hash
|
||||
@comment_hashes = comments_hash[@parent.id].map do |comment|
|
||||
{:comment => comment,
|
||||
:person => person_hash[comment.person_id]
|
||||
}
|
||||
end
|
||||
@ownership = current_user.owns? @photo
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -70,13 +70,6 @@ class StatusMessagesController < ApplicationController
|
|||
|
||||
def show
|
||||
@status_message = current_user.find_visible_post_by_id params[:id]
|
||||
comments_hash = Comment.hash_from_post_ids [@status_message.id]
|
||||
person_hash = Person.from_post_comment_hash comments_hash
|
||||
@comment_hashes = comments_hash[@status_message.id].map do |comment|
|
||||
{:comment => comment,
|
||||
:person => person_hash[comment.person_id]
|
||||
}
|
||||
end
|
||||
|
||||
@object_aspect_ids = @status_message.aspects.map{|a| a.id}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ module SocketsHelper
|
|||
v = render_to_string(:partial => 'people/person', :locals => person_hash)
|
||||
|
||||
elsif object.is_a? Comment
|
||||
v = render_to_string(:partial => 'comments/comment', :locals => {:hash => {:comment => object, :person => object.person}})
|
||||
v = render_to_string(:partial => 'comments/comment', :locals => {:comment => object, :person => object.person})
|
||||
|
||||
elsif object.is_a? Notification
|
||||
v = render_to_string(:partial => 'notifications/popup', :locals => {:note => object, :person => object.actor})
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
# the COPYRIGHT file.
|
||||
|
||||
class Comment < ActiveRecord::Base
|
||||
default_scope :include => :person
|
||||
require File.join(Rails.root, 'lib/diaspora/web_socket')
|
||||
require File.join(Rails.root, 'lib/youtube_titles')
|
||||
include YoutubeTitles
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
# the COPYRIGHT file.
|
||||
|
||||
class Contact < ActiveRecord::Base
|
||||
default_scope :include => :person
|
||||
belongs_to :user
|
||||
validates_presence_of :user
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
# the COPYRIGHT file.
|
||||
|
||||
class Post < ActiveRecord::Base
|
||||
default_scope :include => [:person, :comments]
|
||||
require File.join(Rails.root, 'lib/encryptable')
|
||||
require File.join(Rails.root, 'lib/diaspora/web_socket')
|
||||
include ApplicationHelper
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ class Request < ActiveRecord::Base
|
|||
include Diaspora::Webhooks
|
||||
include ROXML
|
||||
|
||||
default_scope :include => :sender
|
||||
|
||||
xml_accessor :sender_handle
|
||||
xml_accessor :recipient_handle
|
||||
|
||||
|
|
@ -54,15 +56,6 @@ class Request < ActiveRecord::Base
|
|||
sender_handle
|
||||
end
|
||||
|
||||
def self.hashes_for_person person
|
||||
requests = Request.where(:recipient_id => person.id)
|
||||
senders = Person.where(:id => requests.map{|r| r.sender_id})
|
||||
senders_hash = {}
|
||||
senders.each{|sender| senders_hash[sender.id] = sender}
|
||||
requests.map{|r| {:request => r, :sender => senders_hash[r.sender_id]}}
|
||||
end
|
||||
|
||||
|
||||
def notification_type(user, person)
|
||||
if Contact.where(:user_id => user.id, :person_id => person.id).first
|
||||
"request_accepted"
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
%li{:data=>{:guid=>aspect.id}, :class => ("dull" if contacts.length == 0)}
|
||||
.right
|
||||
%b
|
||||
= link_to t('contacts', :count => contact_count), edit_aspect_path(aspect), :rel => 'facebox'
|
||||
= link_to t('contacts', :count => aspect.contacts.count), edit_aspect_path(aspect), :rel => 'facebox'
|
||||
%b
|
||||
= aspect.name
|
||||
%br
|
||||
|
||||
- if contacts.length > 0
|
||||
- if aspect.contacts.length > 0
|
||||
.contacts
|
||||
- for hash in contacts
|
||||
= person_image_link(hash[:person])
|
||||
- for contact in aspect.contacts
|
||||
= person_image_link(contact.person)
|
||||
|
|
|
|||
|
|
@ -5,14 +5,14 @@
|
|||
|
||||
%h4
|
||||
.right
|
||||
= link_to t('contacts', :count => @contacts.count), aspects_manage_path, :title => t('aspects.manage.manage_aspects')
|
||||
= link_to t('contacts', :count => contacts.count), aspects_manage_path, :title => t('aspects.manage.manage_aspects')
|
||||
|
||||
= @aspect_hashes.count
|
||||
- if @aspect_hashes.count == 1
|
||||
= aspects.count
|
||||
- if aspects.count == 1
|
||||
= t('_aspect')
|
||||
- else
|
||||
= t('_aspects')
|
||||
|
||||
%ul
|
||||
- for a_hash in aspect_hashes
|
||||
= render :partial => 'aspects/aspect', :locals => a_hash
|
||||
- for aspect in aspects
|
||||
= render 'aspects/aspect', :aspect => aspect, :contacts => aspect.contacts
|
||||
|
|
|
|||
|
|
@ -5,5 +5,5 @@
|
|||
|
||||
= render 'shared/publisher', :aspect => aspect, :aspect_ids => aspect_ids
|
||||
#main_stream.stream{:data => {:guids => aspect_ids.join(',')}}
|
||||
= render 'shared/stream', :posts => post_hashes
|
||||
= will_paginate @posts
|
||||
= render 'shared/stream', :posts => posts
|
||||
= will_paginate posts
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#edit_aspect_pane
|
||||
- if @contacts.count > 0
|
||||
%h4= t('aspects.edit.add_existing')
|
||||
= render 'shared/contact_list', :aspect_id => aspect.id, :contact_hashes => contacts, :manage => defined?(manage)
|
||||
= render 'shared/contact_list', :aspect_id => aspect.id, :contacts => contacts, :manage => defined?(manage)
|
||||
|
||||
= render 'shared/add_contact', :aspect_id => aspect.id
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
%h4
|
||||
= @aspect
|
||||
.description
|
||||
= t('contacts', :count =>@aspect_contacts.count)
|
||||
= t('contacts', :count =>@aspect_contacts_count)
|
||||
|
||||
.person_tiles{:style => "display:none;"}
|
||||
- for contact in @aspect.contacts
|
||||
|
|
@ -26,7 +26,7 @@
|
|||
= button_to t('.remove_aspect'), @aspect, :method => "delete", :confirm => t('.confirm_remove_aspect'), :class => 'button'
|
||||
|
||||
- if @contacts.count > 0
|
||||
= render 'shared/contact_list', :aspect_id => @aspect.id, :contact_hashes => @all_contacts
|
||||
= render 'shared/contact_list', :aspect_id => @aspect.id, :contacts => @contacts
|
||||
|
||||
#aspect_edit_controls
|
||||
= link_to t('.rename'), '#'
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
= render 'aspect_stream',
|
||||
:aspect => @aspect,
|
||||
:aspect_ids => @aspect_ids,
|
||||
:post_hashes => @post_hashes
|
||||
:posts => @posts
|
||||
|
||||
.span-7.last
|
||||
#home_user_badge
|
||||
|
|
@ -38,7 +38,7 @@
|
|||
%hr
|
||||
|
||||
#aspect_listings.section
|
||||
= render 'aspects/aspect_listings', :aspect_hashes => @aspect_hashes
|
||||
= render 'aspects/aspect_listings', :aspects => @aspects, :contacts => @contacts
|
||||
|
||||
.section
|
||||
%h4= t('shared.invitations.invites')
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
$('#aspect_stream_container').html("<%= escape_javascript(render('aspects/aspect_stream', :aspect => @aspect, :aspect_ids => @aspect_ids, :post_hashes => @post_hashes)) %>");
|
||||
$('#aspect_listings').html("<%= escape_javascript(render('aspects/aspect_listings', :aspect_hashes => @aspect_hashes)) %>");
|
||||
$('#aspect_stream_container').html("<%= escape_javascript(render('aspects/aspect_stream', :aspect => @aspect, :aspect_ids => @aspect_ids, :posts => @posts)) %>");
|
||||
$('#aspect_listings').html("<%= escape_javascript(render('aspects/aspect_listings', :aspects => @aspects)) %>");
|
||||
$('a[rel*=facebox]').facebox();
|
||||
|
||||
$(document).ready(function() {
|
||||
|
|
|
|||
|
|
@ -8,4 +8,4 @@
|
|||
%div{:data => {:role => 'fieldcontain'}}
|
||||
=render 'shared/publisher', :aspect => @aspect
|
||||
|
||||
= render 'shared/stream', :posts => @post_hashes
|
||||
= render 'shared/stream', :posts => @posts
|
||||
|
|
|
|||
|
|
@ -24,13 +24,13 @@
|
|||
- if @remote_requests.size < 1
|
||||
%li=t('.no_requests')
|
||||
- else
|
||||
- for hash in @remote_requests
|
||||
%li.person.request{:data=>{:guid=>hash[:request].id, :person_id=>hash[:sender].id}}
|
||||
- for req in @remote_requests
|
||||
%li.person.request{:data=>{:guid=> req.id, :person_id=> req.sender.id}}
|
||||
.delete
|
||||
.x
|
||||
X
|
||||
.circle
|
||||
= link_to person_image_tag(hash[:sender]), hash[:sender]
|
||||
= link_to person_image_tag(req.sender), req.sender
|
||||
|
||||
- if @remote_requests.size > 0
|
||||
%p
|
||||
|
|
@ -42,30 +42,30 @@
|
|||
\.
|
||||
|
||||
.span-19.last
|
||||
- for hash in @aspect_hashes
|
||||
.aspect.span-9{:data=>{:guid=>hash[:aspect].id}}
|
||||
- for aspect in @aspects
|
||||
.aspect.span-9{:data=>{:guid => aspect.id}}
|
||||
.aspect_name
|
||||
%span.edit_name_field
|
||||
%h3{:contenteditable=>true}
|
||||
= hash[:aspect].name
|
||||
= aspect.name
|
||||
%span.tip click to edit
|
||||
|
||||
%ul.tools
|
||||
%li= link_to t('.add_a_new_contact'), "#manage_aspect_contacts_pane_#{hash[:aspect].id}", :class => 'manage_aspect_contacts_button', :rel => "facebox"
|
||||
%li!= remove_link(hash[:aspect])
|
||||
%li= link_to t('.add_a_new_contact'), "#manage_aspect_contacts_pane_#{aspect.id}", :class => 'manage_aspect_contacts_button', :rel => "facebox"
|
||||
%li!= remove_link(aspect)
|
||||
|
||||
%ul.dropzone{:data=>{:aspect_id=>hash[:aspect].id}}
|
||||
-for contact_hash in hash[:contacts]
|
||||
%li.person{:data=>{:guid=>contact_hash[:person].id, :aspect_id=>hash[:aspect].id}}
|
||||
%ul.dropzone{:data => {:aspect_id => aspect.id}}
|
||||
-for contact in aspect.contacts
|
||||
%li.person{:data => {:guid => contact.person.id, :aspect_id => aspect.id}}
|
||||
.delete
|
||||
.x
|
||||
X
|
||||
.circle
|
||||
= link_to person_image_tag(contact_hash[:person]), contact_hash[:person]
|
||||
= link_to person_image_tag(contact.person), contact.person
|
||||
.draggable_info
|
||||
=t('.drag_to_add')
|
||||
|
||||
.facebox_content
|
||||
%div{:id => "manage_aspect_contacts_pane_#{hash[:aspect].id}"}
|
||||
= render "requests/manage_aspect_contacts", :aspect => hash[:aspect], :manage => true, :contact_hashes => hash[:contacts]
|
||||
%div{:id => "manage_aspect_contacts_pane_#{ aspect.id}"}
|
||||
= render "requests/manage_aspect_contacts", :aspect => aspect, :manage => true, :contacts => @contacts
|
||||
|
||||
|
|
|
|||
|
|
@ -25,5 +25,5 @@
|
|||
= render 'shared/publisher', :aspect => @aspect
|
||||
|
||||
#main_stream.stream{:data => {:guids => @aspect.id}}
|
||||
= render 'shared/stream', :posts => @post_hashes
|
||||
= render 'shared/stream', :posts => @posts
|
||||
=will_paginate @posts
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
$('#main_stream').html("<%= escape_javascript(render('shared/stream', :posts => @post_hashes)) %>");
|
||||
$('#main_stream').html("<%= escape_javascript(render('shared/stream', :posts => @posts)) %>");
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@
|
|||
-# licensed under the Affero General Public License version 3 or later. See
|
||||
-# the COPYRIGHT file.
|
||||
|
||||
%li.comment{:data=>{:guid=>hash[:comment].id}, :class => ("hidden" if(defined? hidden))}
|
||||
= person_image_link(hash[:person])
|
||||
%li.comment{:data=>{:guid => comment.id}, :class => ("hidden" if(defined? hidden))}
|
||||
= person_image_link(comment.person)
|
||||
.content
|
||||
.from
|
||||
= person_link(hash[:person])
|
||||
= markdownify(hash[:comment].text, :youtube_maps => hash[:comment][:youtube_titles])
|
||||
= person_link(comment.person)
|
||||
= markdownify(comment.text, :youtube_maps => comment.youtube_titles)
|
||||
|
||||
.info
|
||||
%span.time
|
||||
= hash[:comment].created_at ? timeago(hash[:comment].created_at) : timeago(Time.now)
|
||||
= comment.created_at ? timeago(comment.created_at) : timeago(Time.now)
|
||||
|
|
|
|||
|
|
@ -4,20 +4,19 @@
|
|||
|
||||
|
||||
- unless defined?(always_expanded) && always_expanded
|
||||
%ul.show_comments{:class => ("hidden" if comment_hashes.size == 0)}
|
||||
%ul.show_comments{:class => ("hidden" if comments.size == 0)}
|
||||
%li
|
||||
= image_tag 'icons/spechbubble_2.png', :class => 'more_comments_icon'
|
||||
%b= comment_toggle(comment_hashes.size)
|
||||
%b= comment_toggle(comments.size)
|
||||
|
||||
%ul.comments{:id => post_id, :class => ("hidden" if comment_hashes.size == 0)}
|
||||
-if comment_hashes.size > 3
|
||||
%ul.comments{:id => post_id, :class => ("hidden" if comments.size == 0)}
|
||||
-if comments.size > 3
|
||||
.older_comments{:class => ("hidden inactive" if defined?(condensed) && condensed)}
|
||||
= render :partial => 'comments/comment', :collection => comment_hashes[0..-4], :as => :hash
|
||||
= render :partial => 'comments/comment', :collection => comment_hashes[-3, 3], :as => :hash
|
||||
= render :partial => 'comments/comment', :collection => comments[0..-4]
|
||||
= render :partial => 'comments/comment', :collection => comments[-3, 3]
|
||||
-else
|
||||
= render :partial => 'comments/comment', :collection => comment_hashes, :as => :hash
|
||||
= render :partial => 'comments/comment', :collection => comments
|
||||
|
||||
- unless @commenting_disabled
|
||||
%li.comment.show
|
||||
= new_comment_form(post_id)
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@
|
|||
= render 'photos/index', :photos => @posts
|
||||
- else
|
||||
#main_stream.stream
|
||||
= render 'shared/stream', :posts => @post_hashes
|
||||
= render 'shared/stream', :posts => @posts
|
||||
|
||||
= will_paginate @posts
|
||||
|
||||
|
|
|
|||
|
|
@ -63,4 +63,4 @@
|
|||
|
||||
#photo_stream.stream.show
|
||||
%div{:data=>{:guid=>@parent.id}}
|
||||
= render "comments/comments", :post_id => @parent.id, :comment_hashes => @comment_hashes, :always_expanded => true
|
||||
= render "comments/comments", :post_id => @parent.id, :comments => @parent.comments, :always_expanded => true
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
%i= aspect.name
|
||||
.span-6.append-1.last
|
||||
%h3= t('.existing')
|
||||
= render 'shared/contact_list', :aspect_id => aspect.id, :contact_hashes => contact_hashes, :manage => defined?(manage)
|
||||
= render 'shared/contact_list', :aspect_id => aspect.id, :contacts => contacts, :manage => defined?(manage)
|
||||
|
||||
.span-7.last
|
||||
= render 'shared/add_contact', :aspect_id => aspect.id
|
||||
|
|
|
|||
|
|
@ -6,13 +6,13 @@
|
|||
.contact_list
|
||||
= search_field_tag :contact_search, "", :class => 'contact_list_search', :results => 5, :placeholder => t('.all_contacts')
|
||||
%ul
|
||||
- for hash in contact_hashes
|
||||
- for contact in contacts
|
||||
%li
|
||||
= person_image_tag hash[:person]
|
||||
= person_image_tag contact.person
|
||||
%h4.name
|
||||
= link_to hash[:person].name, hash[:person]
|
||||
= link_to contact.person.name, contact.person
|
||||
.description
|
||||
= hash[:person].diaspora_handle
|
||||
= contact.person.diaspora_handle
|
||||
.right
|
||||
= aspect_membership_button(aspect_id, hash[:contact], hash[:person])
|
||||
= aspect_membership_button(aspect_id, contact, contact.person)
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
|
||||
- if posts.length > 0
|
||||
- for post_hash in posts
|
||||
= render 'shared/stream_element', post_hash.merge(:all_aspects => @all_aspects, :commenting_disabled => defined?(@commenting_disabled))
|
||||
- for post in posts
|
||||
= render 'shared/stream_element', :post => post, :all_aspects => @all_aspects, :commenting_disabled => defined?(@commenting_disabled)
|
||||
|
||||
- else
|
||||
= render 'aspects/no_posts_message', :post_count => posts.length
|
||||
|
|
|
|||
|
|
@ -3,19 +3,19 @@
|
|||
-# the COPYRIGHT file.
|
||||
|
||||
.stream_element{:data=>{:guid=>post.id}}
|
||||
- if person.owner_id == current_user.id
|
||||
- if post.person.owner_id == current_user.id
|
||||
.right.hidden.controls
|
||||
- reshare_aspects = aspects_without_post(all_aspects, post)
|
||||
- unless reshare_aspects.empty?
|
||||
= render 'shared/reshare', :aspects => reshare_aspects, :post => post
|
||||
= link_to image_tag('deletelabel.png'), status_message_path(post), :confirm => t('are_you_sure'), :method => :delete, :remote => true, :class => "delete", :title => t('delete')
|
||||
|
||||
= person_image_link(person, :size => :thumb_small)
|
||||
= person_image_link(post.person, :size => :thumb_small)
|
||||
|
||||
.content
|
||||
.from
|
||||
%h5
|
||||
=person_link(person)
|
||||
=person_link(post.person)
|
||||
|
||||
- if post.public?
|
||||
%span.arrow ➔
|
||||
|
|
@ -23,15 +23,15 @@
|
|||
%span.aspect_badge.public
|
||||
= t('the_world')
|
||||
|
||||
- elsif person.owner_id == current_user.id
|
||||
- elsif post.person.owner_id == current_user.id
|
||||
%span.arrow ➔
|
||||
%span.aspect_badges
|
||||
= aspect_badges(aspects_with_post(all_aspects, post))
|
||||
|
||||
= render 'status_messages/status_message', :post => post, :photos => photos
|
||||
= render 'status_messages/status_message', :post => post, :photos => post.photos
|
||||
|
||||
.info
|
||||
%span.timeago= link_to(how_long_ago(post), status_message_path(post))
|
||||
= link_to t('comments.new_comment.comment').downcase, '#', :class => 'focus_comment_textarea'
|
||||
|
||||
= render "comments/comments", :post_id => post.id, :comment_hashes => comments, :condensed => true, :commenting_disabled => defined?(@commenting_disabled)
|
||||
= render "comments/comments", :post_id => post.id, :comments => post.comments, :condensed => true, :commenting_disabled => defined?(@commenting_disabled)
|
||||
|
|
|
|||
|
|
@ -29,4 +29,4 @@
|
|||
|
||||
#status_message_stream.stream.show
|
||||
%div{:data=>{:guid=>@status_message.id}}
|
||||
= render "comments/comments", :post_id => @status_message.id, :comment_hashes => @comment_hashes, :always_expanded => true
|
||||
= render "comments/comments", :post_id => @status_message.id, :comments => @status_message.comments, :always_expanded => true
|
||||
|
|
|
|||
|
|
@ -203,70 +203,6 @@ describe AspectsController do
|
|||
end
|
||||
end
|
||||
|
||||
describe "#hashes_for_contacts" do
|
||||
before do
|
||||
@people = []
|
||||
10.times {@people << Factory.create(:person)}
|
||||
@people.each{|p| @user.reload.activate_contact(p, @user.aspects.first.reload)}
|
||||
@hashes = @controller.send(:hashes_for_contacts,@user.reload.contacts)
|
||||
@hash = @hashes.first
|
||||
end
|
||||
it 'has as many hashes as contacts' do
|
||||
@hashes.length.should == @user.contacts.length
|
||||
end
|
||||
it 'has a contact' do
|
||||
@hash[:contact].should == @user.contacts.first
|
||||
end
|
||||
it 'has a person' do
|
||||
@hash[:person].should == @user.contacts.first.person
|
||||
end
|
||||
it "does not select the person's rsa key" do
|
||||
pending "Don't select RSA keys for views"
|
||||
@hash[:person].serialized_public_key.should be_nil
|
||||
end
|
||||
end
|
||||
describe "#hashes_for_aspects" do
|
||||
before do
|
||||
@aspect1 = @user.aspects.create(:name => "SecondAspect")
|
||||
@people = []
|
||||
10.times {@people << Factory.create(:person)}
|
||||
|
||||
@people.each do |p|
|
||||
@user.reload.activate_contact(p, @user.aspects.first.reload)
|
||||
@user.add_contact_to_aspect(@user.contact_for(p), @aspect1)
|
||||
end
|
||||
@user.reload
|
||||
@hashes = @controller.send(:hashes_for_aspects, @user.aspects, @user.contacts, :limit => 9)
|
||||
@hash = @hashes.first
|
||||
@aspect0 = @user.aspects.first
|
||||
end
|
||||
it 'has aspects' do
|
||||
@hashes.length.should == @user.aspects.count
|
||||
@hash[:aspect].should == @aspect0
|
||||
end
|
||||
it 'has a contact_count' do
|
||||
@hash[:contact_count].should == @aspect0.contacts.count
|
||||
end
|
||||
it 'takes a limit on contacts returned' do
|
||||
@hash[:contacts].count.should == 9
|
||||
end
|
||||
it 'has a person in each hash' do
|
||||
@aspect0.contacts.map{|c| c.person}.include?(@hash[:contacts].first[:person]).should be_true
|
||||
end
|
||||
it "does not return the rsa key" do
|
||||
pending "Don't select RSA keys for views"
|
||||
@hash[:contacts].first[:person].serialized_public_key.should be_nil
|
||||
end
|
||||
it 'has a contact in each hash' do
|
||||
@aspect0.contacts.include?(@hash[:contacts].first[:contact]).should be_true
|
||||
end
|
||||
it 'does not retreive duplicate contacts' do
|
||||
@hashes = @controller.send(:hashes_for_aspects, @user.aspects, @user.contacts)
|
||||
@hash = @hashes.first
|
||||
flattened = @hash[:contacts].map{|c| c[:person].id}
|
||||
flattened.uniq.should == flattened
|
||||
end
|
||||
end
|
||||
|
||||
describe "#update" do
|
||||
before do
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ describe Diaspora::Parser do
|
|||
@aspect.reload
|
||||
new_contact = @user.contact_for(@user2.person)
|
||||
@aspect.contacts.include?(new_contact).should be true
|
||||
@user.contacts.include?(new_contact).should be true
|
||||
@user.contacts.reload.include?(new_contact).should be true
|
||||
end
|
||||
|
||||
it 'should process retraction for a person' do
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ describe 'making sure the spec runner works' do
|
|||
it 'connects the first user to the second' do
|
||||
contact = @user1.contact_for @user2.person
|
||||
contact.should_not be_nil
|
||||
@user1.contacts.include?(contact).should be_true
|
||||
@user1.contacts.reload.include?(contact).should be_true
|
||||
@aspect1.contacts.include?(contact).should be_true
|
||||
contact.aspects.include?(@aspect1).should be_true
|
||||
end
|
||||
|
|
@ -43,7 +43,7 @@ describe 'making sure the spec runner works' do
|
|||
it 'connects the second user to the first' do
|
||||
contact = @user2.contact_for @user1.person
|
||||
contact.should_not be_nil
|
||||
@user2.contacts.include?(contact).should be_true
|
||||
@user2.contacts.reload.include?(contact).should be_true
|
||||
@aspect2.contacts.include?(contact).should be_true
|
||||
contact.aspects.include?(@aspect2).should be_true
|
||||
end
|
||||
|
|
|
|||
|
|
@ -71,28 +71,6 @@ describe Request do
|
|||
end
|
||||
end
|
||||
|
||||
describe '.hashes_for_person' do
|
||||
before do
|
||||
@user = Factory.create(:user)
|
||||
@user2 = Factory.create(:user)
|
||||
@user2.send_contact_request_to @user.person, @user2.aspects.create(:name => "hi")
|
||||
@user.reload
|
||||
@user2.reload
|
||||
@hashes = Request.hashes_for_person(@user.person)
|
||||
@hash = @hashes.first
|
||||
end
|
||||
it 'gives back requests' do
|
||||
@hash[:request].should == Request.where(:sender_id => @user2.person.id, :recipient_id => @user.person.id).first
|
||||
end
|
||||
it 'gives back people' do
|
||||
@hash[:sender].should == @user2.person
|
||||
end
|
||||
it 'does not retrieve keys' do
|
||||
pending "don't retrieve keys"
|
||||
@hash[:sender].serialized_public_key.should be_nil
|
||||
end
|
||||
end
|
||||
|
||||
describe 'xml' do
|
||||
before do
|
||||
@request = Request.new(:sender => @user.person, :recipient => @user2.person, :aspect => @aspect)
|
||||
|
|
|
|||
Loading…
Reference in a new issue