Prevent job creation when no client is provided

Now is mandatory to select at least one client when creating a new job.
This will prevent the successful message to appear when no job was created.

Change-Id: Ic3197cae8a07753b160bc87a43c7bf84f00c474b
This commit is contained in:
memo 2015-10-06 10:29:10 +01:00 committed by Memo Garcia
parent 396e07584f
commit 79b5267846
1 changed files with 9 additions and 3 deletions

View File

@ -16,6 +16,7 @@ from django.utils.translation import ugettext_lazy as _
from horizon import exceptions
from horizon import forms
from horizon import messages
from horizon import workflows
import freezer_ui.api.api as freezer_api
@ -208,9 +209,14 @@ class ConfigureJob(workflows.Workflow):
context['job_actions'] = actions_for_job
for client in context['clients']:
context['client_id'] = client
freezer_api.job_create(request, context)
if context['clients']:
for client in context['clients']:
context['client_id'] = client
freezer_api.job_create(request, context)
else:
messages.warning(request, _("At least one client is "
"required to create a job"))
return False
else:
actions = actions_in_job(context.pop('actions', []))
actions_for_job = []