From f928ac885e46c90e00753bb5e998f1238de31ccf Mon Sep 17 00:00:00 2001 From: Renat Akhmerov Date: Sat, 27 Sep 2014 21:50:24 -0700 Subject: [PATCH] Making style changes and adding AUTHORS file Change-Id: I3238253e03d9f80975c65a3efc84bd202b338815 --- AUTHORS | 1 + mistraldashboard/api.py | 11 +++++--- mistraldashboard/executions/tables.py | 39 +++++++++++++++++---------- mistraldashboard/executions/views.py | 8 +++--- mistraldashboard/tasks/tables.py | 32 +++++++++++++--------- mistraldashboard/tasks/views.py | 3 +-- mistraldashboard/workflows/forms.py | 28 +++++++++++-------- mistraldashboard/workflows/tables.py | 2 +- mistraldashboard/workflows/views.py | 10 +++---- 9 files changed, 81 insertions(+), 53 deletions(-) diff --git a/AUTHORS b/AUTHORS index f6395be..7bb82f6 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,3 +1,4 @@ +Christian Berendt Kirill Izotov Nikolay Mahotkin Renat Akhmerov diff --git a/mistraldashboard/api.py b/mistraldashboard/api.py index 8d610db..410a949 100644 --- a/mistraldashboard/api.py +++ b/mistraldashboard/api.py @@ -31,7 +31,10 @@ def mistralclient(request): # additional troubles for those who still rely on v2.0 stack-wise. auth_url=getattr(settings, 'OPENSTACK_KEYSTONE_URL'), # Todo: add SECONDARY_ENDPOINT_TYPE support - endpoint_type=getattr(settings, - 'OPENSTACK_ENDPOINT_TYPE', - 'internalURL'), - service_type=SERVICE_TYPE) + endpoint_type=getattr( + settings, + 'OPENSTACK_ENDPOINT_TYPE', + 'internalURL' + ), + service_type=SERVICE_TYPE + ) diff --git a/mistraldashboard/executions/tables.py b/mistraldashboard/executions/tables.py index 7d75b23..b861c5e 100644 --- a/mistraldashboard/executions/tables.py +++ b/mistraldashboard/executions/tables.py @@ -24,24 +24,35 @@ from mistraldashboard.default.utils import prettyprint class ExecutionsTable(tables.DataTable): - id = tables.Column("id", verbose_name=_("ID"), - link="horizon:mistral:executions:tasks") + id = tables.Column( + "id", + verbose_name=_("ID"), + link="horizon:mistral:executions:tasks" + ) workflow_name = tables.Column("workflow_name", verbose_name=_("Workflow")) - input = tables.Column("input", - verbose_name=_("Input"), - filters=[prettyprint]) - output = tables.Column("output", - verbose_name=_("Output"), - filters=[prettyprint]) + input = tables.Column( + "input", + verbose_name=_("Input"), + filters=[prettyprint] + ) + output = tables.Column( + "output", + verbose_name=_("Output"), + filters=[prettyprint] + ) - created_at = tables.Column("created_at", - verbose_name=_("Created at"), - filters=[humantime]) - updated_at = tables.Column("updated_at", - verbose_name=_("Updated at"), - filters=[humantime]) + created_at = tables.Column( + "created_at", + verbose_name=_("Created at"), + filters=[humantime] + ) + updated_at = tables.Column( + "updated_at", + verbose_name=_("Updated at"), + filters=[humantime] + ) state = tables.Column("state", verbose_name=_("State"), filters=[label]) diff --git a/mistraldashboard/executions/views.py b/mistraldashboard/executions/views.py index 0450da6..fe5372e 100644 --- a/mistraldashboard/executions/views.py +++ b/mistraldashboard/executions/views.py @@ -26,8 +26,7 @@ class IndexView(tables.DataTableView): template_name = 'mistral/executions/index.html' def get_data(self): - client = api.mistralclient(self.request) - return client.executions.list() + return api.mistralclient(self.request).executions.list() class TaskView(tables.DataTableView): @@ -35,5 +34,6 @@ class TaskView(tables.DataTableView): template_name = 'mistral/executions/index.html' def get_data(self): - client = api.mistralclient(self.request) - return client.tasks.list(self.kwargs['execution_id']) + return api.mistralclient(self.request).tasks.list( + self.kwargs['execution_id'] + ) diff --git a/mistraldashboard/tasks/tables.py b/mistraldashboard/tasks/tables.py index 76233c7..71eda56 100644 --- a/mistraldashboard/tasks/tables.py +++ b/mistraldashboard/tasks/tables.py @@ -27,18 +27,26 @@ class TaskTable(tables.DataTable): id = tables.Column("id", verbose_name=_("ID")) name = tables.Column("name", verbose_name=_("Name")) - parameters = tables.Column("parameters", - verbose_name=_("Parameters"), - filters=[prettyprint]) - output = tables.Column("output", - verbose_name=_("Output"), - filters=[prettyprint]) - created_at = tables.Column("created_at", - verbose_name=_("Created at"), - filters=[humantime]) - updated_at = tables.Column("updated_at", - verbose_name=_("Updated at"), - filters=[humantime]) + parameters = tables.Column( + "parameters", + verbose_name=_("Parameters"), + filters=[prettyprint] + ) + output = tables.Column( + "output", + verbose_name=_("Output"), + filters=[prettyprint] + ) + created_at = tables.Column( + "created_at", + verbose_name=_("Created at"), + filters=[humantime] + ) + updated_at = tables.Column( + "updated_at", + verbose_name=_("Updated at"), + filters=[humantime] + ) state = tables.Column("state", verbose_name=_("State"), filters=[label]) diff --git a/mistraldashboard/tasks/views.py b/mistraldashboard/tasks/views.py index 9e67969..a4ec1d7 100644 --- a/mistraldashboard/tasks/views.py +++ b/mistraldashboard/tasks/views.py @@ -25,5 +25,4 @@ class IndexView(tables.DataTableView): template_name = 'mistral/tasks/index.html' def get_data(self): - client = api.mistralclient(self.request) - return client.tasks.list() + return api.mistralclient(self.request).tasks.list() diff --git a/mistraldashboard/workflows/forms.py b/mistraldashboard/workflows/forms.py index fe45fc3..e8e3e1b 100644 --- a/mistraldashboard/workflows/forms.py +++ b/mistraldashboard/workflows/forms.py @@ -25,17 +25,22 @@ from mistraldashboard import api class ExecuteForm(forms.SelfHandlingForm): - workflow_name = forms.CharField(label=_("Workflow"), - required=True, - widget=forms.TextInput( - attrs={'readonly': 'readonly'})) - workflow_input = forms.CharField(label=_("Input"), - required=False, - initial="{}", - widget=forms.widgets.Textarea()) - task_name = forms.CharField(label=_("Task name"), - required=False, - widget=forms.TextInput()) + workflow_name = forms.CharField( + label=_("Workflow"), + required=True, + widget=forms.TextInput(attrs={'readonly': 'readonly'}) + ) + workflow_input = forms.CharField( + label=_("Input"), + required=False, + initial="{}", + widget=forms.widgets.Textarea() + ) + task_name = forms.CharField( + label=_("Task name"), + required=False, + widget=forms.TextInput() + ) def handle(self, request, data): try: @@ -43,6 +48,7 @@ class ExecuteForm(forms.SelfHandlingForm): msg = _('Execution has been created with id "%s".') % ex.id messages.success(request, msg) + return True except Exception: msg = _('Failed to execute workflow "%s".') % data['workflow_name'] diff --git a/mistraldashboard/workflows/tables.py b/mistraldashboard/workflows/tables.py index 5c600b9..8049099 100644 --- a/mistraldashboard/workflows/tables.py +++ b/mistraldashboard/workflows/tables.py @@ -30,7 +30,7 @@ def tags_to_string(workflow): return ', '.join(workflow.tags) if workflow.tags else None -class WorkbooksTable(tables.DataTable): +class WorkflowsTable(tables.DataTable): name = tables.Column("name", verbose_name=_("Name")) description = tables.Column("description", verbose_name=_("Description")) tags = tables.Column(tags_to_string, verbose_name=_("Tags")) diff --git a/mistraldashboard/workflows/views.py b/mistraldashboard/workflows/views.py index 0b1ce75..921bd70 100644 --- a/mistraldashboard/workflows/views.py +++ b/mistraldashboard/workflows/views.py @@ -20,12 +20,12 @@ from horizon import tables from horizon import forms from mistraldashboard import api -from mistraldashboard.workflows.tables import WorkbooksTable +from mistraldashboard.workflows.tables import WorkflowsTable from mistraldashboard.workflows.forms import ExecuteForm class IndexView(tables.DataTableView): - table_class = WorkbooksTable + table_class = WorkflowsTable template_name = 'mistral/workflows/index.html' def get_data(self): @@ -39,10 +39,10 @@ class ExecuteView(forms.ModalFormView): def get_context_data(self, **kwargs): context = super(ExecuteView, self).get_context_data(**kwargs) + context["workflow_name"] = self.kwargs['workflow_name'] + return context def get_initial(self, **kwargs): - return { - 'workflow_name': self.kwargs['workflow_name'] - } + return {'workflow_name': self.kwargs['workflow_name']}