diff --git a/mistraldashboard/api.py b/mistraldashboard/api.py
index cb8280e..4fb7ef0 100644
--- a/mistraldashboard/api.py
+++ b/mistraldashboard/api.py
@@ -67,6 +67,15 @@ def task_list(request, execution_id=None):
return mistralclient(request).tasks.list(execution_id)
+def task_get(request, task_id=None):
+ """Get specific task.
+
+ :param task_id: Task ID
+ """
+
+ return mistralclient(request).tasks.get(task_id)
+
+
@handle_errors(_("Unable to retrieve workflows."), [])
def workflow_list(request):
"""Returns all workflows."""
diff --git a/mistraldashboard/tasks/tables.py b/mistraldashboard/tasks/tables.py
index 6d6ada5..b3c1fbd 100644
--- a/mistraldashboard/tasks/tables.py
+++ b/mistraldashboard/tasks/tables.py
@@ -24,7 +24,10 @@ from mistraldashboard.default.utils import prettyprint
class TaskTable(tables.DataTable):
- id = tables.Column("id", verbose_name=_("ID"))
+ id = tables.Column(
+ "id",
+ verbose_name=_("ID"),
+ link="horizon:mistral:tasks:result")
name = tables.Column("name", verbose_name=_("Name"))
parameters = tables.Column(
diff --git a/mistraldashboard/tasks/templates/tasks/result.html b/mistraldashboard/tasks/templates/tasks/result.html
new file mode 100644
index 0000000..719a730
--- /dev/null
+++ b/mistraldashboard/tasks/templates/tasks/result.html
@@ -0,0 +1,13 @@
+{% extends 'base.html' %}
+{% load i18n %}
+{% block title %}{% trans "Task Result" %}{% endblock %}
+
+{% block page_header %}
+ {% include "horizon/common/_page_header.html" with title=_("Task Result") %}
+{% endblock page_header %}
+
+{% block main %}
+
+{% endblock %}
diff --git a/mistraldashboard/tasks/urls.py b/mistraldashboard/tasks/urls.py
index 04cd970..7d250f7 100644
--- a/mistraldashboard/tasks/urls.py
+++ b/mistraldashboard/tasks/urls.py
@@ -17,9 +17,12 @@
from django.conf.urls import patterns # noqa
from django.conf.urls import url # noqa
-from mistraldashboard.tasks.views import IndexView
+from mistraldashboard.tasks import views
+
+TASKS = r'^(?P[^/]+)/%s$'
urlpatterns = patterns(
'',
- url(r'^$', IndexView.as_view(), name='index'),
+ url(r'^$', views.IndexView.as_view(), name='index'),
+ url(TASKS % 'result', views.ResultView.as_view(), name='result')
)
diff --git a/mistraldashboard/tasks/views.py b/mistraldashboard/tasks/views.py
index 1f683ea..9ff694e 100644
--- a/mistraldashboard/tasks/views.py
+++ b/mistraldashboard/tasks/views.py
@@ -14,12 +14,39 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+from django.core.urlresolvers import reverse
+from django.utils.translation import ugettext_lazy as _
+from django.views import generic
+
+from horizon import exceptions
from horizon import tables
from mistraldashboard import api
from mistraldashboard.tasks.tables import TaskTable
+class ResultView(generic.TemplateView):
+ template_name = 'mistral/tasks/result.html'
+ page_title = _("Task Result")
+
+ def get_context_data(self, **kwargs):
+ context = super(ResultView, self).get_context_data(**kwargs)
+ task = self.get_data(self.request, **kwargs)
+ context['result'] = task.result
+ return context
+
+ def get_data(self, request, **kwargs):
+ try:
+ task_id = kwargs['task_id']
+ task = api.task_get(request, task_id)
+ except Exception:
+ msg = _('Unable to get task "%s".') % task_id
+ redirect = reverse('horizon:mistral:tasks:index')
+ exceptions.handle(self.request, msg, redirect=redirect)
+
+ return task
+
+
class IndexView(tables.DataTableView):
table_class = TaskTable
template_name = 'mistral/tasks/index.html'