Skip to content

Commit

Permalink
removed tabs module and aggregation stuff from tables, cleanup code, …
Browse files Browse the repository at this point in the history
…removed useless imports and added choices to manager, updated readme
  • Loading branch information
michaelkuty committed Aug 28, 2015
1 parent 324e1f6 commit c0f3ddc
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 240 deletions.
7 changes: 4 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ no implementation required, all Django stuff is generated automatically like an
- Rest API Dashboards

- APIModel
- Manager
- ClientBase - simple implementation which uses ``requests``
- Generic - Tables, Views, Actions

Expand All @@ -46,7 +47,7 @@ Manager has all responsibilty for get data from remote API. It`s simple object w
- Others

- ReactJS integration - for large tables with thousands rows we have integrated https://github.com/glittershark/reactable as ``ReactTable``
- tabs, templates (modal login, ...)
- LinkedListColumn
- set of common filters, templatetags

See [Documentation]_ !
Expand Down Expand Up @@ -210,6 +211,6 @@ Read more

.. |License badge| image:: http://img.shields.io/badge/license-Apache%202.0-green.svg?style=flat
.. |Doc badge| image:: https://readthedocs.org/projects/horizon-contrib/badge/?version=stable
.. |Pypi| image:: https://pypip.in/d/horizon-contrib/badge.svg?style=flat
.. |PypiVersion| image:: https://pypip.in/version/horizon-contrib/badge.svg?style=flat
.. |Pypi| image:: https://img.shields.io/pypi/dm/horizon-contrib.svg
.. |PypiVersion| image:: https://badge.fury.io/py/horizon-contrib.svg
.. [Documentation] http://horizon-contrib.readthedocs.org
2 changes: 1 addition & 1 deletion horizon_contrib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
__version__ = '0.0.1'
__author__ = 'Michael Kuty & Ales Komarek'
__license__ = 'Apache 2.0'
__copyright__ = 'Michael Kuty & Ales Komarek'
__copyright__ = 'Michael Kuty & Ales Komarek'
23 changes: 23 additions & 0 deletions horizon_contrib/api/managers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: UTF-8 -*-

import operator
from horizon_contrib.api.base import ClientBase


Expand Down Expand Up @@ -53,6 +54,28 @@ def list(self, request=None):
'GET',
request=request)

def choices(self, request, data=None, pk='id',
label='{hostname}', name='Host', empty=True):
'''make choices from data or self.list
data for making choices
label is string with item context
name is singular name of item
if you want create multiple choices use empty=False
'''
choices = []
if not data:
data = self.list(request)
for item in data:
choices.append((item[pk], label.format(**item)))
if choices:
choices.sort(key=operator.itemgetter(1))
if empty:
choices.insert(0, ("", "Select %s" % name))
else:
choices.insert(0, ("", "No %s available" % name))
return choices

# other common stuff

def order_by(self, *args, **kwargs):
Expand Down
1 change: 0 additions & 1 deletion horizon_contrib/common/content_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import logging
from django.conf import settings
from django.contrib.contenttypes.models import ContentType
from django.utils.translation import ugettext_lazy as _
from django.core import exceptions
from .model_registry import get_model

Expand Down
2 changes: 0 additions & 2 deletions horizon_contrib/forms/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import os

from django import http
from django.conf import settings
from django.core.urlresolvers import reverse, reverse_lazy
from django.forms import models as model_forms
from django.utils.translation import ugettext_lazy as _
from django.views import generic
Expand Down
1 change: 0 additions & 1 deletion horizon_contrib/generic/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from .views import GenericIndexView, DataView

urlpatterns = patterns('',
# forms
url(r'^models/(?P<cls_name>[\w\.\-]+)/create/$', CreateView.as_view(), name='create'),
url(r'^models/(?P<cls_name>[\w\.\-]+)/(?P<id>[\w\.\-]+)/update/$', UpdateView.as_view(), name='update'),
# tables
Expand Down
1 change: 0 additions & 1 deletion horizon_contrib/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import horizon
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_lazy as _

LOG = logging.getLogger(__name__)

Expand Down
114 changes: 0 additions & 114 deletions horizon_contrib/tables/aggregation.py

This file was deleted.

2 changes: 1 addition & 1 deletion horizon_contrib/tables/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ def filter_m2m(datum):
"""
items = []
for d in datum.all():
items.append(d.__unicode__())
items.append(str(d))
return ", ".join(items)
8 changes: 0 additions & 8 deletions horizon_contrib/tables/pagination.py

This file was deleted.

8 changes: 1 addition & 7 deletions horizon_contrib/tables/views.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
# -*- coding: UTF-8 -*-
from django import http, shortcuts
from django.conf import settings
from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator
from django.core.urlresolvers import reverse, reverse_lazy
from django.forms import models as model_forms
from django.utils.translation import ugettext_lazy as _
from horizon import forms, tables
from horizon_contrib.common import content_type as ct
from horizon import tables


class ContextMixin(object):
Expand Down
8 changes: 0 additions & 8 deletions horizon_contrib/tabs/__init__.py

This file was deleted.

93 changes: 0 additions & 93 deletions horizon_contrib/tabs/base.py

This file was deleted.

0 comments on commit c0f3ddc

Please sign in to comment.