Merge pull request #6617 from manuelVo/ignored-user-show-posts-on-profile

Show posts of ignored users on their profile page
This commit is contained in:
Dennis Schubert 2016-01-06 10:47:55 +01:00
commit 439ea693a0
8 changed files with 20 additions and 14 deletions

View file

@ -85,6 +85,7 @@ With the port to Bootstrap 3, app/views/terms/default.haml has a new structure.
* Redesign and refactor report admin interface [#6378](https://github.com/diaspora/diaspora/pull/6378) * Redesign and refactor report admin interface [#6378](https://github.com/diaspora/diaspora/pull/6378)
* Add permalink icon to stream elements [#6457](https://github.com/diaspora/diaspora/pull/6457) * Add permalink icon to stream elements [#6457](https://github.com/diaspora/diaspora/pull/6457)
* Move reshare count to interactions for stream elements [#6487](https://github.com/diaspora/diaspora/pull/6487) * Move reshare count to interactions for stream elements [#6487](https://github.com/diaspora/diaspora/pull/6487)
* Posts of ignored users are now visible on that profile page [#6617](https://github.com/diaspora/diaspora/pull/6617)
# 0.5.6.0 # 0.5.6.0

View file

@ -75,13 +75,6 @@ app.pages.Profile = app.views.Base.extend({
if(!this.model.has("profile")){ if(!this.model.has("profile")){
return false; return false;
} }
if( this.model.isBlocked() ) {
$("#main_stream").empty().html(
'<div class="dull">'+
Diaspora.I18n.t("profile.ignoring", {name: this.model.get("name")}) +
"</div>");
return false;
}
// a collection is set, this means we want to view photos // a collection is set, this means we want to view photos
var route = this.streamCollection ? "personPhotos" : "personStream"; var route = this.streamCollection ? "personPhotos" : "personStream";

View file

@ -103,11 +103,17 @@ class Post < ActiveRecord::Base
excluding_blocks(user).excluding_hidden_shareables(user) excluding_blocks(user).excluding_hidden_shareables(user)
end end
def self.for_a_stream(max_time, order, user=nil) def self.for_a_stream(max_time, order, user=nil, ignore_blocks=false)
scope = self.for_visible_shareable_sql(max_time, order). scope = self.for_visible_shareable_sql(max_time, order).
includes_for_a_stream includes_for_a_stream
scope = scope.excluding_hidden_content(user) if user.present? if user.present?
if ignore_blocks
scope = scope.excluding_hidden_shareables(user)
else
scope = scope.excluding_hidden_content(user)
end
end
scope scope
end end

View file

@ -27,7 +27,5 @@
- else - else
#main_stream #main_stream
.dull .dull
- if @block.present? - if user_signed_in? && (current_user.person != @person)
= t(".ignoring", name: @person.first_name)
- elsif user_signed_in? && (current_user.person != @person)
= t(".has_not_shared_with_you_yet", name: @person.first_name) = t(".has_not_shared_with_you_yet", name: @person.first_name)

View file

@ -911,7 +911,6 @@ en:
start_sharing: "Start sharing" start_sharing: "Start sharing"
message: "Message" message: "Message"
mention: "Mention" mention: "Mention"
ignoring: "You are ignoring all posts from %{name}."
closed_account: "This account has been closed." closed_account: "This account has been closed."
sub_header: sub_header:
you_have_no_tags: "You have no tags!" you_have_no_tags: "You have no tags!"

View file

@ -194,7 +194,6 @@ en:
edit: "Edit" edit: "Edit"
add_some: "Add some" add_some: "Add some"
you_have_no_tags: "You have no tags!" you_have_no_tags: "You have no tags!"
ignoring: "You are ignoring all posts from <%= name %>."
bio: "Bio" bio: "Bio"
location: "Location" location: "Location"
gender: "Gender" gender: "Gender"

View file

@ -7,6 +7,7 @@ Feature: Blocking a user from the stream
| Alice Smith | alice@alice.alice | | Alice Smith | alice@alice.alice |
And a user with email "bob@bob.bob" is connected with "alice@alice.alice" And a user with email "bob@bob.bob" is connected with "alice@alice.alice"
And Alice has a post mentioning Bob And Alice has a post mentioning Bob
And "alice@alice.alice" has a public post with text "All your base are belong to us!"
And I sign in as "bob@bob.bob" And I sign in as "bob@bob.bob"
Scenario: Blocking a user Scenario: Blocking a user
@ -19,4 +20,6 @@ Feature: Blocking a user from the stream
When I am on "alice@alice.alice"'s page When I am on "alice@alice.alice"'s page
When I click on the profile block button When I click on the profile block button
And I confirm the alert And I confirm the alert
Then "All your base are belong to us!" should be post 1
When I go to the home page
Then I should not see any posts in my stream Then I should not see any posts in my stream

View file

@ -15,4 +15,11 @@ class Stream::Person < Stream::Base
def posts def posts
@posts ||= user.present? ? user.posts_from(@person) : @person.posts.where(:public => true) @posts ||= user.present? ? user.posts_from(@person) : @person.posts.where(:public => true)
end end
# @return [Array<Post>]
def stream_posts
posts.for_a_stream(max_time, order, user, true).tap do |posts|
like_posts_for_stream!(posts) # some sql person could probably do this with joins.
end
end
end end