Add custom project generator for apps based on Corporal
and make related changes to support that use case
This commit is contained in:
parent
4cb00eeab7
commit
89e16b6a35
0
corporal/projects/__init__.py
Normal file
0
corporal/projects/__init__.py
Normal file
37
corporal/projects/corporal.py
Normal file
37
corporal/projects/corporal.py
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
# -*- coding: utf-8; -*-
|
||||||
|
"""
|
||||||
|
Corporal project generator
|
||||||
|
"""
|
||||||
|
|
||||||
|
from rattail.projects import PoserProjectGenerator
|
||||||
|
|
||||||
|
|
||||||
|
class CorporalProjectGenerator(PoserProjectGenerator):
|
||||||
|
"""
|
||||||
|
Generator for projects based on Corporal.
|
||||||
|
"""
|
||||||
|
key = 'corporal'
|
||||||
|
|
||||||
|
def normalize_context(self, context):
|
||||||
|
|
||||||
|
# set these first
|
||||||
|
context['has_db'] = True
|
||||||
|
context['has_web'] = True
|
||||||
|
context['alembic_version_locations'] = [
|
||||||
|
'rattail.db:alembic/versions',
|
||||||
|
'rattail_corepos.db:alembic/versions',
|
||||||
|
]
|
||||||
|
context['mako_directories'] = [
|
||||||
|
'{}.web:templates'.format(context['pkg_name']),
|
||||||
|
'corporal.web:templates',
|
||||||
|
'tailbone_corepos:templates',
|
||||||
|
'tailbone:templates',
|
||||||
|
]
|
||||||
|
|
||||||
|
# then do parent logic
|
||||||
|
context = super(CorporalProjectGenerator, self).normalize_context(context)
|
||||||
|
|
||||||
|
# add dependencies
|
||||||
|
context['requires']['Corporal'] = True
|
||||||
|
|
||||||
|
return context
|
10
corporal/projects/corporal/package/db/model/__init__.py.mako
Normal file
10
corporal/projects/corporal/package/db/model/__init__.py.mako
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
## -*- coding: utf-8; mode: python; -*-
|
||||||
|
# -*- coding: utf-8; -*-
|
||||||
|
"""
|
||||||
|
${name} data models
|
||||||
|
"""
|
||||||
|
|
||||||
|
# bring in all of Corporal
|
||||||
|
from corporal.db.model import *
|
||||||
|
|
||||||
|
# TODO: import other/custom models here...
|
|
@ -0,0 +1,14 @@
|
||||||
|
## -*- coding: utf-8; mode: conf; -*-
|
||||||
|
<%inherit file="rattail.projects:poser/package/templates/installer/rattail.conf.mako" />
|
||||||
|
${parent.body()}
|
||||||
|
|
||||||
|
####################
|
||||||
|
## preamble
|
||||||
|
####################
|
||||||
|
|
||||||
|
<%def name="render_group_preamble()">
|
||||||
|
${parent.render_group_preamble()}
|
||||||
|
|
||||||
|
[corepos]
|
||||||
|
foo = bar
|
||||||
|
</%def>
|
|
@ -0,0 +1,15 @@
|
||||||
|
## -*- coding: utf-8; mode: python; -*-
|
||||||
|
# -*- coding: utf-8; -*-
|
||||||
|
"""
|
||||||
|
${name} Views
|
||||||
|
"""
|
||||||
|
|
||||||
|
from corporal.web.views import essentials
|
||||||
|
|
||||||
|
|
||||||
|
def includeme(config):
|
||||||
|
|
||||||
|
# include all views deemed "essential" for Corporal
|
||||||
|
essentials.defaults(config)
|
||||||
|
|
||||||
|
# TODO: include more (e.g. custom) views here as needed
|
|
@ -35,12 +35,25 @@ class CorporalMenuHandler(base.MenuHandler):
|
||||||
|
|
||||||
reports_menu = self.make_reports_menu(request, include_poser=True)
|
reports_menu = self.make_reports_menu(request, include_poser=True)
|
||||||
|
|
||||||
|
other_menu = {
|
||||||
|
'title': "Other",
|
||||||
|
'type': 'menu',
|
||||||
|
'items': [
|
||||||
|
{
|
||||||
|
'title': "Generate New Project",
|
||||||
|
'route': 'generated_projects.create',
|
||||||
|
'perm': 'generated_projects.create',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
admin_menu = self.make_admin_menu(request, include_stores=False)
|
admin_menu = self.make_admin_menu(request, include_stores=False)
|
||||||
|
|
||||||
menus = [
|
menus = [
|
||||||
corepos_menu,
|
corepos_menu,
|
||||||
batch_menu,
|
batch_menu,
|
||||||
reports_menu,
|
reports_menu,
|
||||||
|
other_menu,
|
||||||
admin_menu,
|
admin_menu,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -3,16 +3,8 @@
|
||||||
Corporal Views
|
Corporal Views
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from corporal.web.views import essentials
|
||||||
|
|
||||||
|
|
||||||
def includeme(config):
|
def includeme(config):
|
||||||
|
essentials.defaults(config)
|
||||||
# core views
|
|
||||||
config.include('tailbone.views.essentials')
|
|
||||||
config.include('tailbone.views.poser')
|
|
||||||
|
|
||||||
# main views for CORE-POS
|
|
||||||
config.include('tailbone_corepos.views')
|
|
||||||
|
|
||||||
# batches
|
|
||||||
config.include('tailbone_corepos.views.batch.vendorcatalog')
|
|
||||||
config.include('tailbone_corepos.views.batch.coremember')
|
|
||||||
|
|
48
corporal/web/views/essentials.py
Normal file
48
corporal/web/views/essentials.py
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
# -*- coding: utf-8; -*-
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Rattail -- Retail Software Framework
|
||||||
|
# Copyright © 2010-2023 Lance Edgar
|
||||||
|
#
|
||||||
|
# This file is part of Rattail.
|
||||||
|
#
|
||||||
|
# Rattail is free software: you can redistribute it and/or modify it under the
|
||||||
|
# terms of the GNU General Public License as published by the Free Software
|
||||||
|
# Foundation, either version 3 of the License, or (at your option) any later
|
||||||
|
# version.
|
||||||
|
#
|
||||||
|
# Rattail is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
# details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License along with
|
||||||
|
# Rattail. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
"""
|
||||||
|
Essential views for convenient includes
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
def defaults(config, **kwargs):
|
||||||
|
mod = lambda spec: kwargs.get(spec, spec)
|
||||||
|
|
||||||
|
# core views
|
||||||
|
config.include(mod('tailbone.views.essentials'))
|
||||||
|
config.include(mod('tailbone.views.poser'))
|
||||||
|
config.include(mod('tailbone.views.projects'))
|
||||||
|
|
||||||
|
# main views for CORE-POS
|
||||||
|
config.include(mod('tailbone_corepos.views'))
|
||||||
|
|
||||||
|
# batches
|
||||||
|
config.include(mod('tailbone_corepos.views.batch.vendorcatalog'))
|
||||||
|
config.include(mod('tailbone_corepos.views.batch.coremember'))
|
||||||
|
|
||||||
|
# corporal-specific
|
||||||
|
config.include(mod('corporal.web.views.supplemental'))
|
||||||
|
|
||||||
|
|
||||||
|
def includeme(config):
|
||||||
|
defaults(config)
|
39
corporal/web/views/projects.py
Normal file
39
corporal/web/views/projects.py
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
# -*- coding: utf-8; -*-
|
||||||
|
"""
|
||||||
|
Project views
|
||||||
|
"""
|
||||||
|
|
||||||
|
from tailbone.views import ViewSupplement
|
||||||
|
|
||||||
|
|
||||||
|
class GeneratedProjectViewSupplement(ViewSupplement):
|
||||||
|
"""
|
||||||
|
View supplement for generating projects
|
||||||
|
"""
|
||||||
|
route_prefix = 'generated_projects'
|
||||||
|
|
||||||
|
def configure_form_corporal(self, f):
|
||||||
|
|
||||||
|
f.set_grouping([
|
||||||
|
("Naming", [
|
||||||
|
'name',
|
||||||
|
'pkg_name',
|
||||||
|
'pypi_name',
|
||||||
|
'organization',
|
||||||
|
]),
|
||||||
|
("Core", [
|
||||||
|
'extends_config',
|
||||||
|
'has_cli',
|
||||||
|
]),
|
||||||
|
("Database", [
|
||||||
|
'extends_db',
|
||||||
|
]),
|
||||||
|
])
|
||||||
|
|
||||||
|
# default settings
|
||||||
|
f.set_default('extends_config', False)
|
||||||
|
f.set_default('extends_db', False)
|
||||||
|
|
||||||
|
|
||||||
|
def includeme(config):
|
||||||
|
GeneratedProjectViewSupplement.defaults(config)
|
8
corporal/web/views/supplemental.py
Normal file
8
corporal/web/views/supplemental.py
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
# -*- coding: utf-8; -*-
|
||||||
|
"""
|
||||||
|
Include all supplemental views
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
def includeme(config):
|
||||||
|
config.include('corporal.web.views.projects')
|
Loading…
Reference in a new issue