summaryrefslogtreecommitdiff
path: root/addons/website_forum/static/src
diff options
context:
space:
mode:
authorTurkesh Patel (Open ERP) <tpa@tinyerp.com>2014-04-01 18:58:06 +0530
committerTurkesh Patel (Open ERP) <tpa@tinyerp.com>2014-04-01 18:58:06 +0530
commit30b49e20d47efdf232bd659effdb7bbaacb483c7 (patch)
treea20ade2bb537c6067fa398e5650eab9c7a67b6c4 /addons/website_forum/static/src
parentc3610687fc3e61a84233c0e837fd981a6f9c4d4d (diff)
[IMP] improved code to raise warning on accepting anser.
bzr revid: tpa@tinyerp.com-20140401132806-102jkjwxj2esukcr
Diffstat (limited to 'addons/website_forum/static/src')
-rw-r--r--addons/website_forum/static/src/css/website_forum.css4
-rw-r--r--addons/website_forum/static/src/js/website_forum.js31
2 files changed, 27 insertions, 8 deletions
diff --git a/addons/website_forum/static/src/css/website_forum.css b/addons/website_forum/static/src/css/website_forum.css
index 8647adaded1..b4c6e2315ac 100644
--- a/addons/website_forum/static/src/css/website_forum.css
+++ b/addons/website_forum/static/src/css/website_forum.css
@@ -59,4 +59,8 @@
.load_tags{
width: 845px !important;
+}
+
+.fa-thumbs-up, .fa-thumbs-down, .oe_answer_true, .oe_answer_false {
+ cursor:pointer;
} \ No newline at end of file
diff --git a/addons/website_forum/static/src/js/website_forum.js b/addons/website_forum/static/src/js/website_forum.js
index 591d2d24b69..2f950b58c23 100644
--- a/addons/website_forum/static/src/js/website_forum.js
+++ b/addons/website_forum/static/src/js/website_forum.js
@@ -64,15 +64,30 @@ $(document).ready(function () {
ev.preventDefault();
var $link = $(ev.currentTarget);
openerp.jsonRpc("/forum/correct_answer/", 'call', {
- 'post_id': $link.attr("id")})
- .then(function (data) {
- par = $link.parents().find(".oe_answer_true")
- $link.parents().find(".oe_answer_true").removeClass("oe_answer_true").addClass('oe_answer_false')
- if (data) {
+ 'post_id': $link.attr("id")})
+ .then(function (data) {
+ if (data['error']) {
+ if (data['error'] == 'anonymous_user'){
+ var $warning = $('<div class="alert alert-danger alert-dismissable" id="correct_answer_alert" style="position:absolute; margin-top: -30px; margin-left: 90px;">'+
+ '<button type="button" class="close notification_close" data-dismiss="alert" aria-hidden="true">&times;</button>'+
+ 'Sorry, anonymous users cannot choose correct answer.'+
+ '</div>');
+ } else if (data['error'] == 'user'){
+ var $warning = $('<div class="alert alert-danger alert-dismissable" id="correct_answer_alert" style="position:absolute; margin-top: -30px; margin-left: 90px;">'+
+ '<button type="button" class="close notification_close" data-dismiss="alert" aria-hidden="true">&times;</button>'+
+ 'Sorry, You cannot choose correct answer.'+
+ '</div>');
+ }
+ correct_answer_alert = $link.parent().find("#correct_answer_alert");
+ if (correct_answer_alert.length == 0) {
+ $link.parent().append($warning);
+ }
+ } else {
+ $link.parents().find(".oe_answer_true").removeClass("oe_answer_true").addClass('oe_answer_false');
$link.removeClass("oe_answer_false").addClass('oe_answer_true');
- }
- });
- return false;
+ }
+ });
+ return true;
});
$('.comment_delete').on('click', function (ev) {