From 958e010c5a744e0fceeb6a0394b9c24b4e8a4c68 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Mon, 25 Nov 2024 15:36:43 -0700 Subject: [PATCH] Update csv_export.py --- src/registrar/utility/csv_export.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/registrar/utility/csv_export.py b/src/registrar/utility/csv_export.py index 916242682..ea56f9b27 100644 --- a/src/registrar/utility/csv_export.py +++ b/src/registrar/utility/csv_export.py @@ -214,6 +214,25 @@ class BaseExport(ABC): 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 def get_annotated_queryset(cls, **kwargs): sort_fields = cls.get_sort_fields()