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:
0
horizon/conf/__init__.py
Normal file
0
horizon/conf/__init__.py
Normal file
0
horizon/conf/dash_template/__init__.py
Normal file
0
horizon/conf/dash_template/__init__.py
Normal file
13
horizon/conf/dash_template/dashboard.py
Normal file
13
horizon/conf/dash_template/dashboard.py
Normal 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 }})
|
||||
3
horizon/conf/dash_template/models.py
Normal file
3
horizon/conf/dash_template/models.py
Normal file
@@ -0,0 +1,3 @@
|
||||
"""
|
||||
Stub file to work around django bug: https://code.djangoproject.com/ticket/7198
|
||||
"""
|
||||
@@ -0,0 +1 @@
|
||||
/* Additional CSS for {{ dash_name }}. */
|
||||
@@ -0,0 +1 @@
|
||||
/* Additional JavaScript for {{ dash_name }}. */
|
||||
11
horizon/conf/dash_template/templates/dash_name/base.html
Normal file
11
horizon/conf/dash_template/templates/dash_name/base.html
Normal 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 %}
|
||||
0
horizon/conf/panel_template/__init__.py
Normal file
0
horizon/conf/panel_template/__init__.py
Normal file
3
horizon/conf/panel_template/models.py
Normal file
3
horizon/conf/panel_template/models.py
Normal file
@@ -0,0 +1,3 @@
|
||||
"""
|
||||
Stub file to work around django bug: https://code.djangoproject.com/ticket/7198
|
||||
"""
|
||||
13
horizon/conf/panel_template/panel.py
Normal file
13
horizon/conf/panel_template/panel.py
Normal 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 }})
|
||||
12
horizon/conf/panel_template/templates/panel_name/index.html
Normal file
12
horizon/conf/panel_template/templates/panel_name/index.html
Normal 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 %}
|
||||
7
horizon/conf/panel_template/tests.py
Normal file
7
horizon/conf/panel_template/tests.py
Normal 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)
|
||||
7
horizon/conf/panel_template/urls.py
Normal file
7
horizon/conf/panel_template/urls.py
Normal 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'),
|
||||
)
|
||||
10
horizon/conf/panel_template/views.py
Normal file
10
horizon/conf/panel_template/views.py
Normal 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
|
||||
Reference in New Issue
Block a user