Add support for generating new 'fabric' project
This commit is contained in:
parent
dd2b634ed2
commit
652e951f89
|
@ -10,6 +10,7 @@
|
|||
<b-select v-model="projectType">
|
||||
<option value="rattail">rattail</option>
|
||||
## <option value="byjove">byjove</option>
|
||||
<option value="fabric">fabric</option>
|
||||
</b-select>
|
||||
</b-field>
|
||||
|
||||
|
@ -208,6 +209,87 @@
|
|||
${h.end_form()}
|
||||
</div>
|
||||
|
||||
<div v-if="projectType == 'fabric'">
|
||||
${h.form(request.current_route_url(), ref='fabricForm')}
|
||||
${h.csrf_token(request)}
|
||||
${h.hidden('project_type', value='fabric')}
|
||||
|
||||
<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="Name">
|
||||
<b-input name="name" v-model="fabric.name"></b-input>
|
||||
</b-field>
|
||||
|
||||
<b-field horizontal label="Slug">
|
||||
<b-input name="slug" v-model="fabric.slug"></b-input>
|
||||
</b-field>
|
||||
|
||||
<b-field horizontal label="Organization"
|
||||
message="For use with "branding" etc.">
|
||||
<b-input name="organization" v-model="fabric.organization"></b-input>
|
||||
</b-field>
|
||||
|
||||
<b-field horizontal label="Package Name for PyPI"
|
||||
message="It's a good idea to use org name as namespace prefix here">
|
||||
<b-input name="python_project_name" v-model="fabric.python_project_name"></b-input>
|
||||
</b-field>
|
||||
|
||||
<b-field horizontal label="Package Name in Python"
|
||||
:message="`For example, ~/src/${'$'}{fabric.slug}/${'$'}{fabric.python_package_name}/__init__.py`">
|
||||
<b-input name="python_name" v-model="fabric.python_package_name"></b-input>
|
||||
</b-field>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<br />
|
||||
<div class="card">
|
||||
<header class="card-header">
|
||||
<p class="card-header-title">Misc.</p>
|
||||
</header>
|
||||
<div class="card-content">
|
||||
<div class="content">
|
||||
|
||||
<b-field horizontal label="Time Zone"
|
||||
message="for possible values see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List">
|
||||
<b-input name="timezone" v-model="fabric.timezone"></b-input>
|
||||
</b-field>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<br />
|
||||
<div class="card">
|
||||
<header class="card-header">
|
||||
<p class="card-header-title">Theo</p>
|
||||
</header>
|
||||
<div class="card-content">
|
||||
<div class="content">
|
||||
|
||||
<b-field horizontal label="Integrates With">
|
||||
<b-select name="integrates_with" v-model="fabric.integrates_with">
|
||||
<option value="">(nothing)</option>
|
||||
<option value="catapult">Catapult</option>
|
||||
<option value="corepos">CORE-POS</option>
|
||||
## <option value="locsms">LOC SMS</option>
|
||||
</b-select>
|
||||
</b-field>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
${h.end_form()}
|
||||
</div>
|
||||
|
||||
<br />
|
||||
<div class="buttons" style="padding-left: 8rem;">
|
||||
<b-button type="is-primary"
|
||||
|
@ -247,6 +329,16 @@
|
|||
slug: "okay-then-mobile",
|
||||
}
|
||||
|
||||
ThisPageData.fabric = {
|
||||
name: "AcmeFab",
|
||||
slug: "acmefab",
|
||||
organization: "Acme Foods",
|
||||
python_project_name: "Acme-Fabric",
|
||||
python_package_name: "acmefab",
|
||||
timezone: 'America/Chicago',
|
||||
integrates_with: '',
|
||||
}
|
||||
|
||||
ThisPage.methods.submitProjectForm = function() {
|
||||
let form = this.$refs[this.projectType + 'Form']
|
||||
form.submit()
|
||||
|
|
|
@ -90,6 +90,26 @@ class GenerateByjoveProject(colander.MappingSchema):
|
|||
slug = colander.SchemaNode(colander.String())
|
||||
|
||||
|
||||
class GenerateFabricProject(colander.MappingSchema):
|
||||
"""
|
||||
Schema for generating a new 'fabric' project
|
||||
"""
|
||||
name = colander.SchemaNode(colander.String())
|
||||
|
||||
slug = colander.SchemaNode(colander.String())
|
||||
|
||||
organization = colander.SchemaNode(colander.String())
|
||||
|
||||
python_project_name = colander.SchemaNode(colander.String())
|
||||
|
||||
python_name = colander.SchemaNode(colander.String())
|
||||
|
||||
timezone = colander.SchemaNode(colander.String())
|
||||
|
||||
integrates_with = colander.SchemaNode(colander.String(),
|
||||
missing=colander.null)
|
||||
|
||||
|
||||
class GenerateProjectView(View):
|
||||
"""
|
||||
View for generating new project source code
|
||||
|
@ -114,10 +134,15 @@ class GenerateProjectView(View):
|
|||
project_type = 'rattail'
|
||||
if self.request.method == 'POST':
|
||||
project_type = self.request.POST.get('project_type', 'rattail')
|
||||
if project_type not in ('rattail', 'byjove'):
|
||||
if project_type not in ('rattail', 'byjove', 'fabric'):
|
||||
raise ValueError("Unknown project type: {}".format(project_type))
|
||||
|
||||
schema = GenerateByjoveProject if project_type == 'byjove' else GenerateProject
|
||||
if project_type == 'byjove':
|
||||
schema = GenerateByjoveProject
|
||||
elif project_type == 'fabric':
|
||||
schema = GenerateFabricProject
|
||||
else:
|
||||
schema = GenerateProject
|
||||
form = forms.Form(schema=schema(), request=self.request,
|
||||
use_buefy=use_buefy)
|
||||
if form.validate(newstyle=True):
|
||||
|
|
Loading…
Reference in a new issue