From: jordan Date: Sat, 9 Apr 2011 19:29:45 +0000 (+0000) Subject: OSQA-538, fixing the IE caching issues, now we append the Nocache random number to... X-Git-Tag: live~358 X-Git-Url: https://git.openstreetmap.org/osqa.git/commitdiff_plain/c579fa70d5febab89dcb5b3811ed8d926127bff1 OSQA-538, fixing the IE caching issues, now we append the Nocache random number to the AJAX query, rather than to the whole JavaScript file. Also changed a bit the vote_post logic to ensure that the increment of the node reputation will happen only by one (in the previous implementation increment by 2 or -2 was also possible). git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@954 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- diff --git a/forum/skins/default/media/js/osqa.main.js b/forum/skins/default/media/js/osqa.main.js index 49fedda..2de5ecf 100644 --- a/forum/skins/default/media/js/osqa.main.js +++ b/forum/skins/default/media/js/osqa.main.js @@ -328,19 +328,22 @@ $(function() { $('a.ajax-command').live('click', function(evt) { if (running) return false; - $('.context-menu-dropdown').slideUp('fast'); - var el = $(this); + var ajax_url = el.attr('href') + ajax_url = ajax_url + "?nocache=" + new Date().getTime() + + $('.context-menu-dropdown').slideUp('fast'); + if (el.is('.withprompt')) { - load_prompt(evt, el, el.attr('href')); + load_prompt(evt, el, ajax_url); } else if(el.is('.confirm')) { var doptions = { html: messages.confirm, extra_class: 'confirm', yes_callback: function() { start_command(); - $.getJSON(el.attr('href'), function(data) { + $.getJSON(ajax_url, function(data) { process_ajax_response(data, evt); $dialog.fadeOut('fast', function() { $dialog.remove(); @@ -358,7 +361,7 @@ $(function() { var $dialog = show_dialog(doptions); } else { start_command(); - $.getJSON(el.attr('href'), function(data) { + $.getJSON(ajax_url, function(data) { process_ajax_response(data, evt); }); } diff --git a/forum/views/commands.py b/forum/views/commands.py index 3849ca3..175b6d1 100644 --- a/forum/views/commands.py +++ b/forum/views/commands.py @@ -91,13 +91,11 @@ def vote_post(request, id, vote_type): ) old_vote.cancel(ip=request.META['REMOTE_ADDR']) - score_inc += (old_vote.__class__ == VoteDownAction) and 1 or -1 - - if old_vote.__class__ != new_vote_cls: - new_vote_cls(user=user, node=post, ip=request.META['REMOTE_ADDR']).save() - score_inc += (new_vote_cls == VoteUpAction) and 1 or -1 - else: + score_inc = (old_vote.__class__ == VoteDownAction) and 1 or -1 vote_type = "none" + else: + new_vote_cls(user=user, node=post, ip=request.META['REMOTE_ADDR']).save() + score_inc = (new_vote_cls == VoteUpAction) and 1 or -1 response = { 'commands': {