From 93a3b944d331490067b46810feaa58e422cd574e Mon Sep 17 00:00:00 2001 From: shagi Date: Tue, 4 Jan 2022 09:29:29 +0100 Subject: [PATCH] 'show_deleted_objects' boolean attribute in GASDeleteView --- gas/templates/gas/delete_confirmation.html | 18 ++++++++++-------- gas/views.py | 7 ++++++- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/gas/templates/gas/delete_confirmation.html b/gas/templates/gas/delete_confirmation.html index 34c9804..3bbe78c 100644 --- a/gas/templates/gas/delete_confirmation.html +++ b/gas/templates/gas/delete_confirmation.html @@ -7,14 +7,16 @@ {% block content %}

{{ confirmation_text }}

-

{% trans "Summary" %}

- -

{% trans "Objects" %}

- + {% if show_deleted_objects %} +

{% trans "Summary" %}

+ +

{% trans "Objects" %}

+ + {% endif %}
{% csrf_token %} diff --git a/gas/views.py b/gas/views.py index 86c563b..ace0295 100644 --- a/gas/views.py +++ b/gas/views.py @@ -217,6 +217,7 @@ class GASDeleteView(GASMixin, DeleteView): template_name = "gas/delete_confirmation.html" confirmation_text = _("Are you sure you want to delete {object}?") deleted_text = _("{object} deleted.") + show_deleted_objects = True def get_confirmation_text(self): return self.confirmation_text.format(object=self.object) @@ -239,11 +240,15 @@ class GASDeleteView(GASMixin, DeleteView): def get_context_data(self, **kwargs): ctx = super().get_context_data(**kwargs) - deleted_objects, deleted_model_count = self.get_deleted_objects() + if self.show_deleted_objects: + deleted_objects, deleted_model_count = self.get_deleted_objects() + else: + deleted_objects = deleted_model_count = None ctx.update({ 'confirmation_text': self.get_confirmation_text(), 'cancel_url': self.get_success_url(), + 'show_deleted_objects': self.show_deleted_objects, 'deleted_objects': deleted_objects, 'deleted_model_count': deleted_model_count, })