mirror of
https://github.com/wagtail/wagtail.git
synced 2024-12-01 11:41:20 +01:00
Add link to history view in generic EditView
This commit is contained in:
parent
31694dc141
commit
d7e32c79cc
@ -577,6 +577,7 @@ class EditView(
|
||||
index_url_name = None
|
||||
edit_url_name = None
|
||||
delete_url_name = None
|
||||
history_url_name = None
|
||||
page_title = gettext_lazy("Editing")
|
||||
context_object_name = None
|
||||
template_name = "wagtailadmin/generic/edit.html"
|
||||
@ -635,6 +636,10 @@ class EditView(
|
||||
if self.delete_url_name:
|
||||
return reverse(self.delete_url_name, args=(quote(self.object.pk),))
|
||||
|
||||
def get_history_url(self):
|
||||
if self.history_url_name:
|
||||
return reverse(self.history_url_name, args=(quote(self.object.pk),))
|
||||
|
||||
def get_success_url(self):
|
||||
if not self.index_url_name:
|
||||
raise ImproperlyConfigured(
|
||||
@ -722,6 +727,7 @@ class EditView(
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context["action_url"] = self.get_edit_url()
|
||||
context["history_url"] = self.get_history_url()
|
||||
context["submit_button_label"] = self.submit_button_label
|
||||
context["can_delete"] = (
|
||||
self.permission_policy is None
|
||||
|
@ -288,7 +288,6 @@ class CreateView(generic.CreateEditViewOptionalFeaturesMixin, generic.CreateView
|
||||
|
||||
class EditView(generic.CreateEditViewOptionalFeaturesMixin, generic.EditView):
|
||||
view_name = "edit"
|
||||
history_url_name = None
|
||||
preview_url_name = None
|
||||
revisions_compare_url_name = None
|
||||
usage_url_name = None
|
||||
@ -302,9 +301,6 @@ class EditView(generic.CreateEditViewOptionalFeaturesMixin, generic.EditView):
|
||||
def run_after_hook(self):
|
||||
return self.run_hook("after_edit_snippet", self.request, self.object)
|
||||
|
||||
def get_history_url(self):
|
||||
return reverse(self.history_url_name, args=[quote(self.object.pk)])
|
||||
|
||||
def get_usage_url(self):
|
||||
return reverse(self.usage_url_name, args=[quote(self.object.pk)])
|
||||
|
||||
@ -356,7 +352,6 @@ class EditView(generic.CreateEditViewOptionalFeaturesMixin, generic.EditView):
|
||||
"model_opts": self.model._meta,
|
||||
"action_menu": action_menu,
|
||||
"side_panels": side_panels,
|
||||
"history_url": self.get_history_url(),
|
||||
"usage_url": self.get_usage_url(),
|
||||
"revisions_compare_url_name": self.revisions_compare_url_name,
|
||||
"media": media,
|
||||
|
Loading…
Reference in New Issue
Block a user