Skip to content

Commit

Permalink
Panel message reflect if only one object deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
zediious committed Jul 14, 2024
1 parent 7f0190c commit ef24d43
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions raptorWeb/panel/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,8 +646,13 @@ def post(self, request: HttpRequest, *args: tuple, **kwargs: dict) -> HttpRespon
deleting_objects = self.model.objects.filter(pk__in=form_data.keys())

changed_string: str = ''
for model in deleting_objects:
changed_string += f'{model}, '
deleting_objects_count = deleting_objects.count()
if deleting_objects_count > 1:
for model in deleting_objects:
changed_string += f'{model}, '

else:
changed_string += f'{deleting_objects[0]}'

if changed_string == '':
messages.error(request, 'There were no objects to delete!')
Expand All @@ -660,7 +665,11 @@ def post(self, request: HttpRequest, *args: tuple, **kwargs: dict) -> HttpRespon
action='Deleted'
)

messages.success(request, f'{model_string}s: {changed_string[:-2]} have been permanently deleted!')
if deleting_objects_count > 1:
messages.success(request, f'{model_string}s: {changed_string[:-2]} have been permanently deleted!')
else:
messages.success(request, f'{model_string}: {changed_string[:-2]} has been permanently deleted!')

return HttpResponseRedirect(self.redirect_url)


Expand Down

0 comments on commit ef24d43

Please sign in to comment.