feat(import_export): customise l'export CSV pour quoter
- resoud le pb de 'tel_fixe' '0321...' qui devient '321...' - utilise le meme separateur que les autres export csv ';'pull/103/head
Parent
02b4609293
révision
e5326ee4e9
|
@ -4,6 +4,18 @@ from import_export.formats.base_formats import CSV
|
|||
from import_export.forms import export_action_form_factory
|
||||
|
||||
|
||||
class CSV_quoting(CSV):
|
||||
def export_data(self, dataset, **kwargs):
|
||||
kwargs['delimiter'] = ';'
|
||||
kwargs['quoting'] = 1
|
||||
return super().export_data(dataset, **kwargs)
|
||||
|
||||
def create_dataset(self, in_stream, **kwargs):
|
||||
kwargs['delimiter'] = ';'
|
||||
kwargs['quoting'] = 1
|
||||
return super().create_dataset(in_stream, **kwargs)
|
||||
|
||||
|
||||
class ResetFormMixin:
|
||||
"""
|
||||
remove empty choice for export format
|
||||
|
@ -43,14 +55,11 @@ class BasketBigFilterImportExportMixin(
|
|||
# 'import_export/action_formats.js',
|
||||
# ]
|
||||
change_list_template = "admin/import_export_basket/change_list_import.html"
|
||||
formats = [CSV]
|
||||
formats = [CSV_quoting]
|
||||
|
||||
|
||||
class BasketImportExportMixin(
|
||||
ImportMixin,
|
||||
ExportActionMixin,
|
||||
ResetFormMixin,
|
||||
basket.MixinBasketAdmin,
|
||||
ImportMixin, ExportActionMixin, ResetFormMixin, basket.MixinBasketAdmin
|
||||
):
|
||||
"""
|
||||
Merge of import_export.Import import_export.ExportAction + basket (template)
|
||||
|
@ -63,7 +72,7 @@ class BasketImportExportMixin(
|
|||
# 'import_export/action_formats.js',
|
||||
# ]
|
||||
change_list_template = "admin/import_export_basket/change_list_import.html"
|
||||
formats = [CSV]
|
||||
formats = [CSV_quoting]
|
||||
|
||||
|
||||
class ImportExportMixin(ImportMixin, ExportActionMixin, ResetFormMixin):
|
||||
|
@ -72,4 +81,4 @@ class ImportExportMixin(ImportMixin, ExportActionMixin, ResetFormMixin):
|
|||
+ minor customization
|
||||
"""
|
||||
|
||||
formats = [CSV]
|
||||
formats = [CSV_quoting]
|
||||
|
|
Chargement…
Référencer dans un nouveau ticket