Add support for rattail-integration project generator
This commit is contained in:
parent
1575cad447
commit
999bb29499
|
@ -9,6 +9,7 @@
|
||||||
<b-field horizontal label="Project Type">
|
<b-field horizontal label="Project Type">
|
||||||
<b-select v-model="projectType">
|
<b-select v-model="projectType">
|
||||||
<option value="rattail">rattail</option>
|
<option value="rattail">rattail</option>
|
||||||
|
<option value="rattail_integration">rattail-integration</option>
|
||||||
## <option value="byjove">byjove</option>
|
## <option value="byjove">byjove</option>
|
||||||
<option value="fabric">fabric</option>
|
<option value="fabric">fabric</option>
|
||||||
</b-select>
|
</b-select>
|
||||||
|
@ -181,6 +182,73 @@
|
||||||
${h.end_form()}
|
${h.end_form()}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div v-if="projectType == 'rattail_integration'">
|
||||||
|
${h.form(request.current_route_url(), ref='rattail_integrationForm')}
|
||||||
|
${h.csrf_token(request)}
|
||||||
|
${h.hidden('project_type', value='rattail_integration')}
|
||||||
|
<br />
|
||||||
|
<div class="card">
|
||||||
|
<header class="card-header">
|
||||||
|
<p class="card-header-title">Naming</p>
|
||||||
|
</header>
|
||||||
|
<div class="card-content">
|
||||||
|
<div class="content">
|
||||||
|
|
||||||
|
<b-field horizontal label="Integration Name"
|
||||||
|
message="Name of the system to be integrated">
|
||||||
|
<b-input name="integration_name" v-model="rattail_integration.integration_name"></b-input>
|
||||||
|
</b-field>
|
||||||
|
|
||||||
|
<b-field horizontal label="Integration URL"
|
||||||
|
message="Reference URL for the system to be integrated">
|
||||||
|
<b-input name="integration_url" v-model="rattail_integration.integration_url"></b-input>
|
||||||
|
</b-field>
|
||||||
|
|
||||||
|
<b-field horizontal label="Package Name for PyPI"
|
||||||
|
message="Also will be used as slug, e.g. for folder name">
|
||||||
|
<b-input name="python_project_name" v-model="rattail_integration.python_project_name"></b-input>
|
||||||
|
</b-field>
|
||||||
|
|
||||||
|
${h.hidden('slug', **{'v-model': 'rattail_integration.python_project_name'})}
|
||||||
|
|
||||||
|
<b-field horizontal label="Package Name in Python"
|
||||||
|
:message="`For example, ~/src/${'$'}{rattail_integration.python_project_name}/${'$'}{rattail_integration.python_package_name}/__init__.py`">
|
||||||
|
<b-input name="python_name" v-model="rattail_integration.python_package_name"></b-input>
|
||||||
|
</b-field>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<br />
|
||||||
|
<div class="card">
|
||||||
|
<header class="card-header">
|
||||||
|
<p class="card-header-title">Options</p>
|
||||||
|
</header>
|
||||||
|
<div class="card-content">
|
||||||
|
<div class="content">
|
||||||
|
|
||||||
|
<b-field horizontal label="Extends Config"
|
||||||
|
message="Adds custom config extension">
|
||||||
|
<b-checkbox name="extends_config"
|
||||||
|
v-model="rattail_integration.extends_config"
|
||||||
|
native-value="true">
|
||||||
|
</b-checkbox>
|
||||||
|
</b-field>
|
||||||
|
|
||||||
|
<b-field horizontal label="Extends Rattail Schema"
|
||||||
|
message="Adds custom tables/columns to the Rattail DB schema">
|
||||||
|
<b-checkbox name="extends_db"
|
||||||
|
v-model="rattail_integration.extends_db"
|
||||||
|
native-value="true">
|
||||||
|
</b-checkbox>
|
||||||
|
</b-field>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
${h.end_form()}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div v-if="projectType == 'byjove'">
|
<div v-if="projectType == 'byjove'">
|
||||||
${h.form(request.current_route_url(), ref='byjoveForm')}
|
${h.form(request.current_route_url(), ref='byjoveForm')}
|
||||||
${h.csrf_token(request)}
|
${h.csrf_token(request)}
|
||||||
|
@ -310,6 +378,15 @@
|
||||||
uses_fabric: true,
|
uses_fabric: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ThisPageData.rattail_integration = {
|
||||||
|
integration_name: "Foo",
|
||||||
|
integration_url: "https://www.example.com/",
|
||||||
|
python_project_name: "rattail-foo",
|
||||||
|
python_package_name: "rattail_foo",
|
||||||
|
extends_config: true,
|
||||||
|
extends_db: true,
|
||||||
|
}
|
||||||
|
|
||||||
ThisPageData.byjove = {
|
ThisPageData.byjove = {
|
||||||
name: "Okay-Then-Mobile",
|
name: "Okay-Then-Mobile",
|
||||||
slug: "okay-then-mobile",
|
slug: "okay-then-mobile",
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# Rattail -- Retail Software Framework
|
# Rattail -- Retail Software Framework
|
||||||
# Copyright © 2010-2020 Lance Edgar
|
# Copyright © 2010-2022 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Rattail.
|
# This file is part of Rattail.
|
||||||
#
|
#
|
||||||
|
@ -81,6 +81,25 @@ class GenerateProject(colander.MappingSchema):
|
||||||
uses_fabric = colander.SchemaNode(colander.Boolean())
|
uses_fabric = colander.SchemaNode(colander.Boolean())
|
||||||
|
|
||||||
|
|
||||||
|
class GenerateRattailIntegrationProject(colander.MappingSchema):
|
||||||
|
"""
|
||||||
|
Schema to generate new rattail-integration project
|
||||||
|
"""
|
||||||
|
integration_name = colander.SchemaNode(colander.String())
|
||||||
|
|
||||||
|
integration_url = colander.SchemaNode(colander.String())
|
||||||
|
|
||||||
|
slug = colander.SchemaNode(colander.String())
|
||||||
|
|
||||||
|
python_project_name = colander.SchemaNode(colander.String())
|
||||||
|
|
||||||
|
python_name = colander.SchemaNode(colander.String())
|
||||||
|
|
||||||
|
extends_config = colander.SchemaNode(colander.Boolean())
|
||||||
|
|
||||||
|
extends_db = colander.SchemaNode(colander.Boolean())
|
||||||
|
|
||||||
|
|
||||||
class GenerateByjoveProject(colander.MappingSchema):
|
class GenerateByjoveProject(colander.MappingSchema):
|
||||||
"""
|
"""
|
||||||
Schema for generating a new 'byjove' project
|
Schema for generating a new 'byjove' project
|
||||||
|
@ -115,7 +134,9 @@ class GenerateProjectView(View):
|
||||||
|
|
||||||
def __init__(self, request):
|
def __init__(self, request):
|
||||||
super(GenerateProjectView, self).__init__(request)
|
super(GenerateProjectView, self).__init__(request)
|
||||||
self.handler = self.get_handler()
|
self.project_handler = self.get_handler()
|
||||||
|
# TODO: deprecate / remove this
|
||||||
|
self.handler = self.project_handler
|
||||||
|
|
||||||
def get_handler(self):
|
def get_handler(self):
|
||||||
from rattail.projects.handler import RattailProjectHandler
|
from rattail.projects.handler import RattailProjectHandler
|
||||||
|
@ -132,13 +153,15 @@ class GenerateProjectView(View):
|
||||||
project_type = 'rattail'
|
project_type = 'rattail'
|
||||||
if self.request.method == 'POST':
|
if self.request.method == 'POST':
|
||||||
project_type = self.request.POST.get('project_type', 'rattail')
|
project_type = self.request.POST.get('project_type', 'rattail')
|
||||||
if project_type not in ('rattail', 'byjove', 'fabric'):
|
if project_type not in self.project_handler.get_supported_project_types():
|
||||||
raise ValueError("Unknown project type: {}".format(project_type))
|
raise ValueError("Unknown project type: {}".format(project_type))
|
||||||
|
|
||||||
if project_type == 'byjove':
|
if project_type == 'byjove':
|
||||||
schema = GenerateByjoveProject
|
schema = GenerateByjoveProject
|
||||||
elif project_type == 'fabric':
|
elif project_type == 'fabric':
|
||||||
schema = GenerateFabricProject
|
schema = GenerateFabricProject
|
||||||
|
elif project_type == 'rattail_integration':
|
||||||
|
schema = GenerateRattailIntegrationProject
|
||||||
else:
|
else:
|
||||||
schema = GenerateProject
|
schema = GenerateProject
|
||||||
form = forms.Form(schema=schema(), request=self.request,
|
form = forms.Form(schema=schema(), request=self.request,
|
||||||
|
|
Loading…
Reference in a new issue