customStorage manager in Sistemas app and zip views to upload the zip

This commit is contained in:
fjrodriguez
2023-02-10 07:39:25 -06:00
parent b73a4d50d0
commit ddc4be05a2
6 changed files with 120 additions and 11 deletions

View File

@@ -0,0 +1,51 @@
{% extends 'base.html' %}
{% block title %}
| Sistemas
{% endblock title %}
{% block content %}
<form id="upload-form">
<input type="file" name="zip_file">
<button type="submit">Upload</button>
</form>
<input type="hidden" id="id_token" name="token" value="{{ token }}">
{% endblock content %}
{% block scripts %}
<script>
document.getElementById('upload-form').addEventListener('submit', function (event) {
event.preventDefault();
let formData = new FormData(event.target);
let token = document.getElementById("id_token").value;
fetch(`{% url 'uploadZip' %}`, {
method: 'POST',
body: formData,
headers: {
'Authorization': 'Token ' + token,
},
})
.then(function (response) {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(function (data) {
console.log(data);
window.location.reload();
})
.catch(function (error) {
console.error(error);
});
});
</script>
{% endblock scripts %}