From 51222667b317d8eed67fe7ac6d04352c196eeefb Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 18 Jan 2023 14:37:55 -0600 Subject: [PATCH] Add support for new-style `corporal install` command --- corporal/commands.py | 14 ++++-- corporal/config.py | 1 - corporal/settings.py | 28 ----------- corporal/web/menus.py | 87 +--------------------------------- corporal/web/views/__init__.py | 15 +----- corporal/web/views/common.py | 18 ------- setup.py | 2 +- 7 files changed, 13 insertions(+), 152 deletions(-) delete mode 100644 corporal/settings.py delete mode 100644 corporal/web/views/common.py diff --git a/corporal/commands.py b/corporal/commands.py index 367d21c..d6667c6 100644 --- a/corporal/commands.py +++ b/corporal/commands.py @@ -28,12 +28,16 @@ class Command(commands.Command): long_description = '' -class HelloWorld(commands.Subcommand): +class Install(commands.InstallSubcommand): """ - The requisite 'hello world' example + Install the Corporal app """ - name = 'hello' + name = 'install' description = __doc__.strip() - def run(self, args): - self.stdout.write("hello world!\n") + # nb. these must be explicitly set b/c config is not available + # when running normally, e.g. `corporal -n install` + app_title = "Corporal" + app_package = 'corporal' + app_eggname = 'Corporal' + app_pypiname = 'Corporal' diff --git a/corporal/config.py b/corporal/config.py index f3d9193..658d17f 100644 --- a/corporal/config.py +++ b/corporal/config.py @@ -19,7 +19,6 @@ class CorporalConfig(ConfigExtension): # set some default config values config.setdefault('rattail', 'model', 'corporal.db.model') - config.setdefault('rattail', 'settings', 'corporal.settings') config.setdefault('tailbone.menus', 'handler', 'corporal.web.menus:CorporalMenuHandler') config.setdefault('rattail.config', 'templates', 'corporal:data/config rattail:data/config') diff --git a/corporal/settings.py b/corporal/settings.py deleted file mode 100644 index dcb1b75..0000000 --- a/corporal/settings.py +++ /dev/null @@ -1,28 +0,0 @@ -# -*- coding: utf-8; -*- -""" -App Settings -""" - -from rattail.settings import Setting - - -# bring in some common settings from rattail -from rattail.settings import ( - - # (General) - rattail_app_title, - tailbone_background_color, - tailbone_grid_default_pagesize, - - # Email - rattail_mail_record_attempts, - - # Product - rattail_product_key, - rattail_product_key_title, - tailbone_products_show_pod_image, - - # Purchasing / Receiving - rattail_batch_purchase_allow_cases, - rattail_batch_purchase_allow_expired_credits, -) diff --git a/corporal/web/menus.py b/corporal/web/menus.py index e41fbf2..24b708e 100644 --- a/corporal/web/menus.py +++ b/corporal/web/menus.py @@ -33,92 +33,9 @@ class CorporalMenuHandler(base.MenuHandler): ], } - reports_menu = { - 'title': "Reports", - 'type': 'menu', - 'items': [ - { - 'title': "New Report", - 'route': 'report_output.create', - 'perm': 'report_output.create', - }, - { - 'title': "Generated Reports", - 'route': 'report_output', - 'perm': 'report_output.list', - }, - { - 'title': "Problem Reports", - 'route': 'problem_reports', - 'perm': 'problem_reports.list', - }, - {'type': 'sep'}, - { - 'title': "Poser Reports", - 'route': 'poser_reports', - 'perm': 'poser_reports.list', - }, - ], - } + reports_menu = self.make_reports_menu(request, include_poser=True) - admin_menu = { - 'title': "Admin", - 'type': 'menu', - 'items': [ - { - 'title': "Users", - 'route': 'users', - 'perm': 'users.list', - }, - { - 'title': "User Events", - 'route': 'userevents', - 'perm': 'userevents.list', - }, - { - 'title': "Roles", - 'route': 'roles', - 'perm': 'roles.list', - }, - {'type': 'sep'}, - { - 'title': "App Settings", - 'route': 'appsettings', - 'perm': 'settings.list', - }, - { - 'title': "Email Settings", - 'route': 'emailprofiles', - 'perm': 'emailprofiles.list', - }, - { - 'title': "Email Attempts", - 'route': 'email_attempts', - 'perm': 'email_attempts.list', - }, - { - 'title': "Raw Settings", - 'route': 'settings', - 'perm': 'settings.list', - }, - {'type': 'sep'}, - { - 'title': "Tables", - 'route': 'tables', - 'perm': 'tables.list', - }, - { - 'title': "Importing / Exporting", - 'route': 'importing', - 'perm': 'importing.runjobs', - }, - { - 'title': "Corporal Upgrades", - 'route': 'upgrades', - 'perm': 'upgrades.list', - }, - ], - } + admin_menu = self.make_admin_menu(request, include_stores=False) menus = [ corepos_menu, diff --git a/corporal/web/views/__init__.py b/corporal/web/views/__init__.py index ef837b8..9cf3882 100644 --- a/corporal/web/views/__init__.py +++ b/corporal/web/views/__init__.py @@ -7,21 +7,8 @@ Corporal Views def includeme(config): # core views - config.include('corporal.web.views.common') - config.include('tailbone.views.auth') - config.include('tailbone.views.tables') - config.include('tailbone.views.upgrades') - config.include('tailbone.views.progress') - config.include('tailbone.views.importing') + config.include('tailbone.views.essentials') config.include('tailbone.views.poser') - config.include('tailbone.views.reports') - - # main table views - config.include('tailbone.views.email') - config.include('tailbone.views.people') - config.include('tailbone.views.roles') - config.include('tailbone.views.settings') - config.include('tailbone.views.users') # main views for CORE-POS config.include('tailbone_corepos.views') diff --git a/corporal/web/views/common.py b/corporal/web/views/common.py deleted file mode 100644 index 5d457e4..0000000 --- a/corporal/web/views/common.py +++ /dev/null @@ -1,18 +0,0 @@ -# -*- coding: utf-8; -*- -""" -Common views -""" - -from tailbone.views import common as base - -import corporal - - -class CommonView(base.CommonView): - - project_title = "Corporal" - project_version = corporal.__version__ + '+dev' - - -def includeme(config): - CommonView.defaults(config) diff --git a/setup.py b/setup.py index d43a269..d3b41b2 100644 --- a/setup.py +++ b/setup.py @@ -99,7 +99,7 @@ setup( ], 'corporal.commands': [ - 'hello = corporal.commands:HelloWorld', + 'install = corporal.commands:Install', ], 'paste.app_factory': [