Skip to content
Extraits de code Groupes Projets
Valider 8b081a48 rédigé par danielgrippi's avatar danielgrippi Validation de Raphael Sofaer
Parcourir les fichiers

likes controller now has destroy method. commented out dislikes from views. ...

likes controller now has destroy method.  commented out dislikes from views.  unlike links not functional.
parent 4a24e906
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -3,7 +3,7 @@
# the COPYRIGHT file.
class AspectsController < ApplicationController
helper :comments, :aspect_memberships
helper :comments, :aspect_memberships, :likes
before_filter :authenticate_user!
before_filter :save_sort_order, :only => :index
before_filter :ensure_page, :only => :index
......
# Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
......@@ -41,4 +41,20 @@ class LikesController < ApplicationController
render :nothing => true, :status => 422
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
......@@ -2,16 +2,16 @@
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
- if likes.length > 0
- if likes.size > 0
.likes
= image_tag('icons/happy_smiley.png')
= link_to t('.people_like_this', :count => likes.length), "#", :class => "expand_likes"
%span.hidden.likes_list
= likes_list(likes)
- if dislikes.length > 0
.dislikes
= image_tag('icons/sad_smiley.png')
= link_to t('.people_dislike_this', :count => dislikes.length), "#", :class => "expand_dislikes"
%span.hidden.dislikes_list
= likes_list(dislikes)
/- if dislikes.length > 0
/ .dislikes
/ = image_tag('icons/sad_smiley.png')
/ = link_to t('.people_dislike_this', :count => dislikes.length), "#", :class => "expand_dislikes"
/ %span.hidden.dislikes_list
/ = likes_list(dislikes)
......@@ -39,15 +39,18 @@
- unless (defined?(@commenting_disabled) && @commenting_disabled)
= link_to t('comments.new_comment.comment'), '#', :class => 'focus_comment_textarea'
/ TODO(likes)
/- if (defined?(current_user) && !current_user.liked?(post))
/ %span.like_links
/ |
/ = link_to t('.like'), likes_path(:positive => 'true', :post_id => post.id ), :method => :post, :class => "like_it", :remote => true
/ |
/ = link_to t('.dislike'), likes_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
- if defined?(current_user)
%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
- else
= link_to t('.unlike'), likes_path(:post_id => post.id ), :method => :delete, :class => "like_it", :remote => true
/|
/= 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)
......@@ -271,17 +271,17 @@ en:
likes:
likes:
people_like_this:
zero: "no people liked this"
one: "1 person liked this"
few: "%{count} people liked this"
many: "%{count} people liked this"
other: "%{count} people liked this"
zero: "no likes"
one: "%{count} like"
few: "%{count} likes"
many: "%{count} likes"
other: "%{count} likes"
people_dislike_this:
zero: "no people disliked this"
one: "1 person disliked this"
few: "%{count} people disliked this"
many: "%{count} people disliked this"
other: "%{count} people disliked this"
zero: "no dislikes"
one: "%{count} dislike"
few: "%{count} dislikes"
many: "%{count} dislikes"
other: "%{count} dislikes"
notifications:
request_accepted: "accepted your share request."
......@@ -570,8 +570,9 @@ en:
all_contacts: "All contacts"
cannot_remove: "Cannot remove person from last aspect. (If you want to disconnect from this person you must remove contact.)"
stream_element:
like: "I like this"
dislike: "I dislike this"
like: "Like"
unlike: "Unlike"
dislike: "Dislike"
footer:
logged_in_as: "logged in as %{name}"
your_aspects: "your aspects"
......
......@@ -20,8 +20,8 @@ Diaspora::Application.routes.draw do
end
resources :comments, :only => [:create, :destroy]
resource :like, :only => [:create]
resources :likes, :only => [:create, :destroy]
resources :conversations do
resources :messages, :only => [:create, :show]
......
......@@ -2828,11 +2828,14 @@ h1.tag
a
:padding 1px
:vertical-align middle
:font-size smaller
:font-size 11px
img
:width 12px
:height 12px
:margin-left 0.5em
:position relative
:width 14px
:height 14px
:margin-left 5px
:top 2px
#contacts_of_contact
.section
......
......@@ -11,7 +11,8 @@ describe LikesController do
@aspect1 = @user1.aspects.first
@aspect2 = @user2.aspects.first
@controller.stub(:current_user).and_return(alice)
sign_in :user, @user1
end
......@@ -70,4 +71,29 @@ describe LikesController do
end
end
end
end
\ No newline at end of file
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
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter