you can now reassign a peson's group
This commit is contained in:
parent
22f63a4c44
commit
b4174c664e
5 changed files with 19 additions and 9 deletions
|
|
@ -50,8 +50,14 @@ class GroupsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def move_person
|
def move_person
|
||||||
current_user.move_friend( :friend_id => params[:person_id], :from => params[:old_group_id], :to => params[:new_group_id])
|
unless current_user.move_friend( :friend_id => params[:friend_id], :from => params[:from], :to => params[:to][:to])
|
||||||
render :nothing => true
|
flash[:error] = "didn't work #{params.inspect}"
|
||||||
|
end
|
||||||
|
if group = Group.first(:id => params[:to][:to])
|
||||||
|
redirect_to group
|
||||||
|
else
|
||||||
|
redirect_to Person.first(:id => params[:friend_id])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,10 @@ class PeopleController < ApplicationController
|
||||||
@profile = @person.profile
|
@profile = @person.profile
|
||||||
@person_groups = current_user.groups_with_person(@person)
|
@person_groups = current_user.groups_with_person(@person)
|
||||||
|
|
||||||
|
|
||||||
|
@groups_array = current_user.groups.collect{|x| [x.to_s, x.id]}
|
||||||
|
|
||||||
|
|
||||||
@posts = Post.where(:person_id => @person.id, :_id.in => current_user.visible_post_ids).paginate :page => params[:page], :order => 'created_at DESC'
|
@posts = Post.where(:person_id => @person.id, :_id.in => current_user.visible_post_ids).paginate :page => params[:page], :order => 'created_at DESC'
|
||||||
|
|
||||||
@latest_status_message = current_user.raw_visible_posts.find_all_by__type_and_person_id("StatusMessage", params[:id]).last
|
@latest_status_message = current_user.raw_visible_posts.find_all_by__type_and_person_id("StatusMessage", params[:id]).last
|
||||||
|
|
|
||||||
|
|
@ -51,10 +51,8 @@ class User
|
||||||
puts posts_to_move.inspect
|
puts posts_to_move.inspect
|
||||||
to_group.people << friend
|
to_group.people << friend
|
||||||
to_group.posts << posts_to_move
|
to_group.posts << posts_to_move
|
||||||
puts to_group.inspect
|
|
||||||
from_group.person_ids.delete(ensure_bson(friend.id))
|
from_group.person_ids.delete(ensure_bson(friend.id))
|
||||||
posts_to_move.each{ |x| from_group.post_ids.delete(x.id)}
|
posts_to_move.each{ |x| from_group.post_ids.delete(x.id)}
|
||||||
puts from_group.inspect
|
|
||||||
from_group.save
|
from_group.save
|
||||||
to_group.save
|
to_group.save
|
||||||
return true
|
return true
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,12 @@
|
||||||
%li
|
%li
|
||||||
="groups: #{@person_groups}"
|
="groups: #{@person_groups}"
|
||||||
= "edit"
|
= "edit"
|
||||||
= form_for Request.new do |f|
|
= @groups_array.inspect
|
||||||
= f.select(:group_id, @groups_array)
|
= form_tag move_person_path
|
||||||
= f.hidden_field :destination_url, :value => person.email
|
= select :to, :to, @groups_array
|
||||||
= f.submit "add friend"
|
= hidden_field_tag :from, :from, :value => @person_groups.first.id
|
||||||
|
= hidden_field_tag :friend_id, :friend_id, :value => @person.id
|
||||||
|
= submit_tag "save"
|
||||||
%li
|
%li
|
||||||
url:
|
url:
|
||||||
= @person.url
|
= @person.url
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ Diaspora::Application.routes.draw do
|
||||||
match 'login', :to => 'devise/sessions#new', :as => "new_user_session"
|
match 'login', :to => 'devise/sessions#new', :as => "new_user_session"
|
||||||
match 'logout', :to => 'devise/sessions#destroy', :as => "destroy_user_session"
|
match 'logout', :to => 'devise/sessions#destroy', :as => "destroy_user_session"
|
||||||
match 'get_to_the_choppa', :to => 'devise/registrations#new', :as => "new_user_registration"
|
match 'get_to_the_choppa', :to => 'devise/registrations#new', :as => "new_user_registration"
|
||||||
|
match 'groups/move_person', :to => 'groups#move_person', :as => 'move_person'
|
||||||
#public routes
|
#public routes
|
||||||
#
|
#
|
||||||
match 'webfinger', :to => 'publics#webfinger'
|
match 'webfinger', :to => 'publics#webfinger'
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue