refactor of routes.rb done so far; further refactor needs design decisions
This commit is contained in:
parent
11b0a2c19d
commit
b689d4695b
8 changed files with 31 additions and 37 deletions
|
|
@ -10,7 +10,7 @@ class AspectMembershipsController < ApplicationController
|
|||
#note :id is garbage
|
||||
|
||||
@person_id = params[:person_id]
|
||||
@aspect_id = params[:aspect_id]
|
||||
@aspect_id = params[:id]
|
||||
|
||||
@contact = current_user.contact_for(Person.where(:id => @person_id).first)
|
||||
membership = @contact ? @contact.aspect_memberships.where(:aspect_id => @aspect_id).first : nil
|
||||
|
|
|
|||
|
|
@ -149,15 +149,15 @@ class AspectsController < ApplicationController
|
|||
|
||||
def move_contact
|
||||
@person = Person.find(params[:person_id])
|
||||
@from_aspect = current_user.aspects.where(:id => params[:from]).first
|
||||
@to_aspect = current_user.aspects.where(:id => params[:to][:to]).first
|
||||
@from_aspect = current_user.aspects.where(:id => params[:aspect_id]).first
|
||||
@to_aspect = current_user.aspects.where(:id => params[:to]).first
|
||||
|
||||
response_hash = { }
|
||||
|
||||
unless current_user.move_contact( @person, @to_aspect, @from_aspect)
|
||||
flash[:error] = I18n.t 'aspects.move_contact.error',:inspect => params.inspect
|
||||
end
|
||||
if aspect = current_user.aspects.where(:id => params[:to][:to]).first
|
||||
if aspect = current_user.aspects.where(:id => params[:to]).first
|
||||
response_hash[:notice] = I18n.t 'aspects.move_contact.success'
|
||||
response_hash[:success] = true
|
||||
else
|
||||
|
|
|
|||
|
|
@ -12,11 +12,11 @@
|
|||
|
||||
- if @aspect.contacts_visible
|
||||
= link_to image_tag('icons/padlock-open.png', :height => 16, :width => 16, :id => "contact_visibility_padlock", :class => 'open', :title => t('.aspect_list_is_visible')),
|
||||
"aspects/#{@aspect.id}/toggle_contact_visibility", :remote => true
|
||||
aspect_toggle_contact_visibility_path(@aspect), :method => :put, :remote => true
|
||||
|
||||
- else
|
||||
= link_to image_tag('icons/padlock-closed.png', :height => 16, :width => 16, :id => "contact_visibility_padlock", :title => t('.aspect_list_is_not_visible')),
|
||||
"aspects/#{@aspect.id}/toggle_contact_visibility", :remote => true
|
||||
aspect_toggle_contact_visibility_path(@aspect), :method => :put, :remote => true
|
||||
|
||||
%h3#aspect_name_title
|
||||
%span.name= @aspect
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
- if @ownership
|
||||
.photo_options{:data=>{:actor=>"#{@photo.author.owner.id}", :actor_person => "#{@photo.author.id}", :image_url => "#{@photo.url(:thumb_large)}"}}
|
||||
= link_to t('.make_profile_photo'), {:controller => "photos", :action => "make_profile_photo", :photo_id => @photo.id}, :remote => true, :class => 'make_profile_photo'
|
||||
= link_to t('.make_profile_photo'), photo_make_profile_photo_path(@photo), :method => :put, :remote => true, :class => 'make_profile_photo'
|
||||
|
|
||||
= link_to t('.edit'), '#', :id => "edit_photo_toggle"
|
||||
%br
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
= t('aspects.manage.add_a_new_contact')
|
||||
= info_text(t('.enter_a_diaspora_username'))
|
||||
|
||||
= form_tag(person_by_handle_path, :id => "new_request_to_#{aspect_id}", :class => "webfinger_form", :remote => true) do
|
||||
= form_tag(person_by_handle_people_path, :id => "new_request_to_#{aspect_id}", :class => "webfinger_form", :remote => true) do
|
||||
= search_field_tag :diaspora_handle,'', :id => "request_d_handle_to_#{aspect_id}", :results => 5, :placeholder => t('.diaspora_handle')
|
||||
= hidden_field_tag :aspect_id, aspect_id
|
||||
= submit_tag t('.create_request')
|
||||
|
|
|
|||
|
|
@ -7,20 +7,17 @@ Diaspora::Application.routes.draw do
|
|||
# Posting and Reading
|
||||
|
||||
resources :aspects do
|
||||
collection do
|
||||
match 'move_contact' => :move_contact
|
||||
match 'add_to_aspect' => :add_to_aspect
|
||||
match 'remove_from_aspect' => :remove_from_aspect
|
||||
match 'manage' => :manage
|
||||
end
|
||||
match 'toggle_contact_visibility' => :toggle_contact_visibility
|
||||
get 'manage' => :manage, :on => :collection
|
||||
put 'move_contact' => :move_contact
|
||||
put 'toggle_contact_visibility' => :toggle_contact_visibility
|
||||
end
|
||||
|
||||
resources :status_messages, :only => [:new, :create, :destroy, :show]
|
||||
get 'p/:id' => 'posts#show', :as => 'post'
|
||||
|
||||
match 'photos/make_profile_photo' => 'photos#make_profile_photo'
|
||||
resources :photos, :except => [:index]
|
||||
resources :photos, :except => [:index] do
|
||||
put 'make_profile_photo' => :make_profile_photo
|
||||
end
|
||||
|
||||
resources :comments, :only => [:create, :destroy]
|
||||
|
||||
|
|
@ -63,9 +60,9 @@ Diaspora::Application.routes.draw do
|
|||
end
|
||||
get 'login' => redirect('/users/sign_in')
|
||||
|
||||
scope 'admins' do
|
||||
match 'user_search' => 'admins#user_search'
|
||||
match 'admin_inviter' => 'admins#admin_inviter'
|
||||
scope 'admins', :controller => :admins do
|
||||
match 'user_search' => :user_search
|
||||
get 'admin_inviter' => :admin_inviter
|
||||
end
|
||||
|
||||
resource :profile
|
||||
|
|
@ -78,8 +75,8 @@ Diaspora::Application.routes.draw do
|
|||
resources :people, :except => [:edit, :update] do
|
||||
resources :status_messages
|
||||
resources :photos
|
||||
post 'by_handle' => :retrieve_remote, :on => :collection, :as => 'person_by_handle'
|
||||
end
|
||||
match 'people/by_handle' => 'people#retrieve_remote', :as => 'person_by_handle'
|
||||
|
||||
|
||||
# Federation
|
||||
|
|
@ -122,7 +119,7 @@ Diaspora::Application.routes.draw do
|
|||
|
||||
# Mobile site
|
||||
|
||||
match 'mobile/toggle', :to => 'home#toggle_mobile', :as => 'toggle_mobile'
|
||||
get 'mobile/toggle', :to => 'home#toggle_mobile', :as => 'toggle_mobile'
|
||||
|
||||
|
||||
# Startpage
|
||||
|
|
|
|||
|
|
@ -61,14 +61,13 @@ var AspectEdit = {
|
|||
|
||||
if (person.attr('data-aspect_id') != undefined && // a request doesn't have a data-aspect_id, but an existing contact does
|
||||
dropzone.attr('data-aspect_id') != person.attr('data-aspect_id')) {
|
||||
var aspect_id = person.attr('data-aspect_id')
|
||||
$.ajax({
|
||||
url: "/aspects/move_contact/",
|
||||
type: "PUT",
|
||||
url: "/aspects/" + aspect_id + "/move_contact",
|
||||
data: {
|
||||
"person_id": person.attr('data-guid'),
|
||||
"from": person.attr('data-aspect_id'),
|
||||
"to": {
|
||||
"to": dropzone.attr('data-aspect_id')
|
||||
}
|
||||
"to": dropzone.attr('data-aspect_id')
|
||||
},
|
||||
success: function(data) {
|
||||
AspectEdit.onMovePersonSuccess(person, dropzone);
|
||||
|
|
@ -97,13 +96,12 @@ var AspectEdit = {
|
|||
Diaspora.widgets.alert.alert("Error removing contact", "You cannot remove the person from the last aspect");
|
||||
} else {
|
||||
if (!person.hasClass('request')) {
|
||||
|
||||
var aspect_id = person.attr('data-aspect_id')
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/aspects/remove_from_aspect",
|
||||
type: "DELETE",
|
||||
url: "/aspect_memberships/" + aspect_id,
|
||||
data: {
|
||||
'person_id': person_id,
|
||||
'aspect_id': person.attr('data-aspect_id')
|
||||
'person_id': person_id
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -115,7 +113,7 @@ var AspectEdit = {
|
|||
|
||||
changeName: function() {
|
||||
var $this = $(this),
|
||||
id = $this.closest(".aspect").attr("data-guid"),
|
||||
id = $this.closest(".aspect").attr("data-guid"),
|
||||
link = "/aspects/" + id;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -258,15 +258,14 @@ describe AspectsController do
|
|||
@person = Factory.create(:person)
|
||||
@opts = {
|
||||
:person_id => @person.id,
|
||||
:from => @alices_aspect_1.id,
|
||||
:to =>
|
||||
{:to => @alices_aspect_2.id}
|
||||
:aspect_id => @alices_aspect_1.id,
|
||||
:to => @alices_aspect_2.id
|
||||
}
|
||||
end
|
||||
it 'calls the move_contact_method' do
|
||||
@controller.stub!(:current_user).and_return(@alice)
|
||||
@alice.should_receive(:move_contact)
|
||||
post "move_contact", @opts
|
||||
put :move_contact, @opts
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue