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

Commit

Permalink
Fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
aguilerapy committed Aug 12, 2020
1 parent 443689e commit 1e9a0b0
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 45 deletions.
9 changes: 5 additions & 4 deletions default/static/js/uploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ var toucanApp = toucanApp || {};

function whenAjaxReqFails(jqXHR) {
if (jqXHR.status === 401)
$('.response-fail.default-error').removeClass('hidden');
$('.response-warning.file-process-failed').removeClass('hidden');
else
$('.response-fail').removeClass('hidden');
$('.response-fail.default-error').removeClass('hidden');
app.hideProcessingModal();
}

Expand Down Expand Up @@ -215,6 +215,7 @@ var toucanApp = toucanApp || {};
$(slt).addClass('has-error');
$(slt).append('<div class="help-block">' + msg + '</div>');
});
alert(jqXHR.status);
whenAjaxReqFails(jqXHR);
$('#processing-modal .downloading-status').addClass('hidden');
})
Expand Down Expand Up @@ -260,7 +261,7 @@ var toucanApp = toucanApp || {};

/* check if results were sent to this page */
if (window.location.search == '?sendResult=true') {
showProcessingModal();
app.showProcessingModal();
$.ajax('/send-result/validate/', {'dataType': 'json', type: 'GET'})
.done(function (data) {
disableAddFiles();
Expand All @@ -277,7 +278,7 @@ var toucanApp = toucanApp || {};
$('.response-fail').removeClass('hidden');
})
.always(function () {
hideProcessingModal();
app.hideProcessingModal();
});
}

Expand Down
9 changes: 9 additions & 0 deletions default/templates/default/base-tool.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@
<span class="file open-drive-link hidden">
{% trans "File saved on Google Drive" %}&nbsp;<a target="_blank" role="button"> {% trans "Open" %}</a>
</span>
<div class="form-group form-inline form-send hidden">
<label>{% trans "Send result to function:" %}</label>
<select class="form-control to-function">
<option id="compile" value="/compile/">{% trans "Compile Releases" %}</option>
<option id="upgrade" value="/upgrade/">{% trans "Upgrade from 1.0 to 1.1" %}</option>
<option id="convert" value="/to-spreadsheet/">{% trans "Convert to CSV/Excel" %}</option>
</select>
<a class="send-button" href="#" role="button">{% trans "Send" %}</a>
</div>
</div>
<div class="response-warning action-failed alert alert-warning hidden">
</div>
Expand Down
2 changes: 1 addition & 1 deletion default/templates/default/base-uploader.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
{{ block.super }}
<div class="response-warning file-process-failed alert alert-warning hidden">
{% trans "We couldn't check that all files were JSON or of the OCDS type requested." %}
{% trans "You can add more files or remove them, then click on <b>Start</b> again." %}
{% trans "Please verify each file and try again." %}
{% trans "Files with validation issues will be ignored by default." %}
</div>
<div class="response-fail default-error alert alert-danger hidden">
Expand Down
8 changes: 3 additions & 5 deletions default/templates/default/to-json.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,6 @@
});
});

/** click send button behaviour **/
$('.send-button').click(function(){
window.location.href = $('.to-function').val() + '?sendResult=true';
});

