mirror of
https://framagit.org/la-chariotte/la-chariotte.git
synced 2025-05-02 03:42:26 +02:00
separate last name and first name fields in csv export
This commit is contained in:
parent
064a3a8c74
commit
947eded96f
2 changed files with 15 additions and 9 deletions
|
@ -1448,6 +1448,7 @@ class TestExportGroupedOrderToCSVView:
|
||||||
body = list(csv_reader)
|
body = list(csv_reader)
|
||||||
assert body == [
|
assert body == [
|
||||||
[
|
[
|
||||||
|
"",
|
||||||
"",
|
"",
|
||||||
"test item",
|
"test item",
|
||||||
"test item 2",
|
"test item 2",
|
||||||
|
@ -1455,9 +1456,10 @@ class TestExportGroupedOrderToCSVView:
|
||||||
"Mail",
|
"Mail",
|
||||||
"Téléphone",
|
"Téléphone",
|
||||||
],
|
],
|
||||||
["Prix unitaire TTC (€)", "2,00", "9,00"],
|
["", "Prix unitaire TTC (€)", "2,00", "9,00"],
|
||||||
["bob alescargot", "1", "0", "2,00", "bob2@escargot.fr", "'000"],
|
["Nom", "Prénom"],
|
||||||
["bobby alescargot", "0", "1", "9,00", "bob3@escargot.fr", "'000"],
|
["alescargot", "bob", "1", "0", "2,00", "bob2@escargot.fr", "'000"],
|
||||||
["bob lescargot", "3", "2", "24,00", "bob@escargot.fr", "'000"],
|
["alescargot", "bobby", "0", "1", "9,00", "bob3@escargot.fr", "'000"],
|
||||||
["TOTAL", "4", "3", "35,00"],
|
["lescargot", "bob", "3", "2", "24,00", "bob@escargot.fr", "'000"],
|
||||||
|
["", "TOTAL", "4", "3", "35,00"],
|
||||||
]
|
]
|
||||||
|
|
|
@ -322,7 +322,7 @@ class ExportGroupedOrderToCSVView(GroupedOrderExportView):
|
||||||
writer = csv.writer(response)
|
writer = csv.writer(response)
|
||||||
|
|
||||||
# write headers rows
|
# write headers rows
|
||||||
row = [""]
|
row = ["", ""]
|
||||||
for item in context["items"]:
|
for item in context["items"]:
|
||||||
row.append(item.name)
|
row.append(item.name)
|
||||||
row.append("Prix de la commande")
|
row.append("Prix de la commande")
|
||||||
|
@ -330,14 +330,18 @@ class ExportGroupedOrderToCSVView(GroupedOrderExportView):
|
||||||
row.append("Téléphone")
|
row.append("Téléphone")
|
||||||
writer.writerow(row)
|
writer.writerow(row)
|
||||||
|
|
||||||
row = ["Prix unitaire TTC (€)"]
|
row = ["", "Prix unitaire TTC (€)"]
|
||||||
for item in context["items"]:
|
for item in context["items"]:
|
||||||
row.append(str(item.price).replace(".", ","))
|
row.append(str(item.price).replace(".", ","))
|
||||||
writer.writerow(row)
|
writer.writerow(row)
|
||||||
|
|
||||||
|
row = ["Nom", "Prénom"]
|
||||||
|
writer.writerow(row)
|
||||||
|
|
||||||
# write ordered values rows
|
# write ordered values rows
|
||||||
for order, ordered_items in context["orders_dict"].items():
|
for order, ordered_items in context["orders_dict"].items():
|
||||||
row = [order.author]
|
row = [order.author.last_name]
|
||||||
|
row.append(order.author.first_name)
|
||||||
for ordered_nb in ordered_items:
|
for ordered_nb in ordered_items:
|
||||||
row.append(ordered_nb)
|
row.append(ordered_nb)
|
||||||
row.append(str(order.price).replace(".", ","))
|
row.append(str(order.price).replace(".", ","))
|
||||||
|
@ -346,7 +350,7 @@ class ExportGroupedOrderToCSVView(GroupedOrderExportView):
|
||||||
writer.writerow(row)
|
writer.writerow(row)
|
||||||
|
|
||||||
# write total row
|
# write total row
|
||||||
row = ["TOTAL"]
|
row = ["", "TOTAL"]
|
||||||
for item in context["items"]:
|
for item in context["items"]:
|
||||||
row.append(item.ordered_nb)
|
row.append(item.ordered_nb)
|
||||||
row.append(str(context["object"].total_price).replace(".", ","))
|
row.append(str(context["object"].total_price).replace(".", ","))
|
||||||
|
|
Loading…
Reference in a new issue