From 02be232c71a52054301457c24b60d9012ad67382 Mon Sep 17 00:00:00 2001 From: Kelvin Muchiri Date: Wed, 27 Nov 2024 09:20:50 +0300 Subject: [PATCH] soft-delete XForm deleted from the admin detail page soft-delete XForm deleted from the admin detail page using the Delete button --- onadata/apps/logger/admin.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/onadata/apps/logger/admin.py b/onadata/apps/logger/admin.py index 085e0f63e7..33b80d04cf 100644 --- a/onadata/apps/logger/admin.py +++ b/onadata/apps/logger/admin.py @@ -76,6 +76,15 @@ def delete_queryset(self, request, queryset): level=messages.SUCCESS, ) + def delete_model(self, request, obj): + """ + Override delete_model to perform soft deletion on a single XForm. + """ + obj.soft_delete(user=request.user) + self.message_user( + request, _("The XForm has been soft-deleted."), level=messages.SUCCESS + ) + admin.site.register(XForm, XFormAdmin)