From 999bb29499c40a189b2bb6d71250b17f644a29e2 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sat, 29 Jan 2022 12:36:54 -0600 Subject: [PATCH] Add support for rattail-integration project generator --- tailbone/templates/generate_project.mako | 77 ++++++++++++++++++++++++ tailbone/views/projects.py | 29 ++++++++- 2 files changed, 103 insertions(+), 3 deletions(-) diff --git a/tailbone/templates/generate_project.mako b/tailbone/templates/generate_project.mako index 51f404ee..fa39ec08 100644 --- a/tailbone/templates/generate_project.mako +++ b/tailbone/templates/generate_project.mako @@ -9,6 +9,7 @@ + ## @@ -181,6 +182,73 @@ ${h.end_form()} +
+ ${h.form(request.current_route_url(), ref='rattail_integrationForm')} + ${h.csrf_token(request)} + ${h.hidden('project_type', value='rattail_integration')} +
+
+
+

Naming

+
+
+
+ + + + + + + + + + + + + + ${h.hidden('slug', **{'v-model': 'rattail_integration.python_project_name'})} + + + + + +
+
+
+
+
+
+

Options

+
+
+
+ + + + + + + + + + + +
+
+
+ ${h.end_form()} +
+
${h.form(request.current_route_url(), ref='byjoveForm')} ${h.csrf_token(request)} @@ -310,6 +378,15 @@ 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 = { name: "Okay-Then-Mobile", slug: "okay-then-mobile", diff --git a/tailbone/views/projects.py b/tailbone/views/projects.py index 1770e021..489cb4f4 100644 --- a/tailbone/views/projects.py +++ b/tailbone/views/projects.py @@ -2,7 +2,7 @@ ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2020 Lance Edgar +# Copyright © 2010-2022 Lance Edgar # # This file is part of Rattail. # @@ -81,6 +81,25 @@ class GenerateProject(colander.MappingSchema): 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): """ Schema for generating a new 'byjove' project @@ -115,7 +134,9 @@ class GenerateProjectView(View): def __init__(self, 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): from rattail.projects.handler import RattailProjectHandler @@ -132,13 +153,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', 'fabric'): + if project_type not in self.project_handler.get_supported_project_types(): raise ValueError("Unknown project type: {}".format(project_type)) if project_type == 'byjove': schema = GenerateByjoveProject elif project_type == 'fabric': schema = GenerateFabricProject + elif project_type == 'rattail_integration': + schema = GenerateRattailIntegrationProject else: schema = GenerateProject form = forms.Form(schema=schema(), request=self.request,