Skip to content
Snippets Groups Projects
Commit 183ac75c authored by danielvincent's avatar danielvincent
Browse files

Merge branch 'master' of github.com:diaspora/diaspora

parents 6d8b6701 6fa82490
No related branches found
No related tags found
No related merge requests found
......@@ -96,12 +96,21 @@ class AspectsController < ApplicationController
if current_user.add_person_to_aspect( params[:friend_id], params[:aspect_id])
flash[:notice] = I18n.t 'aspects.add_to_aspect.success'
else
flash[:notice] = I18n.t 'aspects.add_to_aspect.success'
flash[:error] = I18n.t 'aspects.add_to_aspect.failure'
end
redirect_to aspects_path(params[:aspect_id])
end
def remove_from_aspect
if current_user.delete_person_from_aspect( params[:friend_id], params[:aspect_id])
flash[:notice] = I18n.t 'aspects.remove_from_aspect.success'
else
flash[:error] = I18n.t 'aspects.remove_from_aspect.failure'
end
redirect_to aspects_manage_path
end
private
def clean_hash(params)
return {
......
......@@ -130,7 +130,7 @@ class User
def delete_person_from_aspect(person_id, aspect_id, opts = {})
raise "Can not delete a person from an aspect you do not own" unless aspect = self.aspects.find_by_id(aspect_id)
aspect.person_ids.delete(person_id)
aspect.person_ids.delete(person_id.to_id)
opts[:posts] ||= aspect.posts.all(:person_id => person_id)
aspect.posts -= opts[:posts]
aspect.save
......
......@@ -25,8 +25,13 @@
= person_image_tag(request.person)
.name
= request.person.real_name
%h3=t('.ignore_remove')
%h3 Remove from Aspect
.aspect_remove
%ul.dropzone
%li.grey Drag to remove person from aspect
%h3=t('.ignore_remove')
.remove
%ul.dropzone
%li.grey Drag to ignore/remove
......
......@@ -16,15 +16,16 @@
%b.small= @person.diaspora_handle
%li
%i= t(".last_seen",:how_long_ago => how_long_ago(@posts.first))
- if @person != current_user.person && current_user.friends.include?(@person)
%li
%i= t(".friends_since",:how_long_ago => how_long_ago(@person))
%li
= form_tag move_friend_path
= select :to, :to, @aspects_dropdown_array, :selected => @aspects_with_person.first.id
= hidden_field_tag :from, :from, :value => @aspects_with_person.first.id
= hidden_field_tag :friend_id, :friend_id, :value => @person.id
= submit_tag t('.save')
.person_aspects
%ul
- for aspect in @aspects_with_person
%li= link_to aspect.name, aspect
- if @person != current_user.person && current_user.friends.include?(@person)
= link_to t('.remove_friend'), @person, :confirm => t('.are_you_sure'), :method => :delete, :class => "button"
......
......@@ -22,6 +22,7 @@ Diaspora::Application.routes.draw do
match 'aspects/move_friend', :to => 'aspects#move_friend', :as => 'move_friend'
match 'aspects/add_to_aspect',:to => 'aspects#add_to_aspect', :as => 'add_to_aspect'
match 'aspects/remove_from_aspect',:to => 'aspects#remove_from_aspect', :as => 'remove_from_aspect'
match 'aspects/manage', :to => 'aspects#manage'
match 'aspects/public', :to => 'aspects#public'
resources :aspects, :except => [:edit]
......
......@@ -93,6 +93,27 @@ $(function() {
}
});
$(".aspect_remove ul").droppable({
hoverClass: 'active',
drop: function(event, ui) {
if (!$(ui.draggable[0]).hasClass('requested_person')){
var aspect = ui.draggable[0].getAttribute('from_aspect_id')
var person_id = ui.draggable[0].id
$.ajax({
type: "POST",
url: "/aspects/remove_from_aspect",
data:{
'friend_id' : person_id,
'aspect_id' : aspect
}
});
}
$(ui.draggable[0]).fadeOut('slow'); // ui.draggable.fadeOut('slow')
}
});
$(".aspect h3").live( 'focus', function() {
......
......@@ -872,7 +872,8 @@ h1.big_text
.aspect,
.requests,
.remove
.remove,
.aspect_remove
:list
:style none
......
......@@ -80,5 +80,15 @@ describe AspectsController do
@aspect1.reload
@aspect1.people.include?(@user2.person).should be true
end
end
describe "#remove_from_aspect" do
it 'adds the users to the aspect' do
@aspect.reload
@aspect.people.include?(@user2.person).should be true
post 'remove_from_aspect', {:friend_id => @user2.person.id, :aspect_id => @aspect1.id }
@aspect1.reload
@aspect1.people.include?(@user2.person).should be false
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment