Use module_name everywhere; module_folder is redundant

hyphen cannot be used as python module name,
so the default cookiecutter example does not work completely.

Once module_name is fixed, module_name and module_folder are
now always same and module_folder is now unnecessary.
Thus this commit also drops module_folder.

Change-Id: I28a5f7bd349d73627874e1466c72cc66e918f77b
This commit is contained in:
Akihiro Motoki 2017-05-26 15:42:10 +09:00
parent 3ac73d21cb
commit 9125836588
48 changed files with 29 additions and 31 deletions

View File

@ -29,13 +29,12 @@ Generate a Python package project::
This command prompts interactive input. Please check these parameters::
* "repo_group": The name for the git repo group. e.g. "openstack"
* "repo_name": The name for the git repo. e.g. "cafe-ui",
* "repo_name": The name for the git repo. e.g. "cafe-ui", This is used as python package name too.
* "launchpad_project": The name of the project on launchpad. e.g. "cafe-ui",
* "project_short_description": The short descriptions for your UI. e.g. "Cafe User Interface",
* "help_name": The name for the help. e.g. "Cafe-UI",
* "call_by_name": The name of this UI to write texts such as README or Help. e.g. "Cafe UI",
* "module_name": The name of the python module. e.g. "cafe-ui"
* "module_folder": The name for the module folder. e.g. "cafe_ui",
* "module_name": The name of the python module. e.g. "cafe_ui"
* "dashboard": The slug of the "dashboard" you want to add this plugin into. e.g. "project",
* "panel_group": The slug for the "panel_group". e.g. "cafe",
* "panel_group_name": The caption for the "panel_group". e.g. "Cafe",
@ -52,8 +51,8 @@ Run with OpenStack Horizon::
cd <repo_name>
pip install
cp <repo_name>/<module_folder>/enabled/_90_project_<panel_group>_panelgroup.py <horizon-dir>/openstack_dashboard/local/enabled
cp <repo_name>/<module_folder>/enabled/_91_project_<panel_group>_<panel>s.py <horizon-dir>/openstack_dashboard/local/enabled
cp <repo_name>/<module_name>/enabled/_90_project_<panel_group>_panelgroup.py <horizon-dir>/openstack_dashboard/local/enabled
cp <repo_name>/<module_name>/enabled/_91_project_<panel_group>_<panel>s.py <horizon-dir>/openstack_dashboard/local/enabled
then reboot the Horizon.

View File

@ -5,8 +5,7 @@
"project_short_description": "Cafe User Interface",
"help_name": "Cafe-UI",
"call_by_name": "Cafe UI",
"module_name": "cafe-ui",
"module_folder": "cafe_ui",
"module_name": "cafe_ui",
"dashboard": "project",
"panel_group": "cafe",
"panel_group_name": "Cafe",
@ -14,4 +13,4 @@
"panel_func": "Drink",
"api_module": "cafe",
"api_name": "Cafe"
}
}

View File

@ -6,7 +6,7 @@ doc/source/sourcecode
node_modules
npm-debug.log
releasenotes/build
{{ cookiecutter.module_folder }}/test/.secret_key_store
{{ cookiecutter.module_name }}/test/.secret_key_store
.coverage*
.jshintrc
.project

View File

@ -53,8 +53,8 @@ Install {{ cookiecutter.call_by_name }} with all dependencies in your virtual en
And enable it in Horizon::
ln -s ../{{ cookiecutter.repo_name }}/{{ cookiecutter.module_folder }}/enabled/_90_project_{{ cookiecutter.panel_group }}_panelgroup.py openstack_dashboard/local/enabled
ln -s ../{{ cookiecutter.repo_name }}/{{ cookiecutter.module_folder }}/enabled/_91_project_{{ cookiecutter.panel_group }}_{{ cookiecutter.panel }}s_panel.py openstack_dashboard/local/enabled
ln -s ../{{ cookiecutter.repo_name }}/{{ cookiecutter.module_name }}/enabled/_90_project_{{ cookiecutter.panel_group }}_panelgroup.py openstack_dashboard/local/enabled
ln -s ../{{ cookiecutter.repo_name }}/{{ cookiecutter.module_name }}/enabled/_91_project_{{ cookiecutter.panel_group }}_{{ cookiecutter.panel }}s_panel.py openstack_dashboard/local/enabled
To run horizon with the newly enabled {{ cookiecutter.call_by_name }} plugin run::

