Add basic/incomplete support for generating new 'byjove' project
just wanted to get the placeholder in here for now
This commit is contained in:
parent
bd19d7c231
commit
cebe2f8adc
|
@ -1,9 +1,162 @@
|
|||
## -*- coding: utf-8; -*-
|
||||
<%inherit file="/form.mako" />
|
||||
<%inherit file="/page.mako" />
|
||||
|
||||
<%def name="title()">Generate Project</%def>
|
||||
|
||||
<%def name="content_title()"></%def>
|
||||
|
||||
<%def name="page_content()">
|
||||
<b-field horizontal label="Project Type">
|
||||
<b-select v-model="projectType">
|
||||
<option value="rattail">rattail</option>
|
||||
<option value="byjove">byjove</option>
|
||||
</b-select>
|
||||
</b-field>
|
||||
|
||||
<div class="card" v-if="projectType == 'rattail'">
|
||||
<header class="card-header">
|
||||
<p class="card-header-title">New 'rattail' Project</p>
|
||||
</header>
|
||||
<div class="card-content">
|
||||
<div class="content">
|
||||
${h.form(request.current_route_url(), ref='rattailForm')}
|
||||
${h.csrf_token(request)}
|
||||
${h.hidden('project_type', value='rattail')}
|
||||
|
||||
<b-field horizontal label="Name">
|
||||
<b-input name="name" v-model="rattail.name"></b-input>
|
||||
</b-field>
|
||||
|
||||
<b-field horizontal label="Slug">
|
||||
<b-input name="slug" v-model="rattail.slug"></b-input>
|
||||
</b-field>
|
||||
|
||||
<b-field horizontal label="Organization">
|
||||
<b-input name="organization" v-model="rattail.organization"></b-input>
|
||||
</b-field>
|
||||
|
||||
<b-field horizontal label="Python Project Name">
|
||||
<b-input name="python_project_name" v-model="rattail.python_project_name"></b-input>
|
||||
</b-field>
|
||||
|
||||
<b-field horizontal label="Python Package Name">
|
||||
<b-input name="python_name" v-model="rattail.python_package_name"></b-input>
|
||||
</b-field>
|
||||
|
||||
<b-field horizontal label="Has Rattail DB">
|
||||
<b-checkbox name="has_db" v-model="rattail.has_rattail_db"></b-checkbox>
|
||||
</b-field>
|
||||
|
||||
<b-field horizontal label="Extends Rattail DB Schema">
|
||||
<b-checkbox name="extends_db" v-model="rattail.extends_rattail_db_schema"></b-checkbox>
|
||||
</b-field>
|
||||
|
||||
<b-field horizontal label="Uses Rattail Batch Schema">
|
||||
<b-checkbox name="has_batch_schema" v-model="rattail.uses_rattail_batch_schema"></b-checkbox>
|
||||
</b-field>
|
||||
|
||||
<b-field horizontal label="Has Tailbone Web App">
|
||||
<b-checkbox name="has_web" v-model="rattail.has_tailbone_web_app"></b-checkbox>
|
||||
</b-field>
|
||||
|
||||
<b-field horizontal label="Has Tailbone Web API">
|
||||
<b-checkbox name="has_web_api" v-model="rattail.has_tailbone_web_api"></b-checkbox>
|
||||
</b-field>
|
||||
|
||||
<b-field horizontal label="Has DataSync Service">
|
||||
<b-checkbox name="has_datasync" v-model="rattail.has_datasync_service"></b-checkbox>
|
||||
</b-field>
|
||||
|
||||
<b-field horizontal label="Integrates w/ Catapult">
|
||||
<b-checkbox name="integrates_catapult" v-model="rattail.integrates_with_catapult"></b-checkbox>
|
||||
</b-field>
|
||||
|
||||
<b-field horizontal label="Integrates w/ CORE-POS">
|
||||
<b-checkbox name="integrates_corepos" v-model="rattail.integrates_with_corepos"></b-checkbox>
|
||||
</b-field>
|
||||
|
||||
<b-field horizontal label="Integrates w/ LOC SMS">
|
||||
<b-checkbox name="integrates_corepos" v-model="rattail.integrates_with_locsms"></b-checkbox>
|
||||
</b-field>
|
||||
|
||||
<b-field horizontal label="Uses Fabric">
|
||||
<b-checkbox name="uses_fabric" v-model="rattail.uses_fabric"></b-checkbox>
|
||||
</b-field>
|
||||
|
||||
${h.end_form()}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card" v-if="projectType == 'byjove'">
|
||||
<header class="card-header">
|
||||
<p class="card-header-title">New 'byjove' Project</p>
|
||||
</header>
|
||||
<div class="card-content">
|
||||
<div class="content">
|
||||
${h.form(request.current_route_url(), ref='byjoveForm')}
|
||||
${h.csrf_token(request)}
|
||||
${h.hidden('project_type', value='byjove')}
|
||||
|
||||
<b-field horizontal label="Name">
|
||||
<b-input name="name" v-model="byjove.name"></b-input>
|
||||
</b-field>
|
||||
|
||||
<b-field horizontal label="Slug">
|
||||
<b-input name="slug" v-model="byjove.slug"></b-input>
|
||||
</b-field>
|
||||
|
||||
${h.end_form()}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<br />
|
||||
<div class="buttons" style="padding-left: 8rem;">
|
||||
<b-button type="is-primary"
|
||||
@click="submitProjectForm()">
|
||||
Generate Project
|
||||
</b-button>
|
||||
</div>
|
||||
|
||||
</%def>
|
||||
|
||||
<%def name="modify_this_page_vars()">
|
||||
${parent.modify_this_page_vars()}
|
||||
<script type="text/javascript">
|
||||
|
||||
ThisPageData.projectType = 'rattail'
|
||||
|
||||
ThisPageData.rattail = {
|
||||
name: "Okay-Then",
|
||||
slug: "okay-then",
|
||||
organization: "Acme",
|
||||
python_project_name: "Acme-Okay-Then",
|
||||
python_package_name: "okay_then",
|
||||
has_rattail_db: true,
|
||||
extends_rattail_db_schema: false,
|
||||
uses_rattail_batch_schema: false,
|
||||
has_tailbone_web_app: true,
|
||||
has_tailbone_web_api: false,
|
||||
has_datasync_service: false,
|
||||
integrates_with_catapult: false,
|
||||
integrates_with_corepos: false,
|
||||
integrates_with_locsms: false,
|
||||
uses_fabric: false,
|
||||
}
|
||||
|
||||
ThisPageData.byjove = {
|
||||
name: "Okay-Then-Mobile",
|
||||
slug: "okay-then-mobile",
|
||||
}
|
||||
|
||||
ThisPage.methods.submitProjectForm = function() {
|
||||
let form = this.$refs[this.projectType + 'Form']
|
||||
form.submit()
|
||||
}
|
||||
|
||||
</script>
|
||||
</%def>
|
||||
|
||||
|
||||
${parent.body()}
|
||||
|
|
|
@ -81,6 +81,15 @@ class GenerateProject(colander.MappingSchema):
|
|||
uses_fabric = colander.SchemaNode(colander.Boolean())
|
||||
|
||||
|
||||
class GenerateByjoveProject(colander.MappingSchema):
|
||||
"""
|
||||
Schema for generating a new 'byjove' project
|
||||
"""
|
||||
name = colander.SchemaNode(colander.String())
|
||||
|
||||
slug = colander.SchemaNode(colander.String())
|
||||
|
||||
|
||||
class GenerateProjectView(View):
|
||||
"""
|
||||
View for generating new project source code
|
||||
|
@ -102,13 +111,20 @@ class GenerateProjectView(View):
|
|||
# 'type': 'bool'}),
|
||||
# ])
|
||||
|
||||
form = forms.Form(schema=GenerateProject(),
|
||||
request=self.request, use_buefy=use_buefy)
|
||||
project_type = 'rattail'
|
||||
if self.request.method == 'POST':
|
||||
project_type = self.request.POST.get('project_type', 'rattail')
|
||||
if project_type not in ('rattail', 'byjove'):
|
||||
raise ValueError("Unknown project type: {}".format(project_type))
|
||||
|
||||
schema = GenerateByjoveProject if project_type == 'byjove' else GenerateProject
|
||||
form = forms.Form(schema=schema(), request=self.request,
|
||||
use_buefy=use_buefy)
|
||||
form.submit_label = "Generate Project"
|
||||
form.auto_disable = False
|
||||
form.auto_disable_save = False
|
||||
if form.validate(newstyle=True):
|
||||
zipped = self.generate_project(form)
|
||||
zipped = self.generate_project(project_type, form)
|
||||
return self.file_response(zipped)
|
||||
# self.request.session.flash("New project was generated: {}".format(form.validated['name']))
|
||||
# return self.redirect(self.request.current_route_url())
|
||||
|
@ -146,10 +162,10 @@ class GenerateProjectView(View):
|
|||
'use_buefy': use_buefy,
|
||||
}
|
||||
|
||||
def generate_project(self, form):
|
||||
def generate_project(self, project_type, form):
|
||||
options = form.validated
|
||||
slug = options['slug']
|
||||
path = self.handler.generate_project(slug, options)
|
||||
path = self.handler.generate_project(project_type, slug, options)
|
||||
|
||||
zipped = '{}.zip'.format(path)
|
||||
with zipfile.ZipFile(zipped, 'w', zipfile.ZIP_DEFLATED) as z:
|
||||
|
|
Loading…
Reference in a new issue