mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-24 19:48:36 +02:00
Update csv_export.py
This commit is contained in:
parent
4013815a04
commit
958e010c5a
1 changed files with 19 additions and 0 deletions
|
@ -214,6 +214,25 @@ class BaseExport(ABC):
|
||||||
|
|
||||||
return cls.update_queryset(queryset, **kwargs)
|
return cls.update_queryset(queryset, **kwargs)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def export_data_to_csv(cls, csv_file, **kwargs):
|
||||||
|
"""
|
||||||
|
All domain metadata:
|
||||||
|
Exports domains of all statuses plus domain managers.
|
||||||
|
"""
|
||||||
|
writer = csv.writer(csv_file)
|
||||||
|
columns = cls.get_columns()
|
||||||
|
models_dict = cls.get_model_annotation_dict(**kwargs)
|
||||||
|
|
||||||
|
# Write to csv file before the write_csv
|
||||||
|
cls.write_csv_before(writer, **kwargs)
|
||||||
|
|
||||||
|
# Write the csv file
|
||||||
|
rows = cls.write_csv(writer, columns, models_dict)
|
||||||
|
|
||||||
|
# Return rows that for easier parsing and testing
|
||||||
|
return rows
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_annotated_queryset(cls, **kwargs):
|
def get_annotated_queryset(cls, **kwargs):
|
||||||
sort_fields = cls.get_sort_fields()
|
sort_fields = cls.get_sort_fields()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue