Skip to content

Commit

Permalink
allow deleting NotificationTemplates w/ old pending notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanpetrello authored and kakawait committed Aug 5, 2022
1 parent 78fd49e commit 3ad63c3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion awx/api/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4253,7 +4253,9 @@ 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():

hours_old = now() - dateutil.relativedelta.relativedelta(hours=8)
if obj.notifications.filter(status='pending', created__gt=hours_old).exists():
return Response({"error": _("Delete not allowed while there are pending notifications")},
status=status.HTTP_405_METHOD_NOT_ALLOWED)
return super(NotificationTemplateDetail, self).delete(request, *args, **kwargs)
Expand Down

0 comments on commit 3ad63c3

Please sign in to comment.