From a1b09f65c97a8e0dd5ccf65e1ce8e52f9bc0ad19 Mon Sep 17 00:00:00 2001 From: Karl Hobley Date: Thu, 19 Mar 2020 11:55:59 +0000 Subject: [PATCH] Rename export_heading_overrides to export_headings --- docs/advanced_topics/adding_reports.rst | 8 ++++---- wagtail/admin/views/reports.py | 6 +++--- wagtail/contrib/forms/views.py | 2 +- wagtail/contrib/modeladmin/views.py | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/advanced_topics/adding_reports.rst b/docs/advanced_topics/adding_reports.rst index 6bb601183f..e035fab8a0 100644 --- a/docs/advanced_topics/adding_reports.rst +++ b/docs/advanced_topics/adding_reports.rst @@ -77,16 +77,16 @@ For our example, we might want to know when the page was last published, so we'l ``list_export = ReportView.list_export + ['last_published_at']`` -.. attribute:: export_heading_overrides +.. attribute:: export_headings (dictionary) A dictionary of any fields/attributes in ``list_export`` for which you wish to manually specify a heading for the spreadsheet column, and their headings. If unspecified, the heading will be taken from the field ``verbose_name`` if applicable, and the attribute string otherwise. For our example, ``last_published_at`` will automatically get a heading of ``"Last Published At"``, -but a simple "Last Published" looks neater. We'll add that by setting ``export_heading_overrides``: +but a simple "Last Published" looks neater. We'll add that by setting ``export_headings``: -``export_heading_overrides = dict(last_published_at='Last Published', **ReportView.export_heading_overrides)`` +``export_headings = dict(last_published_at='Last Published', **ReportView.export_headings)`` .. attribute:: custom_value_preprocess @@ -197,7 +197,7 @@ The full code title = "Pages with unpublished changes" list_export = ReportView.list_export + ['last_published_at'] - export_heading_overrides = dict(last_published_at='Last Published', **ReportView.export_heading_overrides) + export_headings = dict(last_published_at='Last Published', **ReportView.export_headings) def get_queryset(self): return Page.objects.filter(has_unpublished_changes=True) diff --git a/wagtail/admin/views/reports.py b/wagtail/admin/views/reports.py index e7365f1df3..200728379f 100644 --- a/wagtail/admin/views/reports.py +++ b/wagtail/admin/views/reports.py @@ -44,7 +44,7 @@ class SpreadsheetExportMixin: list: {FORMAT_CSV: list_to_str, FORMAT_XLSX: list_to_str}, } # A dictionary of column heading overrides in the format {field: heading} - export_heading_overrides = {} + export_headings = {} def get_filename(self): """ Gets the base filename for the exported spreadsheet, without extensions """ @@ -111,7 +111,7 @@ class SpreadsheetExportMixin: def get_heading(self, queryset, field): """ Get the heading label for a given field for a spreadsheet generated from queryset """ - heading_override = self.export_heading_overrides.get(field) + heading_override = self.export_headings.get(field) if heading_override: return force_str(heading_override) try: @@ -186,7 +186,7 @@ class ReportView(SpreadsheetExportMixin, TemplateResponseMixin, BaseListView): template_name = "wagtailadmin/reports/base_report.html" title = "" paginate_by = 10 - export_heading_overrides = { + export_headings = { "latest_revision_created_at": _("Updated"), "status_string": _("Status"), "content_type.model_class._meta.verbose_name.title": _("Type"), diff --git a/wagtail/contrib/forms/views.py b/wagtail/contrib/forms/views.py index 5487cd8873..1067bddc99 100644 --- a/wagtail/contrib/forms/views.py +++ b/wagtail/contrib/forms/views.py @@ -155,7 +155,7 @@ class SubmissionsListView(SpreadsheetExportMixin, SafePaginateListView): data_fields = self.form_page.get_data_fields() # Set the export fields and the headings for spreadsheet export self.list_export = [field for field, label in data_fields] - self.export_heading_overrides = dict(data_fields) + self.export_headings = dict(data_fields) return super().dispatch(request, *args, **kwargs) diff --git a/wagtail/contrib/modeladmin/views.py b/wagtail/contrib/modeladmin/views.py index 07cdd46451..64e2e6be94 100644 --- a/wagtail/contrib/modeladmin/views.py +++ b/wagtail/contrib/modeladmin/views.py @@ -267,7 +267,7 @@ class IndexView(SpreadsheetExportMixin, WMABaseView): def get_heading(self, queryset, field): """ Get headings for exported spreadsheet column for the relevant field """ - heading_override = self.export_heading_overrides.get(field) + heading_override = self.export_headings.get(field) if heading_override: return force_str(heading_override) return force_str(label_for_field(field, model=self.model).title())