tuskar-ui/tuskar_ui/infrastructure/views.py
Ana Krivokapic f14da6cb4f Add counts to index pages
Add counts to index pages for Nodes, Images and Roles.

Change-Id: I8b52fe05fb9fc3dac9675cdddf8cc9750aa55ee8
2014-11-10 14:31:36 +01:00

24 lines
891 B
Python

# -*- coding: utf8 -*-
#
# 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.
class ItemCountMixin(object):
def get_items_count(self):
return len(self.get_data())
def get_context_data(self, **kwargs):
context = super(ItemCountMixin, self).get_context_data(**kwargs)
context['items_count'] = self.get_items_count()
return context