DH DG; made privacy page; can now unblock a user; users are actually being blockocked in ajaxed streams

This commit is contained in:
danielgrippi 2011-11-02 17:57:43 -07:00
parent 5b8365118d
commit ae7944418c
18 changed files with 116 additions and 52 deletions

View file

@ -154,7 +154,7 @@ class ApplicationController < ActionController::Base
@stream = stream_klass.new(current_user, :max_time => max_time, :order => sort_order) @stream = stream_klass.new(current_user, :max_time => max_time, :order => sort_order)
if params[:only_posts] if params[:only_posts]
render :partial => 'shared/stream', :locals => {:posts => @stream.posts} render :partial => 'shared/stream', :locals => {:posts => @stream.stream_posts}
else else
render 'aspects/index' render 'aspects/index'
end end

View file

@ -3,7 +3,11 @@ class BlocksController < ApplicationController
def create def create
current_user.blocks.create(params[:block]) current_user.blocks.create(params[:block])
redirect_to :back, :notice => "that person sucked anyways..." redirect_to :back, :notice => "that person sucked anyways..."
end end
def destroy
current_user.blocks.find(params[:id]).delete
redirect_to :back, :notice => "MAKE UP YOUR MIND."
end
end end

View file

@ -20,6 +20,10 @@ class UsersController < ApplicationController
end end
end end
def privacy_settings
@blocks = current_user.blocks.includes(:person)
end
def update def update
password_changed = false password_changed = false
@user = current_user @user = current_user

View file

@ -2,19 +2,18 @@ module StreamElementHelper
def block_user_control(author) def block_user_control(author)
if user_signed_in? if user_signed_in?
link_to image_tag('deletelabel.png'), blocks_path(:block => {:person_id => author.id}), link_to image_tag('deletelabel.png'), blocks_path(:block => {:person_id => author.id}),
:class => 'block_button stream_element_delete', :class => 'block_user delete',
:confirm => t('are_you_sure'), :confirm => t('are_you_sure'),
:title => 'block user', :title => 'block user',
:method => :post :method => :post
end end
end end
def delete_or_hide_button(post) def delete_or_hide_button(post)
if user_signed_in? && current_user.owns?(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') link_to image_tag('deletelabel.png'), post_path(post), :confirm => t('are_you_sure'), :method => :delete, :remote => true, :class => "delete remove_post", :title => t('delete')
else 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') link_to image_tag('deletelabel.png'), share_visibility_path(:id => "42", :post_id => post.id), :method => :put, :remote => true, :class => "delete remove_post vis_hide", :title => t('.hide_and_mute')
end end
end end
end end

View file

@ -28,15 +28,14 @@ module StreamHelper
end end
def time_for_scroll(ajax_stream, stream) def time_for_scroll(ajax_stream, stream)
if ajax_stream || stream.posts.empty? if ajax_stream || stream.stream_posts.empty?
(Time.now() + 1).to_i (Time.now() + 1).to_i
else else
stream.posts.last.send(stream.order.to_sym).to_i stream.stream_posts.last.send(stream.order.to_sym).to_i
end
end end
end def time_for_sort(post)
def time_for_sort post
if controller.instance_of?(AspectsController) if controller.instance_of?(AspectsController)
post.send(session[:sort_order].to_sym) post.send(session[:sort_order].to_sym)
else else

View file

@ -24,10 +24,10 @@ class Post < ActiveRecord::Base
scope :includes_for_a_stream, includes(:o_embed_cache, {:author => :profile}, :mentions => {:person => :profile}) #note should include root and photos, but i think those are both on status_message scope :includes_for_a_stream, includes(:o_embed_cache, {:author => :profile}, :mentions => {:person => :profile}) #note should include root and photos, but i think those are both on status_message
def self.excluding_blocks(user) def self.excluding_blocks(user)
people = user.blocks.map { |x| x.person_id } people = user.blocks.includes(:person).map{|b| b.person}
if people.present? if people.present?
where("posts.author_id NOT IN (?)", people) where("posts.author_id NOT IN (?)", people.map { |person| person.id })
else else
scoped scoped
end end

View file

@ -19,9 +19,9 @@
#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.stream_posts.length > 0 - if !stream.ajax_stream? && stream.stream_posts.length > 0
= render 'shared/stream', :posts => stream.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')
- if current_user.contacts.size < 2 - if current_user.contacts.size < 2

View file

@ -1,5 +1,6 @@
%ul#settings_nav %ul#settings_nav
%li= link_to_unless_current t('profile'), edit_profile_path %li= link_to_unless_current t('profile'), edit_profile_path
%li= link_to_unless_current t('account'), edit_user_path %li= link_to_unless_current t('account'), edit_user_path
%li= link_to_unless_current t('privacy'), privacy_settings_path
%li= link_to_unless_current t('_services'), services_path %li= link_to_unless_current t('_services'), services_path
%li= link_to_unless_current t('_applications'), authorizations_path %li= link_to_unless_current t('_applications'), authorizations_path

View file

@ -0,0 +1,23 @@
-# Copyright (c) 2010-2011, Diaspora Inc. This file is
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
- content_for :page_title do
= t('.title')
#section_header
%h2
= t('privacy')
= render 'shared/settings_nav'
.span-12.prepend-5.last
%h3
= t('.blocked_users')
- @blocks.each do |block|
= block.person.name
\-
= link_to t('.unblock'), block_path(block),
:confirm => t('are_you_sure'),
:method => :delete

View file

@ -9,6 +9,7 @@ en:
settings: "Settings" settings: "Settings"
profile: "Profile" profile: "Profile"
account: "Account" account: "Account"
privacy: "Privacy"
_services: "Services" _services: "Services"
_applications: "Applications" _applications: "Applications"
_photos: "photos" _photos: "photos"
@ -605,7 +606,7 @@ en:
permalink: "permalink" permalink: "permalink"
not_found: "Sorry, we couldn't find that post." not_found: "Sorry, we couldn't find that post."
post_visibilites: share_visibilites:
update: update:
post_hidden_and_muted: "%{name}'s post has been hidden, and notifications have been muted." post_hidden_and_muted: "%{name}'s post has been hidden, and notifications have been muted."
see_it_on_their_profile: "If you want to see updates on this post, visit %{name}'s profile page." see_it_on_their_profile: "If you want to see updates on this post, visit %{name}'s profile page."
@ -891,6 +892,7 @@ en:
simply_visit: "Simply visit" simply_visit: "Simply visit"
on_your_mobile_device: "on your mobile device to access Diaspora* mobile." on_your_mobile_device: "on your mobile device to access Diaspora* mobile."
works_on_modern: "Works on all modern smartphones" works_on_modern: "Works on all modern smartphones"
edit: edit:
export_data: "Export Data" export_data: "Export Data"
photo_export_unavailable: "Photo exporting currently unavailable" photo_export_unavailable: "Photo exporting currently unavailable"
@ -919,6 +921,12 @@ en:
show_community_spotlight: "Show Community Spotlight in Stream?" show_community_spotlight: "Show Community Spotlight in Stream?"
show_getting_started: 'Re-enable Getting Started' show_getting_started: 'Re-enable Getting Started'
getting_started: 'New User Prefrences' getting_started: 'New User Prefrences'
privacy_settings:
title: "Privacy Settings"
blocked_users: "Blocked Users"
unblock: "Unblock"
destroy: "Your account has been locked. It may take 20 minutes for us to finish closing your account. Thank you for trying Diaspora." destroy: "Your account has been locked. It may take 20 minutes for us to finish closing your account. Thank you for trying Diaspora."
getting_started: getting_started:
well_hello_there: "Well, hello there!" well_hello_there: "Well, hello there!"

View file

@ -78,6 +78,7 @@ Diaspora::Application.routes.draw do
controller :users do controller :users do
get 'public/:username' => :public, :as => 'users_public' get 'public/:username' => :public, :as => 'users_public'
match 'getting_started' => :getting_started, :as => 'getting_started' match 'getting_started' => :getting_started, :as => 'getting_started'
match 'privacy' => :privacy_settings, :as => 'privacy_settings'
get 'getting_started_completed' => :getting_started_completed get 'getting_started_completed' => :getting_started_completed
get 'confirm_email/:token' => :confirm_email, :as => 'confirm_email' get 'confirm_email/:token' => :confirm_email, :as => 'confirm_email'
end end
@ -111,7 +112,7 @@ Diaspora::Application.routes.draw do
end end
resources :aspect_memberships, :only => [:destroy, :create, :update] resources :aspect_memberships, :only => [:destroy, :create, :update]
resources :share_visibilities, :only => [:update] resources :share_visibilities, :only => [:update]
resources :blocks, :only => :create resources :blocks, :only => [:create, :destroy]
get 'spotlight' => 'community_spotlight#index', :as => 'spotlight' get 'spotlight' => 'community_spotlight#index', :as => 'spotlight'

View file

@ -252,6 +252,7 @@ ActiveRecord::Schema.define(:version => 20111101202137) do
add_index "people", ["owner_id"], :name => "index_people_on_owner_id", :unique => true add_index "people", ["owner_id"], :name => "index_people_on_owner_id", :unique => true
create_table "photos", :force => true do |t| create_table "photos", :force => true do |t|
t.integer "tmp_old_id"
t.integer "author_id", :null => false t.integer "author_id", :null => false
t.boolean "public", :default => false, :null => false t.boolean "public", :default => false, :null => false
t.string "diaspora_handle" t.string "diaspora_handle"

View file

@ -47,7 +47,7 @@ class Stream::Base
end end
def stream_posts def stream_posts
self.posts.for_a_stream(max_time, order, user) self.posts.for_a_stream(max_time, order, self.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

View file

@ -13,7 +13,8 @@
timeAgo: self.instantiate("TimeAgo", element.find(".timeago a abbr.timeago")), timeAgo: self.instantiate("TimeAgo", element.find(".timeago a abbr.timeago")),
content: element.find(".content .collapsible"), content: element.find(".content .collapsible"),
deletePostLink: element.find("a.stream_element_delete"), blockUserLink: element.find(".block_user"),
deletePostLink: element.find(".remove_post"),
focusCommentLink: element.find("a.focus_comment_textarea"), focusCommentLink: element.find("a.focus_comment_textarea"),
hidePostLoader: element.find("img.hide_loader"), hidePostLoader: element.find("img.hide_loader"),
hidePostUndo: element.find("a.stream_element_hide_undo"), hidePostUndo: element.find("a.stream_element_hide_undo"),
@ -22,8 +23,11 @@
}); });
// twipsy tooltips // twipsy tooltips
self.deletePostLink.twipsy(); $([
self.postScope.twipsy(); self.blockUserLink,
self.deletePostLink,
self.postScope
]).map(function() { this.twipsy(); });
// collapse long posts // collapse long posts
self.content.expander({ self.content.expander({
@ -40,8 +44,10 @@
self.deletePostLink.click(function(evt) { self.deletePostLink.click(function(evt) {
evt.preventDefault(); evt.preventDefault();
self.deletePostLink.toggleClass("hidden"); $([
self.hidePostLoader.toggleClass("hidden"); self.deletePostLink,
self.hidePostLoader
]).toggleClass("hidden");
}); });
self.focusCommentLink.click(function(evt) { self.focusCommentLink.click(function(evt) {

View file

@ -1,18 +1,18 @@
require 'spec_helper' require 'spec_helper'
describe BlocksController do describe BlocksController do
describe "#create" do
before do before do
sign_in alice sign_in alice
end end
it "should create a block" do describe "#create" do
it "creates a block" do
expect { expect {
post :create, :block => { :person_id => 2 } post :create, :block => { :person_id => 2 }
}.should change { alice.blocks.count }.by(1) }.should change { alice.blocks.count }.by(1)
end end
it "should redirect to back" do it "redirects back" do
post :create, :block => { :person_id => 2 } post :create, :block => { :person_id => 2 }
response.should be_redirect response.should be_redirect
@ -24,4 +24,21 @@ describe BlocksController do
flash.should_not be_empty flash.should_not be_empty
end end
end end
describe "#destroy" do
before do
@block = alice.blocks.create(:person => eve.person)
end
it "redirects back" do
delete :destroy, :id => @block.id
response.should be_redirect
end
it "removes a block" do
expect {
delete :destroy, :id => @block.id
}.should change { alice.blocks.count }.by(-1)
end
end
end end

View file

@ -159,6 +159,13 @@ describe UsersController do
end end
end end
describe '#privacy_settings' do
it "returns a 200" do
get 'privacy_settings'
response.status.should == 200
end
end
describe '#edit' do describe '#edit' do
it "returns a 200" do it "returns a 200" do
get 'edit', :id => @user.id get 'edit', :id => @user.id
@ -222,13 +229,11 @@ describe UsersController do
it 'does not fail miserably' do it 'does not fail miserably' do
get :getting_started get :getting_started
response.should be_success response.should be_success
end end
it 'does not fail miserably on mobile' do it 'does not fail miserably on mobile' do
get :getting_started, :format => :mobile get :getting_started, :format => :mobile
response.should be_success response.should be_success
end end
end end
end end

View file

@ -382,9 +382,7 @@ describe User do
end end
end end
describe '.find_or_create_by_invitation' do describe '.find_or_create_by_invitation'
end
describe '.create_from_invitation!' do describe '.create_from_invitation!' do
before do before do
@ -400,7 +398,6 @@ describe User do
it 'sets the email if the service is email' do it 'sets the email if the service is email' do
@user.email.should == @inv.identifier @user.email.should == @inv.identifier
end end
end end
describe 'update_user_preferences' do describe 'update_user_preferences' do
@ -551,7 +548,6 @@ describe User do
alice.remove_all_traces alice.remove_all_traces
end end
it 'should remove mentions' do it 'should remove mentions' do
alice.should_receive(:remove_mentions) alice.should_receive(:remove_mentions)
alice.remove_all_traces alice.remove_all_traces