Stream#posts no longer needs to call for_a_stream
exclude blocked users from all streams
This commit is contained in:
parent
0eb33b371b
commit
5b8365118d
19 changed files with 44 additions and 31 deletions
|
|
@ -1,7 +1,20 @@
|
||||||
module StreamElementHelper
|
module StreamElementHelper
|
||||||
def block_user_control(author)
|
def block_user_control(author)
|
||||||
if user_signed_in?
|
if user_signed_in?
|
||||||
button_to "block a mofo", blocks_path(:block => {:person_id => author.id}), :class => "block_button"
|
link_to image_tag('deletelabel.png'), blocks_path(:block => {:person_id => author.id}),
|
||||||
|
:class => 'block_button stream_element_delete',
|
||||||
|
:confirm => t('are_you_sure'),
|
||||||
|
:title => 'block user',
|
||||||
|
:method => :post
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def delete_or_hide_button(post)
|
||||||
|
if user_signed_in? && current_user.owns?(post)
|
||||||
|
link_to image_tag('deletelabel.png'), post_path(post), :confirm => t('are_you_sure'), :method => :delete, :remote => true, :class => "delete stream_element_delete", :title => t('delete')
|
||||||
|
else
|
||||||
|
link_to image_tag('deletelabel.png'), share_visibility_path(:id => "42", :post_id => post.id), :method => :put, :remote => true, :class => "delete stream_element_delete vis_hide", :title => t('.hide_and_mute')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -37,8 +37,7 @@ class StatusMessage < Post
|
||||||
|
|
||||||
def self.tag_stream(user, tag_array, max_time, order)
|
def self.tag_stream(user, tag_array, max_time, order)
|
||||||
owned_or_visible_by_user(user).
|
owned_or_visible_by_user(user).
|
||||||
joins(:tags).where(:tags => {:name => tag_array}).
|
joins(:tags).where(:tags => {:name => tag_array})
|
||||||
for_a_stream(max_time, order)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def text(opts = {})
|
def text(opts = {})
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@
|
||||||
#gs-shim{:title => "3. #{t('.stay_updated')}", 'data-content' => t('.stay_updated_explanation')}
|
#gs-shim{:title => "3. #{t('.stay_updated')}", 'data-content' => t('.stay_updated_explanation')}
|
||||||
|
|
||||||
#main_stream.stream{:data => {:guids => stream.aspect_ids.join(','), :time_for_scroll => time_for_scroll(stream.ajax_stream?, stream)}}
|
#main_stream.stream{:data => {:guids => stream.aspect_ids.join(','), :time_for_scroll => time_for_scroll(stream.ajax_stream?, stream)}}
|
||||||
- if !stream.ajax_stream? && stream.posts.length > 0
|
- if !stream.ajax_stream? && stream.stream_posts.length > 0
|
||||||
= render 'shared/stream', :posts => stream.posts
|
= render 'shared/stream', :posts => stream.stream_posts
|
||||||
#pagination
|
#pagination
|
||||||
=link_to(t('more'), next_page_path(:ajax_stream => stream.ajax_stream?), :class => 'paginate')
|
=link_to(t('more'), next_page_path(:ajax_stream => stream.ajax_stream?), :class => 'paginate')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,8 @@
|
||||||
= @stream.aspect
|
= @stream.aspect
|
||||||
|
|
||||||
#main_stream.stream
|
#main_stream.stream
|
||||||
= render 'shared/stream', :posts => @stream.posts
|
= render 'shared/stream', :posts => @stream.stream_posts
|
||||||
-if @stream.posts.length > 0
|
-if @stream.stream_posts.length > 0
|
||||||
#pagination
|
#pagination
|
||||||
%a.more-link.paginate{:href => next_page_path}
|
%a.more-link.paginate{:href => next_page_path}
|
||||||
%h1
|
%h1
|
||||||
|
|
|
||||||
|
|
@ -27,12 +27,12 @@
|
||||||
= render 'people/sub_header', :person => @person, :contact => @contact
|
= render 'people/sub_header', :person => @person, :contact => @contact
|
||||||
|
|
||||||
/ hackity hack until we get a photo stream
|
/ hackity hack until we get a photo stream
|
||||||
- if (@posts && @posts.length > 0) || (defined?(@stream) && @stream.posts.length > 0)
|
- if (@posts && @posts.length > 0) || @stream.stream_posts.length > 0
|
||||||
-if @post_type == :photos
|
-if @post_type == :photos
|
||||||
= render 'photos/index', :photos => @posts
|
= render 'photos/index', :photos => @posts
|
||||||
- else
|
- else
|
||||||
#main_stream.stream
|
#main_stream.stream
|
||||||
= render 'shared/stream', :posts => @stream.posts
|
= render 'shared/stream', :posts => @stream.stream_posts
|
||||||
#pagination
|
#pagination
|
||||||
=link_to(t('more'), next_page_path, :class => 'paginate')
|
=link_to(t('more'), next_page_path, :class => 'paginate')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,12 +20,12 @@
|
||||||
= link_to t('.return_to_aspects'), aspects_manage_path
|
= link_to t('.return_to_aspects'), aspects_manage_path
|
||||||
= t('.to_accept_or_ignore')
|
= t('.to_accept_or_ignore')
|
||||||
|
|
||||||
- if @stream.posts.length > 0
|
- if @stream.stream_posts.length > 0
|
||||||
-if @post_type == :photos
|
-if @post_type == :photos
|
||||||
= render 'photos/index', :photos => @stream.posts
|
= render 'photos/index', :photos => @stream.stream_posts
|
||||||
- else
|
- else
|
||||||
#main_stream.stream
|
#main_stream.stream
|
||||||
= render 'shared/stream', :posts => @stream.posts
|
= render 'shared/stream', :posts => @stream.stream_posts
|
||||||
#pagination
|
#pagination
|
||||||
=link_to(t('more'), next_page_path, :class => 'paginate')
|
=link_to(t('more'), next_page_path, :class => 'paginate')
|
||||||
- else
|
- else
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,7 @@
|
||||||
|
|
||||||
.stream_element{:id => post.guid, :class => from_group(post)}
|
.stream_element{:id => post.guid, :class => from_group(post)}
|
||||||
.right.controls
|
.right.controls
|
||||||
- if current_user && post.author.owner_id == current_user.id
|
= delete_or_hide_button(post)
|
||||||
= link_to image_tag('deletelabel.png'), post_path(post), :confirm => t('are_you_sure'), :method => :delete, :remote => true, :class => "delete stream_element_delete", :title => t('delete')
|
|
||||||
- else
|
|
||||||
= link_to image_tag('deletelabel.png'), share_visibility_path(:id => "42", :post_id => post.id), :method => :put, :remote => true, :class => "delete stream_element_delete vis_hide", :title => t('.hide_and_mute')
|
|
||||||
|
|
||||||
= block_user_control(post.author)
|
= block_user_control(post.author)
|
||||||
|
|
||||||
= image_tag 'ajax-loader.gif', :class => "hide_loader hidden"
|
= image_tag 'ajax-loader.gif', :class => "hide_loader hidden"
|
||||||
|
|
|
||||||
|
|
@ -67,8 +67,8 @@
|
||||||
%hr
|
%hr
|
||||||
|
|
||||||
#main_stream.stream
|
#main_stream.stream
|
||||||
- if @stream.posts.length > 0
|
- if @stream.stream_posts.length > 0
|
||||||
= render 'shared/stream', :posts => @stream.posts
|
= render 'shared/stream', :posts => @stream.stream_posts
|
||||||
#pagination
|
#pagination
|
||||||
=link_to(t('more'), next_page_path, :class => 'paginate')
|
=link_to(t('more'), next_page_path, :class => 'paginate')
|
||||||
- else
|
- else
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@
|
||||||
= @stream.display_tag_name
|
= @stream.display_tag_name
|
||||||
|
|
||||||
#main_stream.stream
|
#main_stream.stream
|
||||||
= render 'shared/stream', :posts => @stream.posts
|
= render 'shared/stream', :posts => @stream.stream_posts
|
||||||
-if @stream.posts.length > 0
|
-if @stream.stream_posts.length > 0
|
||||||
#pagination
|
#pagination
|
||||||
%a.more-link.paginate{:href => next_page_path}
|
%a.more-link.paginate{:href => next_page_path}
|
||||||
%h1
|
%h1
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ class Stream::Aspect < Stream::Base
|
||||||
:type => TYPES_OF_POST_IN_STREAM,
|
:type => TYPES_OF_POST_IN_STREAM,
|
||||||
:order => "#{order} DESC",
|
:order => "#{order} DESC",
|
||||||
:max_time => max_time
|
:max_time => max_time
|
||||||
).for_a_stream(max_time, order, user)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
# @return [ActiveRecord::Association<Person>] AR association of people within stream's given aspects
|
# @return [ActiveRecord::Association<Person>] AR association of people within stream's given aspects
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,11 @@ class Stream::Base
|
||||||
|
|
||||||
# @return [ActiveRecord::Relation<Post>]
|
# @return [ActiveRecord::Relation<Post>]
|
||||||
def posts
|
def posts
|
||||||
[]
|
Post.scoped
|
||||||
|
end
|
||||||
|
|
||||||
|
def stream_posts
|
||||||
|
self.posts.for_a_stream(max_time, order, user)
|
||||||
end
|
end
|
||||||
|
|
||||||
# @return [ActiveRecord::Association<Person>] AR association of people within stream's given aspects
|
# @return [ActiveRecord::Association<Person>] AR association of people within stream's given aspects
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ class Stream::CommunitySpotlight < Stream::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def posts
|
def posts
|
||||||
Post.all_public.where(:author_id => people.map{|x| x.id}).for_a_stream(max_time, order)
|
Post.all_public.where(:author_id => people.map{|x| x.id})
|
||||||
end
|
end
|
||||||
|
|
||||||
def people
|
def people
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ class Stream::Mention < Stream::Base
|
||||||
|
|
||||||
# @return [ActiveRecord::Association<Post>] AR association of posts
|
# @return [ActiveRecord::Association<Post>] AR association of posts
|
||||||
def posts
|
def posts
|
||||||
@posts ||= StatusMessage.where_person_is_mentioned(self.user.person).for_a_stream(max_time, order)
|
@posts ||= StatusMessage.where_person_is_mentioned(self.user.person)
|
||||||
end
|
end
|
||||||
|
|
||||||
def contacts_title
|
def contacts_title
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ class Stream::Multi < Stream::Base
|
||||||
@posts ||= lambda do
|
@posts ||= lambda do
|
||||||
post_ids = aspects_post_ids + followed_tags_post_ids + mentioned_post_ids
|
post_ids = aspects_post_ids + followed_tags_post_ids + mentioned_post_ids
|
||||||
post_ids += community_spotlight_post_ids if include_community_spotlight?
|
post_ids += community_spotlight_post_ids if include_community_spotlight?
|
||||||
Post.where(:id => post_ids).for_a_stream(max_time, order, user)
|
Post.where(:id => post_ids)
|
||||||
end.call
|
end.call
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,9 @@ class Stream::Person < Stream::Base
|
||||||
def posts
|
def posts
|
||||||
@posts ||= lambda do
|
@posts ||= lambda do
|
||||||
if user
|
if user
|
||||||
posts = self.user.posts_from(@person).for_a_stream(max_time, order)
|
posts = self.user.posts_from(@person)
|
||||||
else
|
else
|
||||||
posts = @person.posts.where(:public => true).for_a_stream(max_time, order)
|
posts = @person.posts.where(:public => true)
|
||||||
end
|
end
|
||||||
posts
|
posts
|
||||||
end.call
|
end.call
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ class Stream::Public < Stream::Base
|
||||||
|
|
||||||
# @return [ActiveRecord::Association<Post>] AR association of posts
|
# @return [ActiveRecord::Association<Post>] AR association of posts
|
||||||
def posts
|
def posts
|
||||||
@posts ||= Post.all_public.for_a_stream(max_time, order)
|
@posts ||= Post.all_public
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,6 @@ class Stream::Tag < Stream::Base
|
||||||
else
|
else
|
||||||
posts = posts.all_public
|
posts = posts.all_public
|
||||||
end
|
end
|
||||||
posts.tagged_with(tag_name).for_a_stream(max_time, 'created_at')
|
posts.tagged_with(tag_name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -242,7 +242,7 @@ describe PeopleController do
|
||||||
|
|
||||||
it 'is sorted by created_at desc' do
|
it 'is sorted by created_at desc' do
|
||||||
get :show, :id => @person.id
|
get :show, :id => @person.id
|
||||||
assigns[:stream].posts.should == @public_posts.sort_by{|p| p.created_at}.reverse
|
assigns[:stream].stream_posts.should == @public_posts.sort_by{|p| p.created_at}.reverse
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ describe TagFollowingsController do
|
||||||
before do
|
before do
|
||||||
@tag = ActsAsTaggableOn::Tag.create!(:name => "partytimeexcellent")
|
@tag = ActsAsTaggableOn::Tag.create!(:name => "partytimeexcellent")
|
||||||
sign_in :user, bob
|
sign_in :user, bob
|
||||||
|
bob.followed_tags.create(:name => "testing")
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'index' do
|
describe 'index' do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue