DH DG; made privacy page; can now unblock a user; users are actually being blockocked in ajaxed streams
This commit is contained in:
parent
5b8365118d
commit
ae7944418c
18 changed files with 116 additions and 52 deletions
|
|
@ -154,7 +154,7 @@ class ApplicationController < ActionController::Base
|
|||
@stream = stream_klass.new(current_user, :max_time => max_time, :order => sort_order)
|
||||
|
||||
if params[:only_posts]
|
||||
render :partial => 'shared/stream', :locals => {:posts => @stream.posts}
|
||||
render :partial => 'shared/stream', :locals => {:posts => @stream.stream_posts}
|
||||
else
|
||||
render 'aspects/index'
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,7 +3,11 @@ class BlocksController < ApplicationController
|
|||
|
||||
def create
|
||||
current_user.blocks.create(params[:block])
|
||||
|
||||
redirect_to :back, :notice => "that person sucked anyways..."
|
||||
end
|
||||
|
||||
def destroy
|
||||
current_user.blocks.find(params[:id]).delete
|
||||
redirect_to :back, :notice => "MAKE UP YOUR MIND."
|
||||
end
|
||||
end
|
||||
|
|
@ -20,6 +20,10 @@ class UsersController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def privacy_settings
|
||||
@blocks = current_user.blocks.includes(:person)
|
||||
end
|
||||
|
||||
def update
|
||||
password_changed = false
|
||||
@user = current_user
|
||||
|
|
|
|||
|
|
@ -2,19 +2,18 @@ module StreamElementHelper
|
|||
def block_user_control(author)
|
||||
if user_signed_in?
|
||||
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'),
|
||||
: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')
|
||||
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
|
||||
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
|
||||
|
|
@ -28,15 +28,14 @@ module StreamHelper
|
|||
end
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
def time_for_sort post
|
||||
def time_for_sort(post)
|
||||
if controller.instance_of?(AspectsController)
|
||||
post.send(session[:sort_order].to_sym)
|
||||
else
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
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?
|
||||
where("posts.author_id NOT IN (?)", people)
|
||||
where("posts.author_id NOT IN (?)", people.map { |person| person.id })
|
||||
else
|
||||
scoped
|
||||
end
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@
|
|||
#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)}}
|
||||
- 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
|
||||
#pagination
|
||||
#pagination
|
||||
=link_to(t('more'), next_page_path(:ajax_stream => stream.ajax_stream?), :class => 'paginate')
|
||||
|
||||
- if current_user.contacts.size < 2
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
%ul#settings_nav
|
||||
%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('privacy'), privacy_settings_path
|
||||
%li= link_to_unless_current t('_services'), services_path
|
||||
%li= link_to_unless_current t('_applications'), authorizations_path
|
||||
|
|
|
|||
23
app/views/users/privacy_settings.html.haml
Normal file
23
app/views/users/privacy_settings.html.haml
Normal 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
|
||||
|
||||
|
|
@ -9,6 +9,7 @@ en:
|
|||
settings: "Settings"
|
||||
profile: "Profile"
|
||||
account: "Account"
|
||||
privacy: "Privacy"
|
||||
_services: "Services"
|
||||
_applications: "Applications"
|
||||
_photos: "photos"
|
||||
|
|
@ -605,7 +606,7 @@ en:
|
|||
permalink: "permalink"
|
||||
not_found: "Sorry, we couldn't find that post."
|
||||
|
||||
post_visibilites:
|
||||
share_visibilites:
|
||||
update:
|
||||
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."
|
||||
|
|
@ -891,6 +892,7 @@ en:
|
|||
simply_visit: "Simply visit"
|
||||
on_your_mobile_device: "on your mobile device to access Diaspora* mobile."
|
||||
works_on_modern: "Works on all modern smartphones"
|
||||
|
||||
edit:
|
||||
export_data: "Export Data"
|
||||
photo_export_unavailable: "Photo exporting currently unavailable"
|
||||
|
|
@ -919,6 +921,12 @@ en:
|
|||
show_community_spotlight: "Show Community Spotlight in Stream?"
|
||||
show_getting_started: 'Re-enable Getting Started'
|
||||
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."
|
||||
getting_started:
|
||||
well_hello_there: "Well, hello there!"
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ Diaspora::Application.routes.draw do
|
|||
controller :users do
|
||||
get 'public/:username' => :public, :as => 'users_public'
|
||||
match 'getting_started' => :getting_started, :as => 'getting_started'
|
||||
match 'privacy' => :privacy_settings, :as => 'privacy_settings'
|
||||
get 'getting_started_completed' => :getting_started_completed
|
||||
get 'confirm_email/:token' => :confirm_email, :as => 'confirm_email'
|
||||
end
|
||||
|
|
@ -111,7 +112,7 @@ Diaspora::Application.routes.draw do
|
|||
end
|
||||
resources :aspect_memberships, :only => [:destroy, :create, :update]
|
||||
resources :share_visibilities, :only => [:update]
|
||||
resources :blocks, :only => :create
|
||||
resources :blocks, :only => [:create, :destroy]
|
||||
|
||||
get 'spotlight' => 'community_spotlight#index', :as => 'spotlight'
|
||||
|
||||
|
|
|
|||
|
|
@ -252,6 +252,7 @@ ActiveRecord::Schema.define(:version => 20111101202137) do
|
|||
add_index "people", ["owner_id"], :name => "index_people_on_owner_id", :unique => true
|
||||
|
||||
create_table "photos", :force => true do |t|
|
||||
t.integer "tmp_old_id"
|
||||
t.integer "author_id", :null => false
|
||||
t.boolean "public", :default => false, :null => false
|
||||
t.string "diaspora_handle"
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ class Stream::Base
|
|||
end
|
||||
|
||||
def stream_posts
|
||||
self.posts.for_a_stream(max_time, order, user)
|
||||
self.posts.for_a_stream(max_time, order, self.user)
|
||||
end
|
||||
|
||||
# @return [ActiveRecord::Association<Person>] AR association of people within stream's given aspects
|
||||
|
|
|
|||
|
|
@ -13,7 +13,8 @@
|
|||
timeAgo: self.instantiate("TimeAgo", element.find(".timeago a abbr.timeago")),
|
||||
|
||||
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"),
|
||||
hidePostLoader: element.find("img.hide_loader"),
|
||||
hidePostUndo: element.find("a.stream_element_hide_undo"),
|
||||
|
|
@ -22,8 +23,11 @@
|
|||
});
|
||||
|
||||
// twipsy tooltips
|
||||
self.deletePostLink.twipsy();
|
||||
self.postScope.twipsy();
|
||||
$([
|
||||
self.blockUserLink,
|
||||
self.deletePostLink,
|
||||
self.postScope
|
||||
]).map(function() { this.twipsy(); });
|
||||
|
||||
// collapse long posts
|
||||
self.content.expander({
|
||||
|
|
@ -40,8 +44,10 @@
|
|||
self.deletePostLink.click(function(evt) {
|
||||
evt.preventDefault();
|
||||
|
||||
self.deletePostLink.toggleClass("hidden");
|
||||
self.hidePostLoader.toggleClass("hidden");
|
||||
$([
|
||||
self.deletePostLink,
|
||||
self.hidePostLoader
|
||||
]).toggleClass("hidden");
|
||||
});
|
||||
|
||||
self.focusCommentLink.click(function(evt) {
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe BlocksController do
|
||||
describe "#create" do
|
||||
before do
|
||||
sign_in alice
|
||||
end
|
||||
|
||||
it "should create a block" do
|
||||
describe "#create" do
|
||||
it "creates a block" do
|
||||
expect {
|
||||
post :create, :block => { :person_id => 2 }
|
||||
}.should change { alice.blocks.count }.by(1)
|
||||
end
|
||||
|
||||
it "should redirect to back" do
|
||||
it "redirects back" do
|
||||
post :create, :block => { :person_id => 2 }
|
||||
|
||||
response.should be_redirect
|
||||
|
|
@ -24,4 +24,21 @@ describe BlocksController do
|
|||
flash.should_not be_empty
|
||||
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
|
||||
|
|
@ -159,6 +159,13 @@ describe UsersController do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#privacy_settings' do
|
||||
it "returns a 200" do
|
||||
get 'privacy_settings'
|
||||
response.status.should == 200
|
||||
end
|
||||
end
|
||||
|
||||
describe '#edit' do
|
||||
it "returns a 200" do
|
||||
get 'edit', :id => @user.id
|
||||
|
|
@ -222,13 +229,11 @@ describe UsersController do
|
|||
it 'does not fail miserably' do
|
||||
get :getting_started
|
||||
response.should be_success
|
||||
|
||||
end
|
||||
|
||||
it 'does not fail miserably on mobile' do
|
||||
get :getting_started, :format => :mobile
|
||||
response.should be_success
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -382,9 +382,7 @@ describe User do
|
|||
end
|
||||
end
|
||||
|
||||
describe '.find_or_create_by_invitation' do
|
||||
|
||||
end
|
||||
describe '.find_or_create_by_invitation'
|
||||
|
||||
describe '.create_from_invitation!' do
|
||||
before do
|
||||
|
|
@ -400,7 +398,6 @@ describe User do
|
|||
it 'sets the email if the service is email' do
|
||||
@user.email.should == @inv.identifier
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe 'update_user_preferences' do
|
||||
|
|
@ -551,7 +548,6 @@ describe User do
|
|||
alice.remove_all_traces
|
||||
end
|
||||
|
||||
|
||||
it 'should remove mentions' do
|
||||
alice.should_receive(:remove_mentions)
|
||||
alice.remove_all_traces
|
||||
|
|
|
|||
Loading…
Reference in a new issue