Skip to content

Commit

Permalink
Update the remaining number of votes after a vote
Browse files Browse the repository at this point in the history
  • Loading branch information
nono committed Apr 24, 2011
1 parent 6e37c71 commit 15e1665
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/controllers/relevances_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ class RelevancesController < ApplicationController
def for
@comment.vote_for(current_account) if @comment.votable_by?(current_account)
respond_to do |wants|
wants.json { render :json => { :notice => "Merci pour votre vote" } }
wants.json { render :json => { :notice => "Merci pour votre vote", :nb_votes => current_account.nb_votes } }
wants.html { redirect_to :back }
end
end

def against
@comment.vote_against(current_account) if @comment.votable_by?(current_account)
respond_to do |wants|
wants.json { render :json => { :notice => "Merci pour votre vote" } }
wants.json { render :json => { :notice => "Merci pour votre vote", :nb_votes => current_account.nb_votes } }
wants.html { redirect_to :back }
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/votes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ class VotesController < ApplicationController
def for
@node.vote_for(current_account) if @node.content.votable_by?(current_account)
respond_to do |wants|
wants.json { render :json => { :notice => "Merci pour votre vote" } }
wants.json { render :json => { :notice => "Merci pour votre vote", :nb_votes => current_account.nb_votes } }
wants.html { redirect_to_content @node.content }
end
end

def against
@node.vote_against(current_account) if @node.content.votable_by?(current_account)
respond_to do |wants|
wants.json { render :json => { :notice => "Merci pour votre vote" } }
wants.json { render :json => { :notice => "Merci pour votre vote", :nb_votes => current_account.nb_votes } }
wants.html { redirect_to_content @node.content }
end
end
Expand Down
5 changes: 4 additions & 1 deletion app/views/layouts/_sidebar.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
document.write('<a class="secure">Accès sécurisé (https)</a>');
}
- if account_signed_in?
%p Il vous reste #{current_account.nb_votes} avis
%p
Il vous reste
%span#nb_votes #{current_account.nb_votes}
avis
%ul
%li= link_to "Proposer un contenu", '/proposer-un-contenu'
%li= link_to "Mon tableau de bord", '/tableau-de-bord'
Expand Down
3 changes: 3 additions & 0 deletions public/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
if (data && data.notice) {
jQuery.noticeAdd({text: data.notice});
}
if (data && data.nb_votes) {
$("#nb_votes").text(data.nb_votes);
}
if (!$(this).data('hidden')) {
$(this).parent().hide();
}
Expand Down

0 comments on commit 15e1665

Please sign in to comment.