Merge "Show workbook definition"
This commit is contained in:
commit
d9434fd3a0
@ -88,3 +88,12 @@ def workbook_list(request):
|
||||
"""Returns all workbooks."""
|
||||
|
||||
return mistralclient(request).workbooks.list()
|
||||
|
||||
|
||||
def workbook_get(request, workbook_name):
|
||||
"""Get specific workbook.
|
||||
|
||||
:param workbook_name: Workbook name
|
||||
"""
|
||||
|
||||
return mistralclient(request).workbooks.get(workbook_name)
|
||||
|
@ -25,7 +25,11 @@ def tags_to_string(workbook):
|
||||
|
||||
|
||||
class WorkbooksTable(tables.DataTable):
|
||||
name = tables.Column("name", verbose_name=_("Name"))
|
||||
name = tables.Column(
|
||||
"name",
|
||||
verbose_name=_("Name"),
|
||||
link="horizon:mistral:workbooks:detail"
|
||||
)
|
||||
tags = tables.Column(tags_to_string, verbose_name=_("Tags"))
|
||||
created = tables.Column(
|
||||
"created_at",
|
||||
|
13
mistraldashboard/workbooks/templates/workbooks/detail.html
Normal file
13
mistraldashboard/workbooks/templates/workbooks/detail.html
Normal file
@ -0,0 +1,13 @@
|
||||
{% extends 'base.html' %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Workbook Definition" %}{% endblock %}
|
||||
|
||||
{% block page_header %}
|
||||
{% include "horizon/common/_page_header.html" with title=_("Workbook Definition") %}
|
||||
{% endblock page_header %}
|
||||
|
||||
{% block main %}
|
||||
<div class="detail">
|
||||
<pre>{{ definition }}</pre>
|
||||
</div>
|
||||
{% endblock %}
|
@ -17,11 +17,12 @@
|
||||
from django.conf.urls import patterns # noqa
|
||||
from django.conf.urls import url # noqa
|
||||
|
||||
from mistraldashboard.workbooks.views import IndexView
|
||||
from mistraldashboard.workbooks import views
|
||||
|
||||
WORKBOOKS = r'^(?P<workbook_name>[^/]+)/%s$'
|
||||
|
||||
urlpatterns = patterns(
|
||||
'',
|
||||
url(r'^$', IndexView.as_view(), name='index'),
|
||||
url(r'^$', views.IndexView.as_view(), name='index'),
|
||||
url(WORKBOOKS % 'detail', views.DetailView.as_view(), name='detail'),
|
||||
)
|
||||
|
@ -14,6 +14,11 @@
|
||||
# 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
|
||||
@ -26,3 +31,26 @@ class IndexView(tables.DataTableView):
|
||||
|
||||
def get_data(self):
|
||||
return api.workbook_list(self.request)
|
||||
|
||||
|
||||
class DetailView(generic.TemplateView):
|
||||
template_name = 'mistral/workbooks/detail.html'
|
||||
page_title = _("Workbook Definition")
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(DetailView, self).get_context_data(**kwargs)
|
||||
workbook = self.get_data(self.request, **kwargs)
|
||||
context['definition'] = workbook.definition
|
||||
|
||||
return context
|
||||
|
||||
def get_data(self, request, **kwargs):
|
||||
try:
|
||||
workbook_name = kwargs['workbook_name']
|
||||
workbook = api.workbook_get(request, workbook_name)
|
||||
except Exception:
|
||||
msg = _('Unable to get workbook "%s".') % workbook_name
|
||||
redirect = reverse('horizon:mistral:workbooks:index')
|
||||
exceptions.handle(self.request, msg, redirect=redirect)
|
||||
|
||||
return workbook
|
||||
|
Loading…
x
Reference in New Issue
Block a user