feat: modification du format de date et heure dans le csv

This commit is contained in:
Laetitia 2024-05-25 14:49:38 +02:00 committed by Laetitia Getti
parent 8b79492508
commit f242870d50
2 changed files with 15 additions and 8 deletions

View file

@ -374,8 +374,9 @@ class ExportGroupedOrderToCSVView(GroupedOrderExportView):
row.append("Prix de la commande")
row.append("Mail")
row.append("Téléphone")
row.append("Date et Heure")
row.append("Note")
row.append("Date")
row.append("Heure")
writer.writerow(row)
row = ["", "Prix unitaire TTC (€)"]
@ -395,8 +396,9 @@ class ExportGroupedOrderToCSVView(GroupedOrderExportView):
row.append(str(order.price).replace(".", ","))
row.append(order.author.email)
row.append(f"'{order.author.phone}")
row.append(f'\'{order.created_date.strftime("%d %B %Y %H:%M")}')
row.append(f"'{order.note}")
row.append(order.note)
row.append(order.created_date.strftime("%d/%m/%Y"))
row.append(order.created_date.strftime("%H:%M"))
writer.writerow(row)
# write total row

View file

@ -1631,7 +1631,8 @@ class TestExportGroupedOrderToCSVView:
content = response.content.decode("utf-8")
csv_reader = csv.reader(StringIO(content))
body = list(csv_reader)
created_date = f'\'{timezone.now().strftime("%d %B %Y %H:%M")}'
created_date = f"{timezone.now().strftime('%d/%m/%Y')}"
created_time = f"{timezone.now().strftime('%H:%M')}"
assert body == [
[
"",
@ -1641,8 +1642,9 @@ class TestExportGroupedOrderToCSVView:
"Prix de la commande",
"Mail",
"Téléphone",
"Date et Heure",
"Note",
"Date",
"Heure",
],
["", "Prix unitaire TTC (€)", "2,00", "9,00"],
["Nom", "Prénom"],
@ -1654,8 +1656,9 @@ class TestExportGroupedOrderToCSVView:
"2,00",
"bob2@escargot.fr",
"'000",
"",
created_date,
"'None",
created_time,
],
[
"alescargot",
@ -1665,8 +1668,9 @@ class TestExportGroupedOrderToCSVView:
"9,00",
"bob3@escargot.fr",
"'000",
"",
created_date,
"'None",
created_time,
],
[
"lescargot",
@ -1676,8 +1680,9 @@ class TestExportGroupedOrderToCSVView:
"24,00",
"bob@escargot.fr",
"'000",
"",
created_date,
"'None",
created_time,
],
["", "TOTAL", "4", "3", "35,00"],
]