Skip to content

Commit

Permalink
[DONE] Check extesion allowed video filename (#1033)
Browse files Browse the repository at this point in the history
* Check extesion allowed video filename

* Update add_video.html

Remove jquery part
  • Loading branch information
marchal-julien authored Jan 30, 2024
1 parent fedc2be commit eb49ce2
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions pod/video/templates/videos/add_video.html
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,31 @@ <h2 class="card-header card-title pod-card__title h4">{% trans "Help for form fi
maxFileSize: 1,
formData: form_data,
add: function (e, data) { // Called before starting upload
// If this is the second file you're uploading we need to remove the
// old upload_id and just keep the csrftoken (which is always first).
$(".hide-on-processing").hide();
$(".show-on-processing").show();
form_data.splice(1);
calculate_md5(data.files[0], max_chunk_size); // Again, chunks of 100 kB
data.submit();
// If this is the second file you're uploading we need to remove the
// old upload_id and just keep the csrftoken (which is always first).
var allow_extension_array = this.accept.replaceAll(' ', '').split(",");
var extension = data.originalFiles[0].name.substr((data.originalFiles[0].name.lastIndexOf('.') +1)).toLowerCase();
if (allow_extension_array.includes("."+extension) == false) {
showalert(
gettext("The file extension not in the allowed extension:") +
"<br/>" +
this.accept ,
"alert-danger",
);
}
else {
var elementsHideProcessing = document.getElementsByClassName("hide-on-processing");
for (let i = 0; i < elementsHideProcessing.length; i++) {
elementsHideProcessing[i].classList.add('d-none');
}
var elementsShowProcessing = document.getElementsByClassName("show-on-processing");
for (let i = 0; i < elementsShowProcessing.length; i++) {
elementsShowProcessing[i].style.display = 'block';
}
form_data.splice(1);
calculate_md5(data.files[0], max_chunk_size); // Again, chunks of 100 kB
data.submit();
}
},
chunkdone: function (e, data) { // Called after uploading each chunk
$(this).is(':checked')
Expand Down

0 comments on commit eb49ce2

Please sign in to comment.