diff --git a/app/controllers/blocks_controller.rb b/app/controllers/blocks_controller.rb index 7eda12fd7..fe3ced956 100644 --- a/app/controllers/blocks_controller.rb +++ b/app/controllers/blocks_controller.rb @@ -2,12 +2,22 @@ class BlocksController < ApplicationController before_filter :authenticate_user! def create - current_user.blocks.create(params[:block]) - redirect_to :back, :notice => "that person sucked anyways..." + block = current_user.blocks.new(params[:block]) + + if block.save + notice = {:notice => t('blocks.create.success')} + else + notice = {:error => t('blocks.create.failure')} + end + redirect_to :back, notice end def destroy - current_user.blocks.find(params[:id]).delete - redirect_to :back, :notice => "MAKE UP YOUR MIND." + if current_user.blocks.find(params[:id]).delete + notice = {:notice => t('blocks.destroy.success')} + else + notice = {:error => t('blocks.destroy.failure')} + end + redirect_to :back, notice end end diff --git a/app/helpers/stream_element_helper.rb b/app/helpers/stream_element_helper.rb index c908eba60..4ccdbe791 100644 --- a/app/helpers/stream_element_helper.rb +++ b/app/helpers/stream_element_helper.rb @@ -1,10 +1,10 @@ module StreamElementHelper def block_user_control(author) - if user_signed_in? + if user_signed_in? && current_user.person.id != author.id link_to image_tag('deletelabel.png'), blocks_path(:block => {:person_id => author.id}), :class => 'block_user delete', :confirm => t('are_you_sure'), - :title => 'block user', + :title => t('.block_user', :name => author.first_name), :method => :post end end diff --git a/app/views/shared/_stream_element.html.haml b/app/views/shared/_stream_element.html.haml index 1e55edeab..db6e7468a 100644 --- a/app/views/shared/_stream_element.html.haml +++ b/app/views/shared/_stream_element.html.haml @@ -5,8 +5,8 @@ .stream_element{:id => post.guid, :class => from_group(post)} .right.controls - = delete_or_hide_button(post) = block_user_control(post.author) + = delete_or_hide_button(post) = image_tag 'ajax-loader.gif', :class => "hide_loader hidden" diff --git a/app/views/users/privacy_settings.html.haml b/app/views/users/privacy_settings.html.haml index 683ea4270..1a70cbc6c 100644 --- a/app/views/users/privacy_settings.html.haml +++ b/app/views/users/privacy_settings.html.haml @@ -20,4 +20,5 @@ = link_to t('.unblock'), block_path(block), :confirm => t('are_you_sure'), :method => :delete + %br diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 2b18216d4..e63b623cc 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -723,6 +723,14 @@ en: invite: "invite" not_on_diaspora: "Not yet on Diaspora" + blocks: + create: + success: "Alright, you won't see them again. #niceblock!" + failure: "I couldn't block that user. #evasion" + destroy: + success: "User unblocked! #combobreaker" + failure: "I couldn't unblock that user. #evasion" + shared: aspect_dropdown: add_to_aspect: "Add contact" @@ -768,7 +776,6 @@ en: reshare: reshare: "Reshare" public_explain: - control_your_audience: "Control your Audience" new_user_welcome_message: "Use #hashtags to classify your posts and find people who share your interests. Call out awesome people with @Mentions" visibility_dropdown: "Use this dropdown to change visibility of your post. (We suggest you make this first one public.)" @@ -786,7 +793,8 @@ en: connect_to_comment: "Connect to this user to comment on their post" currently_unavailable: 'commenting currently unavailable' via: "via %{link}" - hide_and_mute: "Hide and Mute" + block_user: "Block %{name}" + hide_and_mute: "Hide and mute post" like: "Like" unlike: "Unlike" dislike: "Dislike" diff --git a/lib/stream/base.rb b/lib/stream/base.rb index 27b64b8cf..c3e8df57b 100644 --- a/lib/stream/base.rb +++ b/lib/stream/base.rb @@ -52,8 +52,9 @@ class Stream::Base # @return [ActiveRecord::Association] AR association of people within stream's given aspects def people - people_ids = posts.map{|x| x.author_id} - Person.where(:id => people_ids).includes(:profile) + people_ids = self.stream_posts.map{|x| x.author_id} + Person.where(:id => people_ids). + includes(:profile) end # @return [String] diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 525032183..9020c1548 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -791,9 +791,6 @@ a.paginate, #infscr-loading :text-align center :width 100% - &:hover - :border 1px solid #1C6D99 - #main_stream :position relative :z-index 0 diff --git a/spec/lib/stream/base_spec.rb b/spec/lib/stream/base_spec.rb index d9f538292..6fcd5004b 100644 --- a/spec/lib/stream/base_spec.rb +++ b/spec/lib/stream/base_spec.rb @@ -43,6 +43,13 @@ describe Stream::Base do end end + describe '#people' do + it 'excludes blocked people' do + @stream.should_receive(:stream_posts).and_return(stub.as_null_object) + @stream.people + end + end + describe 'shared behaviors' do it_should_behave_like 'it is a stream' end