/** click send button behaviour **/
$('.send-button').click(function(){
window.location.href = $('.to-function').val() + '?sendResult=true';
Expand Down Expand Up @@ -190,6 +185,9 @@
/* clear URL input text */
$('#input_url_0 input').val('');

/* show form-send options */
$('.response-success .form-send').removeClass('hidden');

/* prevent browser's default action when dragging and dropping files */
$(document).bind('drop dragover', function (e) {
e.preventDefault();
Expand Down
68 changes: 34 additions & 34 deletions default/templates/default/to-spreadsheet.html
Original file line number Diff line number Diff line change
Expand Up @@ -168,48 +168,48 @@
$('.form-group').removeClass('has-error');
$('.help-block').remove();

$.ajax('/upload-url/', {'dataType': 'json', type: 'POST',
'data': $('.input-url-container .form-group .form-control').serialize() +
'&type=' + JSON.parse($('#fileupload').attr('data-form-data')).type,
headers: {'X-CSRFToken': JSON.parse($('#fileupload').attr('data-form-data')).csrfmiddlewaretoken}})
.done(function (data) {
$.ajax('/to-spreadsheet/go/', { 'dataType': 'json' })
.done(function (data) {
$('.response-success .download.xlsx').attr('href', data.xlsx.url);
$('.response-success .download.csv').attr('href', data.csv.url);
$('.response-success .file-size.xlsx').html(utils.readableFileSize(data.xlsx.size));
$('.response-success .file-size.csv').html(utils.readableFileSize(data.csv.size));
$('.response-success .save-drive-link.xlsx').attr('data-url', data.xlsx.driveUrl);
$('.response-success .save-drive-link.csv').attr('data-url', data.csv.driveUrl);
$('.response-success').removeClass('hidden');
})
.fail(function () {
$('.response-fail').removeClass('hidden');
})
.always(function () {
$('#processing-modal').modal('hide');
});
})
.fail(function(jqXHR, textStatus, errorThrown) {
$.each(JSON.parse(jqXHR.responseText), function(i, item) {
slt = "#" + item.id;
msg = item.message;
$(slt).addClass('has-error');
$(slt).append('<div class="help-block">' + msg + '</div>');
$.ajax('/upload-url/', {'dataType': 'json', type: 'POST',
'data': $('.input-url-container .form-group .form-control').serialize() +
'&type=' + JSON.parse($('#fileupload').attr('data-form-data')).type,
headers: {'X-CSRFToken': JSON.parse($('#fileupload').attr('data-form-data')).csrfmiddlewaretoken}})
.done(function (data) {
$.ajax('/to-spreadsheet/go/', { 'dataType': 'json' })
.done(function (data) {
$('.response-success .download.xlsx').attr('href', data.xlsx.url);
$('.response-success .download.csv').attr('href', data.csv.url);
$('.response-success .file-size.xlsx').html(utils.readableFileSize(data.xlsx.size));
$('.response-success .file-size.csv').html(utils.readableFileSize(data.csv.size));
$('.response-success .save-drive-link.xlsx').attr('data-url', data.xlsx.driveUrl);
$('.response-success .save-drive-link.csv').attr('data-url', data.csv.driveUrl);
$('.response-success').removeClass('hidden');
})
.fail(function () {
$('.response-fail').removeClass('hidden');
})
.always(function () {
$('#processing-modal').modal('hide');
});
$('.response-fail').removeClass('hidden');
$('#processing-modal').modal('hide');
})
.fail(function(jqXHR, textStatus, errorThrown) {
$.each(JSON.parse(jqXHR.responseText), function(i, item) {
slt = "#" + item.id;
msg = item.message;
$(slt).addClass('has-error');
$(slt).append('<div class="help-block">' + msg + '</div>');
});
$('.response-fail').removeClass('hidden');
$('#processing-modal').modal('hide');
});
});

function performAction(url, params) {
$('#processing-modal').modal('show');
$.ajax(url, { 'data': params, 'dataType': 'json' })
.done(function(data){
$('.response-success .download-xlsx').attr('href', data.xlsx.url);
$('.response-success .download-csv').attr('href', data.csv.url);
$('.response-success .file-size-xlsx').html(utils.readableFileSize(data.xlsx.size));
$('.response-success .file-size-csv').html(utils.readableFileSize(data.csv.size));
$('.response-success .download.xlsx').attr('href', data.xlsx.url);
$('.response-success .download.csv').attr('href', data.csv.url);
$('.response-success .file-size.xlsx').html(utils.readableFileSize(data.xlsx.size));
$('.response-success .file-size.csv').html(utils.readableFileSize(data.csv.size));
$('.response-success').removeClass('hidden');
$('.response-success .save-drive-link.xlsx').attr('data-url', data.xlsx.driveUrl);
$('.response-success .save-drive-link.csv').attr('data-url', data.csv.driveUrl);
Expand Down
2 changes: 1 addition & 1 deletion default/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from requests.exceptions import ConnectionError, HTTPError, SSLError

from default.data_file import DataFile
from default.decorators import clear_drive_session_vars, clear_files, published_date
from default.decorators import clear_drive_session_vars, clear_files, published_date, validate_files
from default.forms import MappingSheetOptionsForm
from default.google_drive import get_credentials_from_session, google_api_messages, upload_to_drive
from default.mapping_sheet import (get_extended_mapping_sheet, get_mapping_sheet_from_uploaded_file,
Expand Down

0 comments on commit 1e9a0b0

Please sign in to comment.