View File

@ -35,9 +35,9 @@ sys.path.insert(0, ROOT)
# This is required for ReadTheDocs.org, but isn't a bad idea anyway.
os.environ.setdefault('DJANGO_SETTINGS_MODULE',
'{{ cookiecutter.module_folder }}.test.settings')
'{{ cookiecutter.module_name }}.test.settings')
from {{ cookiecutter.module_folder }} \
from {{ cookiecutter.module_name }} \
import version as ui_ver
@ -67,7 +67,7 @@ def write_autodoc_index():
return modlist
RSTDIR = os.path.abspath(os.path.join(BASE_DIR, "sourcecode"))
SRCS = [('{{ cookiecutter.module_folder }}', ROOT), ]
SRCS = [('{{ cookiecutter.module_name }}', ROOT), ]
EXCLUDED_MODULES = ()
CURRENT_SOURCES = {}

View File

@ -53,8 +53,8 @@ Install {{ cookiecutter.call_by_name }} with all dependencies in your virtual en
And enable it in Horizon::
ln -s ../{{ cookiecutter.repo_name }}/{{ cookiecutter.module_folder }}/enabled/_90_project_{{ cookiecutter.panel_group }}_panelgroup.py openstack_dashboard/local/enabled
ln -s ../{{ cookiecutter.repo_name }}/{{ cookiecutter.module_folder }}/enabled/_91_project_{{ cookiecutter.panel_group }}_{{ cookiecutter.panel }}s_panel.py openstack_dashboard/local/enabled
ln -s ../{{ cookiecutter.repo_name }}/{{ cookiecutter.module_name }}/enabled/_90_project_{{ cookiecutter.panel_group }}_panelgroup.py openstack_dashboard/local/enabled
ln -s ../{{ cookiecutter.repo_name }}/{{ cookiecutter.module_name }}/enabled/_91_project_{{ cookiecutter.panel_group }}_{{ cookiecutter.panel }}s_panel.py openstack_dashboard/local/enabled
To run horizon with the newly enabled {{ cookiecutter.call_by_name }} plugin run::

View File

@ -19,5 +19,5 @@ from django.core.management import execute_from_command_line # noqa
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE",
"{{ cookiecutter.module_folder }}.test.settings")
"{{ cookiecutter.module_name }}.test.settings")
execute_from_command_line(sys.argv)

View File

@ -25,8 +25,8 @@
"dependencies": {},
"scripts": {
"postinstall": "if [ ! -d .tox ] || [ ! -d .tox/py27 ]; then tox -epy27 --notest; fi",
"lint": "eslint --no-color {{ cookiecutter.module_folder }}/static",
"lintq": "eslint --quiet {{ cookiecutter.module_folder }}/static",
"test": "karma start {{ cookiecutter.module_folder }}/karma.conf.js --single-run"
"lint": "eslint --no-color {{ cookiecutter.module_name }}/static",
"lintq": "eslint --quiet {{ cookiecutter.module_name }}/static",
"test": "karma start {{ cookiecutter.module_name }}/karma.conf.js --single-run"
}
}

View File

