Replace Task text field with drop-down list

Change-Id: I6b73bbff181dcae93aea435b8efa172b3bbebf57
This commit is contained in:
Kirill Izotov 2014-04-30 13:07:06 +07:00
parent 986d7623fb
commit 47e602eb31
3 changed files with 16 additions and 6 deletions

View File

@ -1,5 +1,6 @@
from django.utils.translation import ugettext_lazy as _
from django.core.urlresolvers import reverse
import yaml
from horizon import exceptions
from horizon import forms
@ -13,9 +14,9 @@ class ExecuteForm(forms.SelfHandlingForm):
required=True,
widget=forms.TextInput(
attrs={'readonly': 'readonly'}))
task = forms.CharField(label=_("Task"),
required=True,
help_text=_("Name of the task to stop"))
task = forms.ChoiceField(label=_("Task"),
required=True,
help_text=_("Task to start the execution"))
context = forms.CharField(label=_("Context"),
required=False,
initial="{}",
@ -23,6 +24,15 @@ class ExecuteForm(forms.SelfHandlingForm):
def __init__(self, request, *args, **kwargs):
super(ExecuteForm, self).__init__(request, *args, **kwargs)
client = api.mistralclient(request)
workbook_definition = client.workbooks.get_definition(
kwargs['initial']['workbook_name'])
workbook = yaml.safe_load(workbook_definition)
task_choices = [('', _("Select a task"))]
for task in workbook['Workflow']['tasks']:
task_choices.append((task, task))
self.fields['task'].choices = task_choices
def handle(self, request, data):
try:

View File

@ -1,8 +1,8 @@
from django.conf.urls import patterns # noqa
from django.conf.urls import url # noqa
from demo_dashboard.dashboards.mistral.workbooks.views \
import IndexView, ExecuteView
from demo_dashboard.dashboards.mistral.workbooks.views import IndexView
from demo_dashboard.dashboards.mistral.workbooks.views import ExecuteView
WORKBOOKS = r'^(?P<workbook_name>[^/]+)/%s$'

View File

@ -1,3 +1,3 @@
-e git+https://github.com/openstack/horizon.git#egg=horizon
# -e ../python-mistralclient
-e git+https://github.com/stackforge/python-mistralclient.git#egg=mistralclient
PyYAML>=3.1.0