Updating startpanel for pluggables
'run_tests.sh -m startpanel <name>' command for creating new panels still requires specifying the dashboard with the '--dashboard=<dash-python-path>' otherwise it fails. With the new mechanism for plugging in extensions, this should no longer be a requirement as the handling of the enabled file will do the registration. It is still a valid option for integrated content generation though. Closes-Bug: #1410025 Change-Id: Ibaaa6c4d36defeae420919d0ea647e18127afefb
This commit is contained in:
parent
ee711e5c11
commit
2aecf4470b
@ -117,7 +117,7 @@ Panels
|
||||
|
||||
To create a new panel, run the following::
|
||||
|
||||
./run_tests -m startpanel <panel_name> --dashboard=<dashboard_path>
|
||||
./run_tests -m startpanel <panel_name>
|
||||
|
||||
This will create a directory with the given panel name, and ``panel.py``
|
||||
module with the basic panel code filled in, and various other common
|
||||
@ -125,8 +125,10 @@ module with the basic panel code filled in, and various other common
|
||||
|
||||
Available options:
|
||||
|
||||
* ``-d``, ``--dashboard``: The dotted python path to your dashboard app (the module
|
||||
which containers the ``dashboard.py`` file.).
|
||||
* ``-d``, ``--dashboard``: The dotted python path to your dashboard app (the
|
||||
module which containers the ``dashboard.py`` file.). If not specified, the
|
||||
target dashboard should be specified in a pluggable settings file for the
|
||||
panel.
|
||||
* ``--target``: the directory in which the panel files should be created.
|
||||
If the value is ``auto`` the panel will be created as a new directory inside
|
||||
the dashboard module's directory structure. Default: A new directory within
|
||||
|
@ -1,3 +0,0 @@
|
||||
"""
|
||||
Stub file to work around django bug: https://code.djangoproject.com/ticket/7198
|
||||
"""
|
@ -1,13 +1,11 @@
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
import horizon
|
||||
|
||||
from {{ dash_path }} import dashboard
|
||||
|
||||
{% if dashboard %}from {{ dash_path }} import dashboard{% endif %}
|
||||
|
||||
class {{ panel_name|title }}(horizon.Panel):
|
||||
name = _("{{ panel_name|title }}")
|
||||
slug = "{{ panel_name|slugify }}"
|
||||
{% if dashboard %}
|
||||
|
||||
|
||||
dashboard.{{ dash_name|title }}.register({{ panel_name|title }})
|
||||
dashboard.{{ dash_name|title }}.register({{ panel_name|title }}){% endif %}
|
||||
|
@ -6,7 +6,7 @@
|
||||
[% include "horizon/common/_page_header.html" with title=_("{{ panel_name|title }}") %]
|
||||
[% endblock page_header %]
|
||||
|
||||
[% block {{ dash_name }}_main %]
|
||||
[% block main %]
|
||||
[% endblock %]
|
||||
|
||||
{% endjstemplate %}
|
||||
|
@ -50,25 +50,21 @@ class Command(TemplateCommand):
|
||||
if panel_name is None:
|
||||
raise CommandError("You must provide a panel name.")
|
||||
|
||||
if options.get('dashboard') is None:
|
||||
raise CommandError("You must specify the name of the dashboard "
|
||||
"this panel will be registered with using the "
|
||||
"-d or --dashboard option.")
|
||||
|
||||
dashboard_path = options.get('dashboard')
|
||||
dashboard_mod_path = ".".join([dashboard_path, "dashboard"])
|
||||
if options.get('dashboard'):
|
||||
dashboard_path = options.get('dashboard')
|
||||
dashboard_mod_path = ".".join([dashboard_path, "dashboard"])
|
||||
|
||||
# Check the dashboard.py file in the dashboard app can be imported.
|
||||
# Add the dashboard information to our options to pass along if all
|
||||
# goes well.
|
||||
try:
|
||||
dashboard_mod = import_module(dashboard_mod_path)
|
||||
options["dash_path"] = dashboard_path
|
||||
options["dash_name"] = dashboard_path.split(".")[-1]
|
||||
except ImportError:
|
||||
raise CommandError("A dashboard.py module could not be imported "
|
||||
" from the dashboard at %r."
|
||||
% options.get("dashboard"))
|
||||
try:
|
||||
dashboard_mod = import_module(dashboard_mod_path)
|
||||
options["dash_path"] = dashboard_path
|
||||
options["dash_name"] = dashboard_path.split(".")[-1]
|
||||
except ImportError:
|
||||
raise CommandError("A dashboard.py module could not be "
|
||||
"imported from the dashboard at %r."
|
||||
% options.get("dashboard"))
|
||||
|
||||
target = options.pop("target", None)
|
||||
if target == "auto":
|
||||
|
Loading…
Reference in New Issue
Block a user