Hide package_counter in case of using glare

It is now impossible to display the correct number of packages in
each category using glare as a package storage, because glare
doesn't store this information. Therefore, it is better to just
hide counters from the user until package count will be implemented
in Glare.

Change-Id: I62487dbb12b1d104d293dcc499ded216982e0159
Related-bug: #1537070
This commit is contained in:
Valerii Kovalchuk 2016-03-30 16:50:30 +03:00
parent 4ebf7f56b6
commit 6ff16698c8
5 changed files with 28 additions and 4 deletions

View File

@ -599,6 +599,8 @@ class IndexView(list_view.ListView):
context['no_apps'] = True
if self.get_current_category() != ALL_CATEGORY_NAME or search:
context['no_apps'] = False
context['MURANO_USE_GLARE'] = getattr(settings, 'MURANO_USE_GLARE',
False)
return context

View File

@ -12,6 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from django.conf import settings
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ungettext_lazy
@ -51,6 +52,9 @@ class DeleteCategory(tables.DeleteAction):
)
def allowed(self, request, category=None):
use_artifacts = getattr(settings, 'MURANO_USE_GLARE', False)
if use_artifacts:
return category is not None
if category is not None:
if not category.package_count:
return True
@ -68,8 +72,10 @@ class DeleteCategory(tables.DeleteAction):
class CategoriesTable(tables.DataTable):
name = tables.Column('name', verbose_name=_('Category Name'))
package_count = tables.Column('package_count',
verbose_name=_('Package Count'))
use_artifacts = getattr(settings, 'MURANO_USE_GLARE', False)
if not use_artifacts:
package_count = tables.Column('package_count',
verbose_name=_('Package Count'))
class Meta(object):
name = 'categories'

View File

@ -15,6 +15,7 @@
from collections import OrderedDict
import json
from django.conf import settings
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_lazy as _
from horizon import exceptions
@ -219,6 +220,13 @@ class EnvironmentServicesTab(tabs.TableTab):
return services
def get_context_data(self, request, **kwargs):
context = super(EnvironmentServicesTab,
self).get_context_data(request, **kwargs)
context['MURANO_USE_GLARE'] = getattr(settings, 'MURANO_USE_GLARE',
False)
return context
class DeploymentTab(tabs.TableTab):
slug = "deployments"

View File

@ -48,7 +48,11 @@
{% for category in categories %}
<li class="clearfix">
<a tabindex="-1" href="{% url 'horizon:murano:catalog:index' %}?category={{ category.name|urlencode }}" class="btn btn-small">
{{ category.name }} ({{category.package_count}})</a>
{{ category.name }}
{% if not MURANO_USE_GLARE %}
({{category.package_count}})
{% endif %}
</a>
</li>
{% endfor %}
</ul>

View File

@ -39,7 +39,11 @@
<li role="presentation"><a
role="menuitem" tabindex="-1"
data-category-name="{{ category.name }}"
href="#">{{ category.name }} ({{category.package_count}})</a>
href="#">{{ category.name }}
{% if not MURANO_USE_GLARE %}
({{category.package_count}})
{% endif %}
</a>
</li>
{% endfor %}
</ul>