Skip to content

Commit

Permalink
enhance XForm admin messages
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvin-muchiri committed Nov 27, 2024
1 parent a1b8313 commit d2215a8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions onadata/apps/logger/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class XFormAdmin(FilterByUserMixin, VersionAdmin, admin.ModelAdmin):
list_display = ("internal_id", "id_string", "project_id", "downloadable", "shared")
search_fields = ("id", "id_string", "title", "project__id", "project__name")
user_lookup_field = "user"
actions = ["restore_form"]
actions = ["restore_form", "delete_queryset", "delete_model"]

def internal_id(self, obj):
"""Display the internal ID."""
Expand Down Expand Up @@ -90,14 +90,16 @@ def delete_model(self, request, obj):
if obj.deleted_at is not None:
self.message_user(
request,
_("The XForm has already been soft-deleted."),
_(f"The XForm {obj.id_string} has already been soft-deleted."),
level=messages.WARNING,
)
return

obj.soft_delete(user=request.user)
self.message_user(
request, _("The XForm has been soft-deleted."), level=messages.SUCCESS
request,
_(f"The XForm {obj.id_string} has been soft-deleted successfully."),
level=messages.SUCCESS,
)


Expand Down

0 comments on commit d2215a8

Please sign in to comment.