@ -14,7 +14,7 @@ setenv = VIRTUAL_ENV={envdir}
install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} -U {opts} {packages}
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
commands = python manage.py test {posargs} --settings={{cookiecutter.module_folder}}.test.settings
commands = python manage.py test {posargs} --settings={{cookiecutter.module_name}}.test.settings
[testenv:pep8]
commands = flake8 {posargs}
@ -25,7 +25,7 @@ commands = {posargs}
[testenv:cover]
commands =
coverage erase
coverage run {toxinidir}/manage.py test {{cookiecutter.module_folder}} --settings={{cookiecutter.module_folder}}.test.settings {posargs} --exclude-dir={{cookiecutter.module_folder}}/test/integration_tests {posargs}
coverage run {toxinidir}/manage.py test {{cookiecutter.module_name}} --settings={{cookiecutter.module_name}}.test.settings {posargs} --exclude-dir={{cookiecutter.module_name}}/test/integration_tests {posargs}
coverage xml --omit '.tox/cover/*' -o 'cover/coverage.xml'
coverage html --omit '.tox/cover/*' -d 'cover/htmlcov'
@ -33,7 +33,7 @@ commands =
basepython = python2.7
commands =
pip install django>=1.8,<1.9
python manage.py test {posargs} --settings={{cookiecutter.module_folder}}.test.settings
python manage.py test {posargs} --settings={{cookiecutter.module_name}}.test.settings
[testenv:eslint]
whitelist_externals = npm
@ -56,7 +56,7 @@ commands =
echo "nexecute `npm run test`"
[testenv:docs]
setenv = DJANGO_SETTINGS_MODULE={{cookiecutter.module_folder}}.test.settings
setenv = DJANGO_SETTINGS_MODULE={{cookiecutter.module_name}}.test.settings
commands = python setup.py build_sphinx
[testenv:releasenotes]

View File

@ -12,7 +12,7 @@
from django.views import generic
from {{cookiecutter.module_folder}}.api import client
from {{cookiecutter.module_name}}.api import client
from openstack_dashboard.api.rest import urls
from openstack_dashboard.api.rest import utils as rest_utils

View File

@ -15,7 +15,7 @@ import horizon
# This panel will be loaded from horizon, because specified in enabled file.
# To register REST api, import below here.
from {{cookiecutter.module_folder}}.api import rest_api # noqa
from {{cookiecutter.module_name}}.api import rest_api # noqa
class {{cookiecutter.panel_func}}s(horizon.Panel):

View File

@ -19,7 +19,7 @@ PANEL_GROUP_NAME = _('{{cookiecutter.panel_group_name}}')
# The slug of the dashboard the PANEL_GROUP associated with. Required.
PANEL_GROUP_DASHBOARD = '{{cookiecutter.dashboard}}'
ADD_INSTALLED_APPS = ['{{cookiecutter.module_folder}}']
ADD_INSTALLED_APPS = ['{{cookiecutter.module_name}}']
ADD_ANGULAR_MODULES = [
'horizon.dashboard.{{cookiecutter.panel_group}}'

View File

@ -18,4 +18,4 @@ PANEL_GROUP = '{{cookiecutter.panel_group}}'
PANEL_DASHBOARD = '{{cookiecutter.dashboard}}'
# Python panel class of the PANEL to be added.
ADD_PANEL = '{{cookiecutter.module_folder}}.content.{{cookiecutter.panel}}s.panel.{{cookiecutter.panel_func}}s'
ADD_PANEL = '{{cookiecutter.module_name}}.content.{{cookiecutter.panel}}s.panel.{{cookiecutter.panel_func}}s'

View File

@ -19,14 +19,14 @@ from openstack_dashboard.test.settings import * # noqa
HORIZON_CONFIG.pop('dashboards', None)
HORIZON_CONFIG.pop('default_dashboard', None)
# Update the dashboards with {{cookiecutter.module_folder}}
import {{cookiecutter.module_folder}}.enabled
# Update the dashboards with {{cookiecutter.module_name}}
import {{cookiecutter.module_name}}.enabled
import openstack_dashboard.enabled
from openstack_dashboard.utils import settings
settings.update_dashboards(
[
{{cookiecutter.module_folder}}.enabled,
{{cookiecutter.module_name}}.enabled,
openstack_dashboard.enabled,
],
HORIZON_CONFIG,