mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-12 20:49:41 +02:00
cleanup
This commit is contained in:
parent
87a9655828
commit
d5f799347a
1 changed files with 19 additions and 19 deletions
|
@ -213,6 +213,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):
|
||||||
"""Returns an annotated queryset based off of all query conditions."""
|
"""Returns an annotated queryset based off of all query conditions."""
|
||||||
|
@ -243,25 +262,6 @@ class BaseExport(ABC):
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_model_annotation_dict(cls, **kwargs):
|
def get_model_annotation_dict(cls, **kwargs):
|
||||||
return convert_queryset_to_dict(cls.get_annotated_queryset(**kwargs), is_model=False)
|
return convert_queryset_to_dict(cls.get_annotated_queryset(**kwargs), is_model=False)
|
||||||
|
|
||||||
@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 write_csv(
|
def write_csv(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue