Add handling for server errors when uploading images and documents via a modal dialog

This commit is contained in:
nfletton 2016-01-28 09:34:53 -07:00 committed by Matt Westcott
parent 67be20426a
commit 94ba1c40e4
5 changed files with 21 additions and 0 deletions

View file

@ -10,6 +10,7 @@ Changelog
* Date/time pickers now respect the locale's 'first day of week' setting (Peter Quade)
* Refactored the way forms are constructed for the page editor, to allow custom forms to be used
* Notification message on publish now indicates whether the page is being published now or scheduled for publication in future (Chris Rogers)
* Server errors when uploading images / documents through the chooser modal are now reported back to the user (Nigel Fletton)
* Fix: Custom page managers no longer raise an error when used on an abstract model
* Fix: Wagtail's migrations are now all reversible (benjaoming)
* Fix: Deleting a page content type now preserves existing pages as basic Page instances, to prevent tree corruption

View file

@ -104,6 +104,7 @@ Contributors
* Josh Schneier
* Mikalai Radchuk
* Charlie Choiniere
* Nigel Fletton
Translators

View file

@ -30,6 +30,7 @@ Minor features
* Date/time pickers now respect the locale's 'first day of week' setting (Peter Quade)
* Refactored the way forms are constructed for the page editor, to allow custom forms to be used
* Notification message on publish now indicates whether the page is being published now or scheduled for publication in future (Chris Rogers)
* Server errors when uploading images / documents through the chooser modal are now reported back to the user (Nigel Fletton)
Bug fixes

View file

@ -1,3 +1,4 @@
{% load i18n %}
function(modal) {
function ajaxifyLinks (context) {
$('a.document-choice', context).click(function() {
@ -57,6 +58,14 @@ function(modal) {
dataType: 'text',
success: function(response){
modal.loadResponseText(response);
},
error: function(response, textStatus, errorThrown) {
{% trans "Server Error" as error_label %}
{% trans "Report this error to your webmaster with the following information:" as error_message %}
message = '{{ error_message|escapejs }}<br />' + errorThrown + ' - ' + response.status;
$('#upload').append(
'<div class="help-block help-critical">' +
'<strong>{{ error_label|escapejs }}: </strong>' + message + '</div>');
}
});

View file

@ -1,3 +1,4 @@
{% load i18n %}
function(modal) {
var searchUrl = $('form.image-search', modal.body).attr('action');
@ -63,6 +64,14 @@ function(modal) {
dataType: 'text',
success: function(response){
modal.loadResponseText(response);
},
error: function(response, textStatus, errorThrown) {
{% trans "Server Error" as error_label %}
{% trans "Report this error to your webmaster with the following information:" as error_message %}
message = '{{ error_message|escapejs }}<br />' + errorThrown + ' - ' + response.status;
$('#upload').append(
'<div class="help-block help-critical">' +
'<strong>{{ error_label|escapejs }}: </strong>' + message + '</div>');
}
});