Adds dash/panel app templates, mgmt commands, template loader.

Implements blueprint scaffolding.

Using custom management commands you can now create the majority
of the boilerplate code for a new dashboard or panel from a
set of basic templates with a single command. See the docs
for more info.

Additionally, in support of the new commands (and inherent
codified directory structure) there's a new template loader
included which can load templates from "templates" directories
in any registered panel.

Change-Id: I1df5eb152cb18694dc89d562799c8d3e8950ca6f
This commit is contained in:
Gabriel Hurley
2012-04-26 19:22:51 -07:00
parent 8396026722
commit 1721ba9c4a
27 changed files with 385 additions and 10 deletions

0
horizon/conf/__init__.py Normal file
View File

View File

View File

@@ -0,0 +1,13 @@
from django.utils.translation import ugettext_lazy as _
import horizon
class {{ dash_name|title }}(horizon.Dashboard):
name = _("{{ dash_name|title }}")
slug = "{{ dash_name|slugify }}"
panels = () # Add your panels here.
default_panel = '' # Specify the slug of the dashboard's default panel.
horizon.register({{ dash_name|title }})

View File

@@ -0,0 +1,3 @@
"""
Stub file to work around django bug: https://code.djangoproject.com/ticket/7198
"""

View File

@@ -0,0 +1 @@
/* Additional CSS for {{ dash_name }}. */

View File

@@ -0,0 +1 @@
/* Additional JavaScript for {{ dash_name }}. */

View File

@@ -0,0 +1,11 @@
{% load horizon %}{% jstemplate %}[% extends 'base.html' %]
[% block sidebar %]
[% include 'horizon/common/_sidebar.html' %]
[% endblock %]
[% block main %]
[% include "horizon/_messages.html" %]
[% block {{ dash_name }}_main %][% endblock %]
[% endblock %]
{% endjstemplate %}

View File

View File

@@ -0,0 +1,3 @@
"""
Stub file to work around django bug: https://code.djangoproject.com/ticket/7198
"""

View File

@@ -0,0 +1,13 @@
from django.utils.translation import ugettext_lazy as _
import horizon
from {{ dash_path }} import dashboard
class {{ panel_name|title }}(horizon.Panel):
name = _("{{ panel_name|title }}")
slug = "{{ panel_name|slugify }}"
dashboard.register({{ panel_name|title }})

View File

@@ -0,0 +1,12 @@
{% load horizon %}{% jstemplate %}[% extends '{{ dash_name }}/base.html' %]
[% load i18n %]
[% block title %][% trans "{{ panel_name|title }}" %][% endblock %]
[% block page_header %]
[% include "horizon/common/_page_header.html" with title=_("{{ panel_name|title }}") %]
[% endblock page_header %]
[% block {{ dash_name }}_main %]
[% endblock %]
{% endjstemplate %}

View File

@@ -0,0 +1,7 @@
from horizon import test
class {{ panel_name|title}}Tests(test.TestCase):
# Unit tests for {{ panel_name }}.
def test_me(self):
self.assertTrue(1 + 1 == 2)

View File

@@ -0,0 +1,7 @@
from django.conf.urls.defaults import patterns, url
from .views import IndexView
urlpatterns = patterns('',
url(r'^$', IndexView.as_view(), name='index'),
)

View File

@@ -0,0 +1,10 @@
from horizon import views
class IndexView(views.APIView):
# A very simple class-based view...
template_name = '{{ panel_name }}/index.html'
def get_data(self, request, context, *args, **kwargs):
# Add data to the context here...
return context