diff --git a/dataworkspace/dataworkspace/apps/datasets/models.py b/dataworkspace/dataworkspace/apps/datasets/models.py index 7b20819395..4c2e500b02 100644 --- a/dataworkspace/dataworkspace/apps/datasets/models.py +++ b/dataworkspace/dataworkspace/apps/datasets/models.py @@ -723,7 +723,11 @@ def source_reference(self): return None def get_filename(self, extension=".csv"): - filename = slugify(self.name) + extension # pylint: disable=no-member + sec_class = self.dataset.get_government_security_classification_display() + # pylint: disable=no-member + filename = ( + f"{slugify(self.name)}{f'-{sec_class}' if sec_class is not None else ''}{extension}" + ) if self.source_reference is not None: return f"{self.source_reference}-{filename}" return filename @@ -900,6 +904,10 @@ def get_pipeline_last_success_date(self): def pipeline_last_run_success(self): return self.get_pipeline_last_run_state() in ["success", None] + def get_custom_export_file_name(self): + sec_class = self.dataset.get_government_security_classification_display() + return f"{self.name}-custom-export{f'-{sec_class}' if sec_class is not None else ''}.csv" + class SourceTableFieldDefinition(models.Model): field = models.CharField( @@ -1016,7 +1024,6 @@ def get_filename(self): # pylint: disable=arguments-differ native_extension = os.path.splitext(self.url)[1] extension = native_extension if native_extension else ".csv" return super().get_filename(extension=extension) - return super().get_filename() @property @@ -1211,6 +1218,10 @@ def get_chart_builder_query(self): def get_save_grid_view_url(self): return reverse("datasets:custom_dataset_query_save_grid_view", args=(self.id,)) + def get_custom_export_file_name(self): + sec_class = self.dataset.get_government_security_classification_display() + return f"{self.name}-custom-export{f'-{sec_class}' if sec_class is not None else ''}.csv" + class CustomDatasetQueryTable(models.Model): query = models.ForeignKey(CustomDatasetQuery, on_delete=models.CASCADE, related_name="tables") @@ -2084,6 +2095,10 @@ def get_grid_data_url(self): def get_save_grid_view_url(self): return reverse("datasets:reference_dataset_save_grid_view", args=(self.id,)) + def get_custom_export_file_name(self): + sec_class = self.get_government_security_classification_display() + return f"{self.slug}-{self.published_version}-custom-export{f'-{sec_class}' if sec_class is not None else ''}.csv" + @receiver(m2m_changed, sender=ReferenceDataset.tags.through) def save_reference_dataset_tags_on_m2m_changed(instance, **_): diff --git a/dataworkspace/dataworkspace/templates/datasets/data-preview/data_cut_source_preview.html b/dataworkspace/dataworkspace/templates/datasets/data-preview/data_cut_source_preview.html index 12ebe7edea..df6a1ec701 100644 --- a/dataworkspace/dataworkspace/templates/datasets/data-preview/data_cut_source_preview.html +++ b/dataworkspace/dataworkspace/templates/datasets/data-preview/data_cut_source_preview.html @@ -19,7 +19,7 @@ '{{ object.get_grid_data_url }}', '?download=1', null, - '{{ object.name }}-custom-export.csv', + '{{ object.get_custom_export_file_name }}', {% flag CHART_BUILDER_BUILD_CHARTS_FLAG %} '{% url 'datasets:create_chart_from_grid' object.dataset.id object.id %}', {% else %} diff --git a/dataworkspace/dataworkspace/templates/datasets/data-preview/data_sourceset_preview.html b/dataworkspace/dataworkspace/templates/datasets/data-preview/data_sourceset_preview.html index ee74277006..477b27833a 100644 --- a/dataworkspace/dataworkspace/templates/datasets/data-preview/data_sourceset_preview.html +++ b/dataworkspace/dataworkspace/templates/datasets/data-preview/data_sourceset_preview.html @@ -19,7 +19,7 @@ '{{ object.get_grid_data_url }}', '?download=1', null, - '{{ object.name }}-custom-export.csv', + '{{ object.get_custom_export_file_name }}', {% flag CHART_BUILDER_BUILD_CHARTS_FLAG %} '{% url 'datasets:create_chart_from_grid' object.dataset.id object.id %}', {% else %} diff --git a/dataworkspace/dataworkspace/templates/datasets/data-preview/reference_dataset_preview.html b/dataworkspace/dataworkspace/templates/datasets/data-preview/reference_dataset_preview.html index 664da6aeab..1f41d1dbfd 100644 --- a/dataworkspace/dataworkspace/templates/datasets/data-preview/reference_dataset_preview.html +++ b/dataworkspace/dataworkspace/templates/datasets/data-preview/reference_dataset_preview.html @@ -19,7 +19,7 @@ null, null, JSON.parse(document.getElementById('grid_data').textContent), - '{{ model.slug }}-{{ model.published_version }}-custom-export.csv', + '{{ model.get_custom_export_file_name }}', null, '{{ model.send_post_data_url}}', '{{ model.id }}', diff --git a/dataworkspace/dataworkspace/templates/datasets/referencedataset_detail.html b/dataworkspace/dataworkspace/templates/datasets/referencedataset_detail.html index bd9dc43192..1b678f0b69 100644 --- a/dataworkspace/dataworkspace/templates/datasets/referencedataset_detail.html +++ b/dataworkspace/dataworkspace/templates/datasets/referencedataset_detail.html @@ -24,7 +24,7 @@ null, null, JSON.parse(document.getElementById('grid_data').textContent), - '{{ model.slug }}-{{ model.published_version }}-custom-export.csv', + '{{ model.get_custom_export_file_name }}', null, '{{ model.send_post_data_url}}', '{{ model.id }}',