diff --git a/app/controllers/blocks_controller.rb b/app/controllers/blocks_controller.rb index 7eda12fd7411106f34954319dfdf83e402532282..fe3ced956fe89d7414634f1c9d6e9b09cbaf9713 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 c908eba60daac5999e1e3c1d6f13cf5feeab314c..4ccdbe79177ab140bacac325498c413fd26c8372 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 1e55edeab1980eba746fd375b5852972cb5d7bdc..db6e7468a4737ed37a5c1178a703db3c3aa02d25 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 683ea427071b5082c7421726d4106b3ecc1d6f02..1a70cbc6c8b76d28ba8d949cc8828184f727a384 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 2b18216d4cb0d3c70020ea0979e9b677e5db5f85..e63b623cc3cec75215f22dcd4bb1937ef517c014 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 27b64b8cf7ac22db103f0c49a6771be1221536fb..c3e8df57b08df5961c801ccda5b81060a04fca1d 100644 --- a/lib/stream/base.rb +++ b/lib/stream/base.rb @@ -52,8 +52,9 @@ class Stream::Base # @return [ActiveRecord::Association<Person>] 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 5250321839f97ccf7988c1b7bbf3972d4d2abcf5..9020c1548b12045842ca9f94f9f76bfd1dc349ee 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 d9f538292eab7e956bbfc2081ae02caacd4d1274..6fcd5004be97407303ba9bd5ec62ede91cdc6d37 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