Add support for rattail-integration project generator

This commit is contained in:
Lance Edgar 2022-01-29 12:36:54 -06:00
parent 1575cad447
commit 999bb29499
2 changed files with 103 additions and 3 deletions

View file

@ -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,