From 3d837940413c0ada663bd9671e2fa0b5e241df9c Mon Sep 17 00:00:00 2001 From: Aamir Khan Date: Fri, 29 Jun 2012 18:58:46 -0400 Subject: Fix #5 : Added alert box in case user is not logged in and tries to vote --- templates/message.html | 9 +++++++++ templates/thread.html | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/templates/message.html b/templates/message.html index 58187c0..d3d884b 100644 --- a/templates/message.html +++ b/templates/message.html @@ -19,6 +19,7 @@ $(".voteup").click(function() { // @TODO: Extract the message id from the HTML DOM element instead of hard coding it in Javascript. message_id = this.parentElement.getAttribute('messageid'); + {% if user.is_authenticated %} $.ajax({ type : "POST", url : '/vote/{{list_address}}/', @@ -33,10 +34,14 @@ } }); return false; + {% else %} + alert('You need to login in order to vote'); + {% endif %} }); $(".votedown").click(function() { message_id = this.parentElement.getAttribute('messageid'); + {% if user.is_authenticated %} $.ajax({ type : "POST", url : '/vote/{{list_address}}/', @@ -51,6 +56,10 @@ } }); return false; + {% else %} + alert('You need to login in order to vote'); + {% endif %} + }); }); diff --git a/templates/thread.html b/templates/thread.html index 508b03a..b15dd45 100644 --- a/templates/thread.html +++ b/templates/thread.html @@ -53,6 +53,7 @@ $(".voteup").click(function() { // @TODO: Extract the message id from the HTML DOM element instead of hard coding it in Javascript. message_id = this.parentElement.getAttribute('messageid'); + {% if user.is_authenticated %} $.ajax({ type : "POST", url : '/vote/{{list_address}}/', @@ -67,10 +68,14 @@ } }); return false; + {% else %} + alert('You need to login in order to vote'); + {% endif %} }); $(".votedown").click(function() { message_id = this.parentElement.getAttribute('messageid'); + {% if user.is_authenticated %} $.ajax({ type : "POST", url : '/vote/{{list_address}}/', @@ -85,6 +90,10 @@ } }); return false; + {% else %} + alert('You need to login in order to vote'); + {% endif %} + }); }); -- cgit