Replace Task text field with drop-down list
Change-Id: I6b73bbff181dcae93aea435b8efa172b3bbebf57
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
|
import yaml
|
||||||
|
|
||||||
from horizon import exceptions
|
from horizon import exceptions
|
||||||
from horizon import forms
|
from horizon import forms
|
||||||
@@ -13,9 +14,9 @@ class ExecuteForm(forms.SelfHandlingForm):
|
|||||||
required=True,
|
required=True,
|
||||||
widget=forms.TextInput(
|
widget=forms.TextInput(
|
||||||
attrs={'readonly': 'readonly'}))
|
attrs={'readonly': 'readonly'}))
|
||||||
task = forms.CharField(label=_("Task"),
|
task = forms.ChoiceField(label=_("Task"),
|
||||||
required=True,
|
required=True,
|
||||||
help_text=_("Name of the task to stop"))
|
help_text=_("Task to start the execution"))
|
||||||
context = forms.CharField(label=_("Context"),
|
context = forms.CharField(label=_("Context"),
|
||||||
required=False,
|
required=False,
|
||||||
initial="{}",
|
initial="{}",
|
||||||
@@ -23,6 +24,15 @@ class ExecuteForm(forms.SelfHandlingForm):
|
|||||||
|
|
||||||
def __init__(self, request, *args, **kwargs):
|
def __init__(self, request, *args, **kwargs):
|
||||||
super(ExecuteForm, self).__init__(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):
|
def handle(self, request, data):
|
||||||
try:
|
try:
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
from django.conf.urls import patterns # noqa
|
from django.conf.urls import patterns # noqa
|
||||||
from django.conf.urls import url # noqa
|
from django.conf.urls import url # noqa
|
||||||
|
|
||||||
from demo_dashboard.dashboards.mistral.workbooks.views \
|
from demo_dashboard.dashboards.mistral.workbooks.views import IndexView
|
||||||
import IndexView, ExecuteView
|
from demo_dashboard.dashboards.mistral.workbooks.views import ExecuteView
|
||||||
|
|
||||||
WORKBOOKS = r'^(?P<workbook_name>[^/]+)/%s$'
|
WORKBOOKS = r'^(?P<workbook_name>[^/]+)/%s$'
|
||||||
|
|
||||||
|
@@ -1,3 +1,3 @@
|
|||||||
-e git+https://github.com/openstack/horizon.git#egg=horizon
|
-e git+https://github.com/openstack/horizon.git#egg=horizon
|
||||||
# -e ../python-mistralclient
|
|
||||||
-e git+https://github.com/stackforge/python-mistralclient.git#egg=mistralclient
|
-e git+https://github.com/stackforge/python-mistralclient.git#egg=mistralclient
|
||||||
|
PyYAML>=3.1.0
|
Reference in New Issue
Block a user