Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Commit

Permalink
bug 1260197 - minor fixes: semicolon, debugger statements, gettext wr…
Browse files Browse the repository at this point in the history
…appers...
  • Loading branch information
dchukhin committed Aug 22, 2016
1 parent 98b79b0 commit 3b715c4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
23 changes: 10 additions & 13 deletions kuma/static/js/wiki-edit.js
Expand Up @@ -484,7 +484,7 @@
// record event
mdn.analytics.trackEvent({
category: 'Wiki',
action: 'Button',
action: 'Button', // now "Publish and keep editing" but keeping label for analytics continuity
label: 'Save and Keep Editing'
});

Expand Down Expand Up @@ -512,27 +512,25 @@
var $responseLoginRequired = $parsedData.find('#login');
// If there are errors, saveNotification() for each of them
if ($responseErrors.length) {
var liErrors = $responseErrors.find('li')
for (var i = 0; i < liErrors.length; i++) {
saveNotification.error(liErrors[i])
}
var $liErrors = $responseErrors.find('li');
saveNotification.error($liErrors);
//$form.submit();
// Check if the session has timed out
} else if ($responseLoginRequired.length) {
saveNotification.error('Publishing failed. You are not currently signed in. Please use a new tab to sign in and try publishing again.')
saveNotification.error(gettext('Publishing failed. You are not currently signed in. Please use a new tab to sign in and try publishing again.'));
} else {
// assume it went well
saveNotification.success(gettext('Changes saved.'), 2000);

// We also need to update the form's current_rev to
// avoid triggering a conflict, since we just saved in
// the background.
var responseData = JSON.parse(data)
if (responseData['error'] == true) {
saveNotification.error(responseData['error_message'])
var responseData = JSON.parse(data);
if (responseData['error'] === true) {
saveNotification.error(responseData['error_message']);
} else {
var responseRevision = JSON.parse(data)['new_revision_id'];
$("input[id=id_current_rev]").val(responseRevision)
$("input[id=id_current_rev]").val(responseRevision);

// Clear the review comment
$('#id_comment').val('');
Expand All @@ -548,14 +546,13 @@
error: function(jqXHR, textStatus, errorThrown) {
// Try to display the error that comes back from the server
try {
var errorMessage = JSON.parse(jqXHR['responseText'])['error_message']
var errorMessage = JSON.parse(jqXHR['responseText'])['error_message'];
} catch (err) {
errorMessage = "Publishing failed. Please copy and paste your changes into a safe place and try submitting the form using the 'Publish' button.";
errorMessage = gettext("Publishing failed. Please copy and paste your changes into a safe place and try submitting the form using the 'Publish' button.");
}
saveNotification.error(errorMessage);
// Re-enable the form; it gets disabled to prevent double-POSTs
$form.attr('disabled', false);
// save draft
}
});
/*
Expand Down
2 changes: 1 addition & 1 deletion kuma/wiki/jinja2/wiki/includes/page_buttons.html
Expand Up @@ -21,7 +21,7 @@
{% if document %}
{# No save-and-edit on new pages because slug changes confuse it #}
<li>
<button type="button" class="button positive btn-save-and-edit" data-optimizely-hook="button-save-and-keep-editing button-save-and-keep-editing-{{ location }}"><span>{{ _('Publish and Keep Editing') }}</span><i aria-hidden="true" class="icon-edit"></i></button>
<button type="button" class="button positive btn-save-and-edit" data-optimizely-hook="button-save-and-keep-editing button-save-and-keep-editing-{{ location }}"><span>{{ _('Publish and Keep Editing') }}</span><i aria-hidden="true" class="icon-pencil"></i></button>
</li>
{% endif %}
<li>
Expand Down
3 changes: 1 addition & 2 deletions kuma/wiki/views/translate.py
Expand Up @@ -202,7 +202,6 @@ def translate(request, document_slug, document_locale, revision_id=None):
parent_slug=slug_dict['parent'])
rev_form.instance.document = doc # for rev_form.clean()

# import ipdb;ipdb.set_trace()
if rev_form.is_valid() and not doc_form_invalid:
parent_id = request.POST.get('parent_id', '')

Expand Down Expand Up @@ -234,7 +233,7 @@ def translate(request, document_slug, document_locale, revision_id=None):
"error_message": mark_safe(rev_form.errors['current_rev'][0]),
"new_revision_id": rev_form.instance.id,
}
return JsonResponse(data=data, status=500)
return JsonResponse(data=data)

if doc:
from_id = smart_int(request.GET.get('from'), None)
Expand Down

0 comments on commit 3b715c4

Please sign in to comment.