Merge "Use template filter to convert list of packages in the template"
This commit is contained in:
commit
d8d76e4489
@ -12,8 +12,6 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import json
|
|
||||||
|
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django import http as django_http
|
from django import http as django_http
|
||||||
from django import shortcuts
|
from django import shortcuts
|
||||||
@ -493,7 +491,7 @@ class ServicesTable(tables.DataTable):
|
|||||||
packages, self._more = pkg_api.package_list(
|
packages, self._more = pkg_api.package_list(
|
||||||
self.request,
|
self.request,
|
||||||
filters={'type': 'Application', 'catalog': True})
|
filters={'type': 'Application', 'catalog': True})
|
||||||
return json.dumps([package.to_dict() for package in packages])
|
return [package.to_dict() for package in packages]
|
||||||
|
|
||||||
def actions_allowed(self):
|
def actions_allowed(self):
|
||||||
status, version = _get_environment_status_and_version(
|
status, version = _get_environment_status_and_version(
|
||||||
|
@ -1,15 +1,10 @@
|
|||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% load custom_filters %}
|
{% load custom_filters %}
|
||||||
|
{% load jsonify %}
|
||||||
|
|
||||||
{% block table_caption %}
|
{% block table_caption %}
|
||||||
{% with apps=table.get_apps_list %}
|
{% with apps=table.get_apps_list %}
|
||||||
{% comment %}
|
{% if apps %}
|
||||||
Note(efedorova): We are comparing to the string, since get_apps_list
|
|
||||||
functions returns json.dumps, which is used in js later.
|
|
||||||
So to prevent extra transformations comparing to the string is used
|
|
||||||
to check for app absence.
|
|
||||||
{% endcomment %}
|
|
||||||
{% if apps != '[]' %}
|
|
||||||
<div class="col-xs-5">
|
<div class="col-xs-5">
|
||||||
<h3 class="table_title extra_title table_title">
|
<h3 class="table_title extra_title table_title">
|
||||||
{% trans "Application Components" %}</h3>
|
{% trans "Application Components" %}</h3>
|
||||||
@ -79,7 +74,7 @@
|
|||||||
{% trans "There are no applications matching your criteria." %}</p>
|
{% trans "There are no applications matching your criteria." %}</p>
|
||||||
<div id="apps_carousel" class="carousel">
|
<div id="apps_carousel" class="carousel">
|
||||||
<input type="hidden" id="apps_carousel_contents"
|
<input type="hidden" id="apps_carousel_contents"
|
||||||
value="{{ apps }}">
|
value="{{ apps|jsonify }}">
|
||||||
|
|
||||||
<div class="carousel-inner"></div>
|
<div class="carousel-inner"></div>
|
||||||
<a class="left carousel-control" ng-non-bindable href="#apps_carousel"
|
<a class="left carousel-control" ng-non-bindable href="#apps_carousel"
|
||||||
|
23
muranodashboard/templatetags/jsonify.py
Normal file
23
muranodashboard/templatetags/jsonify.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# Copyright (c) 2016 Mirantis, Inc.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
from django import template
|
||||||
|
import json
|
||||||
|
|
||||||
|
register = template.Library()
|
||||||
|
|
||||||
|
|
||||||
|
@register.filter(name='jsonify')
|
||||||
|
def jsonify(value):
|
||||||
|
return json.dumps(value)
|
Loading…
Reference in New Issue
Block a user