mirror of
https://github.com/ZwareBear/awx.git
synced 2026-04-20 15:01:48 -05:00
Disallow DELETE on a notification_template
When there are pending notifications
This commit is contained in:
@@ -3487,6 +3487,15 @@ class NotificationTemplateDetail(RetrieveUpdateDestroyAPIView):
|
||||
serializer_class = NotificationTemplateSerializer
|
||||
new_in_300 = True
|
||||
|
||||
def delete(self, request, *args, **kwargs):
|
||||
obj = self.get_object()
|
||||
if not request.user.can_access(self.model, 'delete', obj):
|
||||
return Response(status=status.HTTP_404_NOT_FOUND)
|
||||
if obj.notifications.filter(status='pending').exists():
|
||||
return Response({"error": "Delete not allowed while there are pending notifications"},
|
||||
status=status.HTTP_405_METHOD_NOT_ALLOWED)
|
||||
return resp
|
||||
|
||||
class NotificationTemplateTest(GenericAPIView):
|
||||
|
||||
view_name = 'NotificationTemplate Test'
|
||||
|
||||
Reference in New Issue
Block a user