likes controller now has destroy method. commented out dislikes from views. unlike links not functional.
This commit is contained in:
parent
4a24e90671
commit
8b081a48b4
8 changed files with 86 additions and 37 deletions
|
|
@ -3,7 +3,7 @@
|
||||||
# the COPYRIGHT file.
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
class AspectsController < ApplicationController
|
class AspectsController < ApplicationController
|
||||||
helper :comments, :aspect_memberships
|
helper :comments, :aspect_memberships, :likes
|
||||||
before_filter :authenticate_user!
|
before_filter :authenticate_user!
|
||||||
before_filter :save_sort_order, :only => :index
|
before_filter :save_sort_order, :only => :index
|
||||||
before_filter :ensure_page, :only => :index
|
before_filter :ensure_page, :only => :index
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
# Copyright (c) 2010, Diaspora Inc. This file is
|
|
||||||
# licensed under the Affero General Public License version 3 or later. See
|
# licensed under the Affero General Public License version 3 or later. See
|
||||||
# the COPYRIGHT file.
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
|
|
@ -41,4 +41,20 @@ class LikesController < ApplicationController
|
||||||
render :nothing => true, :status => 422
|
render :nothing => true, :status => 422
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
if @like = Like.where(:id => params[:id], :author_id => current_user.person.id).first
|
||||||
|
current_user.retract(@like)
|
||||||
|
respond_to do |format|
|
||||||
|
format.mobile{ redirect_to @like.post }
|
||||||
|
format.js {render :nothing => true, :status => 204}
|
||||||
|
end
|
||||||
|
else
|
||||||
|
respond_to do |format|
|
||||||
|
format.mobile {redirect_to :back}
|
||||||
|
format.js {render :nothing => true, :status => 403}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,16 +2,16 @@
|
||||||
-# licensed under the Affero General Public License version 3 or later. See
|
-# licensed under the Affero General Public License version 3 or later. See
|
||||||
-# the COPYRIGHT file.
|
-# the COPYRIGHT file.
|
||||||
|
|
||||||
- if likes.length > 0
|
- if likes.size > 0
|
||||||
.likes
|
.likes
|
||||||
= image_tag('icons/happy_smiley.png')
|
= image_tag('icons/happy_smiley.png')
|
||||||
= link_to t('.people_like_this', :count => likes.length), "#", :class => "expand_likes"
|
= link_to t('.people_like_this', :count => likes.length), "#", :class => "expand_likes"
|
||||||
%span.hidden.likes_list
|
%span.hidden.likes_list
|
||||||
= likes_list(likes)
|
= likes_list(likes)
|
||||||
|
|
||||||
- if dislikes.length > 0
|
/- if dislikes.length > 0
|
||||||
.dislikes
|
/ .dislikes
|
||||||
= image_tag('icons/sad_smiley.png')
|
/ = image_tag('icons/sad_smiley.png')
|
||||||
= link_to t('.people_dislike_this', :count => dislikes.length), "#", :class => "expand_dislikes"
|
/ = link_to t('.people_dislike_this', :count => dislikes.length), "#", :class => "expand_dislikes"
|
||||||
%span.hidden.dislikes_list
|
/ %span.hidden.dislikes_list
|
||||||
= likes_list(dislikes)
|
/ = likes_list(dislikes)
|
||||||
|
|
|
||||||
|
|
@ -39,15 +39,18 @@
|
||||||
- unless (defined?(@commenting_disabled) && @commenting_disabled)
|
- unless (defined?(@commenting_disabled) && @commenting_disabled)
|
||||||
= link_to t('comments.new_comment.comment'), '#', :class => 'focus_comment_textarea'
|
= link_to t('comments.new_comment.comment'), '#', :class => 'focus_comment_textarea'
|
||||||
|
|
||||||
/ TODO(likes)
|
- if defined?(current_user)
|
||||||
/- if (defined?(current_user) && !current_user.liked?(post))
|
%span.like_links
|
||||||
/ %span.like_links
|
|
|
||||||
/ |
|
- if !current_user.liked?(post)
|
||||||
/ = link_to t('.like'), likes_path(:positive => 'true', :post_id => post.id ), :method => :post, :class => "like_it", :remote => true
|
= link_to t('.like'), likes_path(:positive => 'true', :post_id => post.id ), :method => :post, :class => "like_it", :remote => true
|
||||||
/ |
|
- else
|
||||||
/ = link_to t('.dislike'), likes_path(:positive => 'false', :post_id => post.id), :method => :post, :class => "dislike_it", :remote => true
|
= link_to t('.unlike'), likes_path(:post_id => post.id ), :method => :delete, :class => "like_it", :remote => true
|
||||||
|
|
||||||
/.likes_container
|
/|
|
||||||
/ = render "likes/likes", :post_id => post.id, :likes => post.likes, :dislikes => post.dislikes, :current_user => current_user
|
/= link_to t('.dislike'), like_path(:positive => 'false', :post_id => post.id), :method => :post, :class => "dislike_it", :remote => true
|
||||||
|
|
||||||
|
.likes_container
|
||||||
|
= render "likes/likes", :post_id => post.id, :likes => post.likes, :dislikes => post.dislikes, :current_user => current_user
|
||||||
|
|
||||||
= render "comments/comments", :post => post, :comments => post.comments, :current_user => current_user, :condensed => true, :commenting_disabled => (defined?(@commenting_disabled) && @commenting_disabled)
|
= render "comments/comments", :post => post, :comments => post.comments, :current_user => current_user, :condensed => true, :commenting_disabled => (defined?(@commenting_disabled) && @commenting_disabled)
|
||||||
|
|
|
||||||
|
|
@ -271,17 +271,17 @@ en:
|
||||||
likes:
|
likes:
|
||||||
likes:
|
likes:
|
||||||
people_like_this:
|
people_like_this:
|
||||||
zero: "no people liked this"
|
zero: "no likes"
|
||||||
one: "1 person liked this"
|
one: "%{count} like"
|
||||||
few: "%{count} people liked this"
|
few: "%{count} likes"
|
||||||
many: "%{count} people liked this"
|
many: "%{count} likes"
|
||||||
other: "%{count} people liked this"
|
other: "%{count} likes"
|
||||||
people_dislike_this:
|
people_dislike_this:
|
||||||
zero: "no people disliked this"
|
zero: "no dislikes"
|
||||||
one: "1 person disliked this"
|
one: "%{count} dislike"
|
||||||
few: "%{count} people disliked this"
|
few: "%{count} dislikes"
|
||||||
many: "%{count} people disliked this"
|
many: "%{count} dislikes"
|
||||||
other: "%{count} people disliked this"
|
other: "%{count} dislikes"
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
request_accepted: "accepted your share request."
|
request_accepted: "accepted your share request."
|
||||||
|
|
@ -570,8 +570,9 @@ en:
|
||||||
all_contacts: "All contacts"
|
all_contacts: "All contacts"
|
||||||
cannot_remove: "Cannot remove person from last aspect. (If you want to disconnect from this person you must remove contact.)"
|
cannot_remove: "Cannot remove person from last aspect. (If you want to disconnect from this person you must remove contact.)"
|
||||||
stream_element:
|
stream_element:
|
||||||
like: "I like this"
|
like: "Like"
|
||||||
dislike: "I dislike this"
|
unlike: "Unlike"
|
||||||
|
dislike: "Dislike"
|
||||||
footer:
|
footer:
|
||||||
logged_in_as: "logged in as %{name}"
|
logged_in_as: "logged in as %{name}"
|
||||||
your_aspects: "your aspects"
|
your_aspects: "your aspects"
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,8 @@ Diaspora::Application.routes.draw do
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :comments, :only => [:create, :destroy]
|
resources :comments, :only => [:create, :destroy]
|
||||||
resource :like, :only => [:create]
|
|
||||||
|
|
||||||
|
resources :likes, :only => [:create, :destroy]
|
||||||
|
|
||||||
resources :conversations do
|
resources :conversations do
|
||||||
resources :messages, :only => [:create, :show]
|
resources :messages, :only => [:create, :show]
|
||||||
|
|
|
||||||
|
|
@ -2828,11 +2828,14 @@ h1.tag
|
||||||
a
|
a
|
||||||
:padding 1px
|
:padding 1px
|
||||||
:vertical-align middle
|
:vertical-align middle
|
||||||
:font-size smaller
|
:font-size 11px
|
||||||
img
|
img
|
||||||
:width 12px
|
:position relative
|
||||||
:height 12px
|
:width 14px
|
||||||
:margin-left 0.5em
|
:height 14px
|
||||||
|
:margin-left 5px
|
||||||
|
:top 2px
|
||||||
|
|
||||||
|
|
||||||
#contacts_of_contact
|
#contacts_of_contact
|
||||||
.section
|
.section
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,8 @@ describe LikesController do
|
||||||
|
|
||||||
@aspect1 = @user1.aspects.first
|
@aspect1 = @user1.aspects.first
|
||||||
@aspect2 = @user2.aspects.first
|
@aspect2 = @user2.aspects.first
|
||||||
|
|
||||||
|
@controller.stub(:current_user).and_return(alice)
|
||||||
sign_in :user, @user1
|
sign_in :user, @user1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -70,4 +71,29 @@ describe LikesController do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
describe '#destroy' do
|
||||||
|
context 'your like' do
|
||||||
|
before do
|
||||||
|
@message = bob.post(:status_message, :text => "hey", :to => @aspect1.id)
|
||||||
|
@like = alice.build_like(true, :on => @message)
|
||||||
|
@like.save
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'lets a user destroy their like' do
|
||||||
|
alice.should_receive(:retract).with(@like)
|
||||||
|
delete :destroy, :format => "js", :id => @like.id
|
||||||
|
response.status.should == 204
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'does not let a user destroy other likes' do
|
||||||
|
like2 = eve.build_like(true, :on => @message)
|
||||||
|
like2.save
|
||||||
|
|
||||||
|
alice.should_not_receive(:retract)
|
||||||
|
delete :destroy, :format => "js", :id => like2.id
|
||||||
|
response.status.should == 403
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue