From 7223d2172117a98ee6e8dc5725a789d907ceaa50 Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 27 Aug 2010 12:27:16 -0700 Subject: [PATCH] Add singular move friend route, it must be eliminated later --- app/controllers/groups_controller.rb | 11 ++++++++++- app/views/people/show.html.haml | 2 +- config/routes.rb | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index 3bd27c72b..145db190c 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -65,5 +65,14 @@ class GroupsController < ApplicationController redirect_to Group.first, :action => "edit" end - + def move_friend + unless current_user.move_friend( :friend_id => params[:friend_id], :from => params[:from], :to => params[:to][:to]) + 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 diff --git a/app/views/people/show.html.haml b/app/views/people/show.html.haml index eab323e83..0fc753524 100644 --- a/app/views/people/show.html.haml +++ b/app/views/people/show.html.haml @@ -17,7 +17,7 @@ %li %i= "friends since: #{how_long_ago(@person)}" %li - = form_tag move_friends_path + = form_tag move_friend_path = select :to, :to, @groups_dropdown_array, :selected_value => @groups_with_person.first.id = hidden_field_tag :from, :from, :value => @groups_with_person.first.id = hidden_field_tag :friend_id, :friend_id, :value => @person.id diff --git a/config/routes.rb b/config/routes.rb index 663dc9785..11904a654 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -21,6 +21,7 @@ Diaspora::Application.routes.draw do match 'logout', :to => 'devise/sessions#destroy', :as => "destroy_user_session" match 'get_to_the_choppa', :to => 'devise/registrations#new', :as => "new_user_registration" match 'groups/move_friends', :to => 'groups#move_friends', :as => 'move_friends' + match 'groups/move_friend', :to => 'groups#move_friend', :as => 'move_friend' #public routes # match 'webfinger', :to => 'publics#webfinger'