Skip to content

Commit

Permalink
Make generic/confirm_unpublish.html template extend generic/base.html…
Browse files Browse the repository at this point in the history
… template
  • Loading branch information
laymonage authored and gasman committed Dec 18, 2024
1 parent e63b42b commit faa37c0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 28 deletions.
46 changes: 21 additions & 25 deletions wagtail/admin/templates/wagtailadmin/generic/confirm_unpublish.html
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
{% extends "wagtailadmin/base.html" %}
{% extends "wagtailadmin/generic/base.html" %}
{% load i18n wagtailadmin_tags %}
{% block titletag %}{% blocktrans trimmed with title=object_display_title %}Unpublish {{ title }}{% endblocktrans %}{% endblock %}
{% block content %}
{% include "wagtailadmin/shared/header.html" with title=_("Unpublish") subtitle=object_display_title icon=header_icon %}

<div class="nice-padding">
{% if usage_url %}
{% include "wagtailadmin/shared/usage_summary.html" %}
{% endif %}
{% block confirmation_text %}
<p>
{% blocktrans trimmed with model_name=model_opts.verbose_name %}
Are you sure you want to unpublish this {{ model_name }}?
{% endblocktrans %}
</p>
{% endblock %}
{% block main_content %}
{% if usage_url %}
{% include "wagtailadmin/shared/usage_summary.html" %}
{% endif %}
{% block confirmation_text %}
<p>
{% blocktrans trimmed with model_name=model_opts.verbose_name %}
Are you sure you want to unpublish this {{ model_name }}?
{% endblocktrans %}
</p>
{% endblock %}

<form action="{{ unpublish_url }}" method="POST">
{% csrf_token %}
<form action="{{ unpublish_url }}" method="POST">
{% csrf_token %}

{% block form_content %}
{% endblock %}
{% block form_content %}
{% endblock %}

<div>
<button class="button" type="submit">{% trans 'Yes, unpublish it' %}</button>
<a href="{{ next_url }}" class="button button-secondary">{% trans "No, don't unpublish" %}</a>
</div>
</form>
</div>
<div>
<button class="button" type="submit">{% trans 'Yes, unpublish it' %}</button>
<a href="{{ next_url }}" class="button button-secondary">{% trans "No, don't unpublish" %}</a>
</div>
</form>
{% endblock %}
9 changes: 6 additions & 3 deletions wagtail/admin/views/generic/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1324,6 +1324,7 @@ class UnpublishView(HookResponseMixin, WagtailAdminTemplateMixin, TemplateView):
edit_url_name = None
unpublish_url_name = None
usage_url_name = None
page_title = gettext_lazy("Unpublish")
success_message = gettext_lazy("'%(object)s' unpublished.")
template_name = "wagtailadmin/generic/confirm_unpublish.html"

Expand All @@ -1344,12 +1345,15 @@ def get_object(self, queryset=None):
def get_usage(self):
return ReferenceIndex.get_grouped_references_to(self.object)

def get_breadcrumbs_items(self):
return []

def get_objects_to_unpublish(self):
# Hook to allow child classes to have more objects to unpublish (e.g. page descendants)
return [self.object]

def get_object_display_title(self):
return str(self.object)
def get_page_subtitle(self):
return get_latest_str(self.object)

def get_success_message(self):
if self.success_message is None:
Expand Down Expand Up @@ -1415,7 +1419,6 @@ def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["model_opts"] = self.object._meta
context["object"] = self.object
context["object_display_title"] = self.get_object_display_title()
context["unpublish_url"] = self.get_unpublish_url()
context["next_url"] = self.get_next_url()
context["usage_url"] = self.get_usage_url()
Expand Down

0 comments on commit faa37c0

Please sign in to comment.