Skip to content

Commit

Permalink
[UPDT] HORILLA VIEWS: Permission in the GenericDeleteConfirmation
Browse files Browse the repository at this point in the history
  • Loading branch information
horilla-opensource committed Jan 30, 2025
1 parent af3fbcb commit cc45e33
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions horilla_views/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,8 +551,15 @@ def post(self, *args, **kwargs):

def delete_callback(instance, protected=False):
try:
instance.delete()
messages.success(self.request, f"Deleted {instance}")
if self.request.user.has_perm(
f"{instance._meta.app_label}.delete_{instance._meta.model.__name__.lower()}"
):
instance.delete()
messages.success(self.request, f"Deleted {instance}")
else:
messages.info(
self.request, f"You don't have permission to delete {instance}"
)
except:
messages.error(self.request, f"Cannot delete : {instance}")

Expand Down

0 comments on commit cc45e33

Please sign in to comment.