Skip to content

Commit

Permalink
Merge pull request ansible#1159 from AlanCoding/reschedule_msg
Browse files Browse the repository at this point in the history
Verbose error messages for failure to re-schedule
  • Loading branch information
AlanCoding committed Feb 8, 2018
2 parents 9bc0a07 + 87b5990 commit 181399d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions awx/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

# Django
from django.conf import settings
from django.core.exceptions import FieldError
from django.core.exceptions import FieldError, ObjectDoesNotExist
from django.db.models import Q, Count, F
from django.db import IntegrityError, transaction
from django.shortcuts import get_object_or_404
Expand Down Expand Up @@ -4204,7 +4204,15 @@ def post(self, request, *args, **kwargs):
obj = self.get_object()

if not obj.can_schedule:
return Response({"error": _('Information needed to schedule this job is missing.')},
if getattr(obj, 'passwords_needed_to_start', None):
return Response({"error": _('Cannot create schedule because job requires credential passwords.')},
status=status.HTTP_400_BAD_REQUEST)
try:
obj.launch_config
except ObjectDoesNotExist:
return Response({"error": _('Cannot create schedule because job was launched by legacy method.')},
status=status.HTTP_400_BAD_REQUEST)
return Response({"error": _('Cannot create schedule because a related resource is missing.')},
status=status.HTTP_400_BAD_REQUEST)

config = obj.launch_config
Expand Down

0 comments on commit 181399d

Please sign in to comment.