kopia lustrzana https://github.com/wagtail/wagtail
Make index_url_name and edit_url_name in generic HistoryView optional
Also update the generic UsageView's get_edit_url method signature to match the HistoryView and the generic IndexView by taking an "instance" parameter, just to be consistent even though we technically only use self.object for these views.pull/10998/head
rodzic
9cc0539c4c
commit
d461ed08bf
|
@ -226,21 +226,30 @@ class HistoryView(PermissionCheckedMixin, BaseObjectMixin, BaseListingView):
|
|||
return str(self.object)
|
||||
|
||||
def get_breadcrumbs_items(self):
|
||||
return self.breadcrumbs_items + [
|
||||
{
|
||||
"url": reverse(self.index_url_name),
|
||||
"label": capfirst(self.model._meta.verbose_name_plural),
|
||||
},
|
||||
{
|
||||
"url": self.get_edit_url(self.object),
|
||||
"label": str(self.object),
|
||||
},
|
||||
items = []
|
||||
if self.index_url_name:
|
||||
items.append(
|
||||
{
|
||||
"url": reverse(self.index_url_name),
|
||||
"label": capfirst(self.model._meta.verbose_name_plural),
|
||||
}
|
||||
)
|
||||
edit_url = self.get_edit_url(self.object)
|
||||
if edit_url:
|
||||
items.append(
|
||||
{
|
||||
"url": edit_url,
|
||||
"label": str(self.object),
|
||||
}
|
||||
)
|
||||
items.append(
|
||||
{
|
||||
"url": "",
|
||||
"label": gettext("History"),
|
||||
"sublabel": self.get_page_subtitle(),
|
||||
},
|
||||
]
|
||||
}
|
||||
)
|
||||
return self.breadcrumbs_items + items
|
||||
|
||||
@cached_property
|
||||
def header_buttons(self):
|
||||
|
|
|
@ -38,9 +38,9 @@ class UsageView(PermissionCheckedMixin, BaseObjectMixin, BaseListingView):
|
|||
return object.get_latest_revision_as_object()
|
||||
return object
|
||||
|
||||
def get_edit_url(self):
|
||||
def get_edit_url(self, instance):
|
||||
if self.edit_url_name:
|
||||
return reverse(self.edit_url_name, args=(quote(self.object.pk),))
|
||||
return reverse(self.edit_url_name, args=(quote(instance.pk),))
|
||||
|
||||
def get_usage_url(self, instance):
|
||||
if self.usage_url_name:
|
||||
|
@ -61,7 +61,7 @@ class UsageView(PermissionCheckedMixin, BaseObjectMixin, BaseListingView):
|
|||
"label": capfirst(self.object._meta.verbose_name_plural),
|
||||
}
|
||||
)
|
||||
edit_url = self.get_edit_url()
|
||||
edit_url = self.get_edit_url(self.object)
|
||||
if edit_url:
|
||||
items.append(
|
||||
{
|
||||
|
@ -80,7 +80,7 @@ class UsageView(PermissionCheckedMixin, BaseObjectMixin, BaseListingView):
|
|||
|
||||
@cached_property
|
||||
def header_buttons(self):
|
||||
edit_url = self.get_edit_url()
|
||||
edit_url = self.get_edit_url(self.object)
|
||||
buttons = []
|
||||
if edit_url:
|
||||
buttons.append(
|
||||
|
|
Ładowanie…
Reference in New Issue