Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
pauloxnet committed Apr 10, 2017
2 parents 7581b56 + 7498f9d commit 1521731
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 25 deletions.
13 changes: 10 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Documentation
Check out the docs_ for more complete examples.


Compatability
Compatibility
-------------

.. image:: https://travis-ci.org/byashimov/django-controlcenter.svg?branch=master
Expand All @@ -100,15 +100,22 @@ This project uses Chartist.js_, Masonry.js_ and Sortable.js_.
Changelog
---------

Only worthy changes are listed in here.
0.2.3
~~~~~
- Updated column grid, thanks to @pauloxnet.
- Grammar fixes, thanks to @danielquinn.
- It's should be possible now to use a custom dashboard view with a custom template.

0.2.2
~~~~~
- ``dashboard.html`` now extends ``admin/base_site.html`` instead of ``admin/base.html`` in order to display *branding* block
- ``dashboard.html`` now extends ``admin/base_site.html`` instead of ``admin/base.html``
in order to display *branding* block. Thanks to @chadgh.
- Updated ``jsonify`` tag filter, thanks to @k8n.

0.2.1
~~~~~
- Django 1.10 support. Tested in tox *only*.
- Updated the SingleBarChart example, thanks to @greeve.

0.2.0
~~~~~
Expand Down
40 changes: 21 additions & 19 deletions controlcenter/views.py
Original file line number Diff line number Diff line change
@@ -1,42 +1,43 @@
from importlib import import_module

from django.conf.urls import url
from django.contrib import admin
from django.contrib.admin.views.decorators import staff_member_required
from django.core.exceptions import ImproperlyConfigured
from django.http import Http404
from django.utils.decorators import method_decorator
from django.utils.module_loading import import_string
from django.views.generic.base import TemplateView

from . import app_settings


class ControlCenter(object):
def get_urls(self):
self.dashboards = []
for index, path in enumerate(app_settings.DASHBOARDS):
pkg, name = path.rsplit('.', 1)
klass = getattr(import_module(pkg), name)
instance = klass(index)
self.dashboards.append(instance)
def __init__(self, view_class):
self.view_class = view_class

def get_dashboards(self):
klasses = map(import_string, app_settings.DASHBOARDS)
dashboards = [klass(pk=pk) for pk, klass in enumerate(klasses)]
if not dashboards:
raise ImproperlyConfigured('No dashboards found.')
return dashboards

def get_view(self):
dashboards = self.get_dashboards()
return self.view_class.as_view(dashboards=dashboards)

if not self.dashboards:
raise ImproperlyConfigured('No dashboard found in '
'settings.CONTROLCENTER_DASHBOARDS.')
def get_urls(self):
urlpatterns = [
url(r'^(?P<pk>\d+)/$', dashboard_view, name='dashboard'),
url(r'^(?P<pk>\d+)/$', self.get_view(), name='dashboard'),
]
return urlpatterns

@property
def urls(self):
# include(arg, namespace=None, app_name=None)
return self.get_urls(), 'controlcenter', 'controlcenter'

controlcenter = ControlCenter()


class DashboardView(TemplateView):
dashboards = NotImplemented
template_name = 'controlcenter/dashboard.html'

@method_decorator(staff_member_required)
Expand All @@ -46,7 +47,7 @@ def dispatch(self, *args, **kwargs):
def get(self, request, *args, **kwargs):
pk = int(self.kwargs['pk'])
try:
self.dashboard = controlcenter.dashboards[pk]
self.dashboard = self.dashboards[pk]
except IndexError:
raise Http404('Dashboard not found.')
return super(DashboardView, self).get(request, *args, **kwargs)
Expand All @@ -55,7 +56,7 @@ def get_context_data(self, **kwargs):
context = {
'title': self.dashboard.title,
'dashboard': self.dashboard,
'dashboards': controlcenter.dashboards,
'dashboards': self.dashboards,
'groups': self.dashboard.get_widgets(self.request),
'sharp': app_settings.SHARP,
}
Expand All @@ -65,4 +66,5 @@ def get_context_data(self, **kwargs):
kwargs.update(context)
return super(DashboardView, self).get_context_data(**kwargs)

dashboard_view = DashboardView.as_view()

controlcenter = ControlCenter(view_class=DashboardView)
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
project = 'django-controlcenter'
copyright = ('{}, Django-controlcenter developers and contributors'
.format(datetime.date.today().year))
version = '0.2.0'
release = '0.2.0'
version = '0.2.3'
release = '0.2.3'
exclude_patterns = ['_build']
pygments_style = 'sphinx'
html_theme = 'default'
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='django-controlcenter',
version='0.2.2',
version='0.2.3',
description='Set of widgets to build dashboards for your Django-project.',
long_description='',
url='https://github.com/byashimov/django-controlcenter',
Expand Down

0 comments on commit 1521731

Please sign in to comment.