Commit 2dfe104f by E. Kolpakov Committed by Jonathan Piacenti

Fix for endorsement 403 error

parent 05c4e03f
...@@ -181,11 +181,13 @@ class @DiscussionUtil ...@@ -181,11 +181,13 @@ class @DiscussionUtil
params["$loading"].loaded() params["$loading"].loaded()
return request return request
@updateWithUndo: (model, updates, safeAjaxParams, errorMsg) -> @updateWithUndo: (model, updates, safeAjaxParams, errorMsg, beforeSend) ->
if errorMsg if errorMsg
safeAjaxParams.error = => @discussionAlert(gettext("Sorry"), errorMsg) safeAjaxParams.error = => @discussionAlert(gettext("Sorry"), errorMsg)
undo = _.pick(model.attributes, _.keys(updates)) undo = _.pick(model.attributes, _.keys(updates))
model.set(updates) model.set(updates)
if beforeSend?
beforeSend()
@safeAjax(safeAjaxParams).fail(() -> model.set(undo)) @safeAjax(safeAjaxParams).fail(() -> model.set(undo))
@bindLocalEvents: ($local, eventsHandler) -> @bindLocalEvents: ($local, eventsHandler) ->
......
...@@ -211,8 +211,9 @@ if Backbone? ...@@ -211,8 +211,9 @@ if Backbone?
DiscussionUtil.updateWithUndo( DiscussionUtil.updateWithUndo(
@model, @model,
updates, updates,
{url: url, type: "POST", data: {endorsed: is_endorsing}, beforeSend: beforeFunc, $elem: $(event.currentTarget)}, {url: url, type: "POST", data: {endorsed: is_endorsing}, $elem: $(event.currentTarget)},
msg msg,
beforeFunc
).always(@trigger("comment:endorse")) # ensures UI components get updated to the correct state when ajax completes ).always(@trigger("comment:endorse")) # ensures UI components get updated to the correct state when ajax completes
toggleVote: (event) => toggleVote: (event) =>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment