Skip to content

Commit

Permalink
aggiunto supporto per caricamento file ods
Browse files Browse the repository at this point in the history
  • Loading branch information
nkoexe committed Aug 30, 2024
1 parent 6b53241 commit cf4ed87
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions sostituzioni/control/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ def from_buffer(buffer: bytes | BytesIO, file_type: str | None = None):
):
file_type = "ods"

if file_type == "csv":
if file_type == "csv" or file_type == "text/csv":
data = pd.read_csv(buffer)
elif file_type == "xlsx":
elif file_type == "xlsx" or file_type == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" or file_type == "application/vnd.ms-excel":
data = pd.read_excel(buffer)
elif file_type == "ods":
elif file_type == "ods" or file_type == "application/vnd.oasis.opendocument.spreadsheet":
data = pd.read_excel(buffer, engine="odf")
else:
# tenta comunque di aprirlo yolo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@ function importa_docenti() {
}

let file = docenti_filepicker.files[0]
if (file.type != "text/csv" && file.type != "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") {
alert("Seleziona un file CSV o XLSX");
if (("text/csv", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application/vnd.ms-excel", "application/vnd.oasis.opendocument.spreadsheet").indexOf(file.type) == -1) {
alert("Seleziona un file CSV, XLSX o ODS");
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
<div id="main-container">
<div class="opzione">
<h5 class="opzione-titolo">Importa docenti da file</h5>
<p class="opzione-descrizione">Usare file esportati dai gruppi Google. Accettati formati XSLX e CSV.</p>
<p class="opzione-descrizione">Accettati file esportati da gruppi Google. Caricare un file CSV, XLSX o ODS.</p>
<!-- <p class="opzione-descrizione">Usare file esportati dai gruppi Google. Accettati formati XSLX e CSV, con l'email nella colonna 'Member Email'. Il nome del file dovrebbe assomigliare a questo: 'Members_xxxxxxxxxxxxxxxx_01012023_000000.csv.xlsx'</p> -->
<div class="opzione-file">
<div id="import-docenti-dropzone" class="opzione-file-dropzone">
<input type="file" id="import-docenti-filepicker" class="fileselected" accept=".csv,.xlsx">
<label for="import-docenti-filepicker"><span>Selezione un file o trascinalo qui</span></label>
<input type="file" id="import-docenti-filepicker" class="fileselected" accept=".csv,.xlsx,.xls,.ods">
<label for="import-docenti-filepicker" tabindex="0"><span>Selezione un file o trascinalo qui</span></label>
</div>
<!-- todo pulsante conferma e pulsante cancella file -->
<div id="import-docenti-selected" class="import-selected-file-container">
Expand Down

0 comments on commit cf4ed87

Please sign in to comment.