kopia lustrzana https://github.com/wagtail/wagtail
Move header_more_buttons for export buttons to SpreadsheetExportMixin
Also remove the unnecessary call to get_header_more_buttons in WagtailAdminTemplateMixin, as the buttons are already constructed as part of get_header_buttons()pull/10998/head
rodzic
af80198c7d
commit
1fbe6a64f5
|
@ -94,7 +94,6 @@ class WagtailAdminTemplateMixin(TemplateResponseMixin, ContextMixin):
|
|||
if self._show_breadcrumbs:
|
||||
context["breadcrumbs_items"] = self.get_breadcrumbs_items()
|
||||
context["header_buttons"] = self.get_header_buttons()
|
||||
context["header_more_buttons"] = self.get_header_more_buttons()
|
||||
return context
|
||||
|
||||
def get_template_names(self):
|
||||
|
|
|
@ -42,7 +42,6 @@ from wagtail.admin.ui.tables import (
|
|||
from wagtail.admin.utils import get_latest_str, get_valid_next_url_from_request
|
||||
from wagtail.admin.views.mixins import SpreadsheetExportMixin
|
||||
from wagtail.admin.widgets.button import (
|
||||
Button,
|
||||
ButtonWithDropdown,
|
||||
HeaderButton,
|
||||
ListingButton,
|
||||
|
@ -368,29 +367,6 @@ class IndexView(
|
|||
)
|
||||
return buttons
|
||||
|
||||
@cached_property
|
||||
def header_more_buttons(self):
|
||||
buttons = []
|
||||
if self.list_export:
|
||||
buttons.append(
|
||||
Button(
|
||||
_("Download XLSX"),
|
||||
url=self.xlsx_export_url,
|
||||
icon_name="download",
|
||||
priority=90,
|
||||
)
|
||||
)
|
||||
buttons.append(
|
||||
Button(
|
||||
_("Download CSV"),
|
||||
url=self.csv_export_url,
|
||||
icon_name="download",
|
||||
priority=100,
|
||||
)
|
||||
)
|
||||
|
||||
return buttons
|
||||
|
||||
def get_list_more_buttons(self, instance):
|
||||
buttons = []
|
||||
edit_url = self.get_edit_url(instance)
|
||||
|
|
|
@ -11,10 +11,13 @@ from django.utils import timezone
|
|||
from django.utils.dateformat import Formatter
|
||||
from django.utils.encoding import force_str
|
||||
from django.utils.formats import get_format
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.text import capfirst
|
||||
from django.utils.translation import gettext as _
|
||||
from openpyxl import Workbook
|
||||
from openpyxl.cell import WriteOnlyCell
|
||||
|
||||
from wagtail.admin.widgets.button import Button
|
||||
from wagtail.coreutils import multigetattr
|
||||
|
||||
|
||||
|
@ -301,3 +304,30 @@ class SpreadsheetExportMixin:
|
|||
@property
|
||||
def csv_export_url(self):
|
||||
return self.get_export_url("csv")
|
||||
|
||||
@cached_property
|
||||
def show_export_buttons(self):
|
||||
return bool(self.list_export)
|
||||
|
||||
@cached_property
|
||||
def header_more_buttons(self):
|
||||
buttons = super().header_more_buttons.copy()
|
||||
if self.show_export_buttons:
|
||||
buttons.append(
|
||||
Button(
|
||||
_("Download XLSX"),
|
||||
url=self.xlsx_export_url,
|
||||
icon_name="download",
|
||||
priority=90,
|
||||
)
|
||||
)
|
||||
buttons.append(
|
||||
Button(
|
||||
_("Download CSV"),
|
||||
url=self.csv_export_url,
|
||||
icon_name="download",
|
||||
priority=100,
|
||||
)
|
||||
)
|
||||
|
||||
return buttons
|
||||
|
|
Ładowanie…
Reference in New Issue