diff --git a/amadeus/static/js/resources.js b/amadeus/static/js/resources.js index e067d7f..239e974 100644 --- a/amadeus/static/js/resources.js +++ b/amadeus/static/js/resources.js @@ -135,13 +135,30 @@ function FileSelectHandler(e) { parent = $(e.target.offsetParent), max_size = parseInt($(e.target).data("max_size")) * 1024 * 1024, submit_btn = $(e.target).closest("form").find("input[type='submit']"), - mimeTypes = $(e.target).data('mimetypes'); + mimeTypes = $(e.target).data('mimetypes'), + file_id = parent.data('file_id'); + + if ($(e.target).closest("form").prop('id') == "bulletin") { + parent.removeClass('alert-file'); + + var alerts_open = $(e.target).closest("form").find(".alert-file").length; + + if (alerts_open == 0) { + $(submit_btn).prop('disable', false); + $(submit_btn).prop('disabled', false); + } + + $("." + file_id + "-file-errors").hide(); + $("." + file_id + "-file-errors .size").hide(); + $("." + file_id + "-file-errors .format").hide(); + } else { + $(".client-file-errors").hide(); + $(".size").hide(); + $(".format").hide(); + $(submit_btn).prop('disable', false); + $(submit_btn).prop('disabled', false); + } - $(".client-file-errors").hide(); - $(".size").hide(); - $(".format").hide(); - $(submit_btn).prop('disable', false); - $(submit_btn).prop('disabled', false); // process all File objects for (var i = 0, f; f = files[i]; i++) { @@ -150,16 +167,30 @@ function FileSelectHandler(e) { $(submit_btn).prop('disable', true); $(submit_btn).prop('disabled', true); - $(".client-file-errors").show(); - $(".size").show(); + if ($(e.target).closest("form").prop('id') == "bulletin") { + $("." + file_id + "-file-errors").show(); + $("." + file_id + "-file-errors .size").show(); + + parent.addClass('alert-file'); + } else { + $(".client-file-errors").show(); + $(".size").show(); + } } if (!mimeTypes.includes(f.type)) { $(submit_btn).prop('disable', true); $(submit_btn).prop('disabled', true); - $(".client-file-errors").show(); - $(".format").show(); + if ($(e.target).closest("form").prop('id') == "bulletin") { + $("." + file_id + "-file-errors").show(); + $("." + file_id + "-file-errors .format").show(); + + parent.addClass('alert-file'); + } else { + $(".client-file-errors").show(); + $(".format").show(); + } } parent.find('.filedrag').html(f.name); diff --git a/bulletin/forms.py b/bulletin/forms.py index cabcf7f..efab8b3 100644 --- a/bulletin/forms.py +++ b/bulletin/forms.py @@ -39,6 +39,8 @@ class BulletinForm(forms.ModelForm): widgets = { 'content': forms.Textarea, 'brief_description': forms.Textarea, + 'file_content': ResubmitFileWidget(attrs={'accept':'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,application/vnd.oasis.opendocument.spreadsheet,text/csv'}), + 'indicators': ResubmitFileWidget(attrs={'accept':'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,application/vnd.oasis.opendocument.spreadsheet,text/csv'}), } def clean_name(self): diff --git a/bulletin/sheets/xls/olhos.xls b/bulletin/sheets/xls/olhos.xls new file mode 100644 index 0000000..6cd0424 Binary files /dev/null and b/bulletin/sheets/xls/olhos.xls differ diff --git a/bulletin/templates/bulletin/_form.html b/bulletin/templates/bulletin/_form.html index 7aa0a67..0ff1abe 100644 --- a/bulletin/templates/bulletin/_form.html +++ b/bulletin/templates/bulletin/_form.html @@ -1,7 +1,7 @@ {% load static i18n %} {% load widget_tweaks %} -