Use newer config strategy for all views

to make inheritance easier
This commit is contained in:
Lance Edgar 2022-11-23 12:20:58 -06:00
parent db9b3617a4
commit b64f6c7884
44 changed files with 397 additions and 75 deletions

View file

@ -239,5 +239,12 @@ class AuthenticationView(View):
config.add_view(cls, attr='stop_root', route_name='stop_root')
def includeme(config):
def defaults(config, **kwargs):
base = globals()
AuthenticationView = kwargs.get('AuthenticationView', base['AuthenticationView'])
AuthenticationView.defaults(config)
def includeme(config):
defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2021 Lance Edgar
# Copyright © 2010-2022 Lance Edgar
#
# This file is part of Rattail.
#
@ -210,5 +210,12 @@ class EmailBounceView(MasterView):
cls._defaults(config)
def includeme(config):
def defaults(config, **kwargs):
base = globals()
EmailBounceView = kwargs.get('EmailBounceView', base['EmailBounceView'])
EmailBounceView.defaults(config)
def includeme(config):
defaults(config)

View file

@ -110,5 +110,12 @@ class CategoryView(MasterView):
CategoriesView = CategoryView
def includeme(config):
def defaults(config, **kwargs):
base = globals()
CategoryView = kwargs.get('CategoryView', base['CategoryView'])
CategoryView.defaults(config)
def includeme(config):
defaults(config)

View file

@ -340,5 +340,12 @@ class CommonView(View):
permission='admin')
def includeme(config):
def defaults(config, **kwargs):
base = globals()
CommonView = kwargs.get('CommonView', base['CommonView'])
CommonView.defaults(config)
def includeme(config):
defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2021 Lance Edgar
# Copyright © 2010-2022 Lance Edgar
#
# This file is part of Rattail.
#
@ -80,5 +80,12 @@ class CustomerGroupView(MasterView):
CustomerGroupsView = CustomerGroupView
def includeme(config):
def defaults(config, **kwargs):
base = globals()
CustomerGroupView = kwargs.get('CustomerGroupView', base['CustomerGroupView'])
CustomerGroupView.defaults(config)
def includeme(config):
defaults(config)

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.
#
@ -45,5 +45,12 @@ class CreateCustomerOrderBatchView(CustomerOrderBatchView):
creatable = False
def includeme(config):
def defaults(config, **kwargs):
base = globals()
CreateCustomerOrderBatchView = kwargs.get('CreateCustomerOrderBatchView', base['CreateCustomerOrderBatchView'])
CreateCustomerOrderBatchView.defaults(config)
def includeme(config):
defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2021 Lance Edgar
# Copyright © 2010-2022 Lance Edgar
#
# This file is part of Rattail.
#
@ -566,5 +566,12 @@ class CustomerOrderItemView(MasterView):
CustomerOrderItemsView = CustomerOrderItemView
def includeme(config):
def defaults(config, **kwargs):
base = globals()
CustomerOrderItemView = kwargs.get('CustomerOrderItemView', base['CustomerOrderItemView'])
CustomerOrderItemView.defaults(config)
def includeme(config):
defaults(config)

View file

@ -241,5 +241,12 @@ class DepartmentView(MasterView):
cls._defaults(config)
def includeme(config):
def defaults(config, **kwargs):
base = globals()
DepartmentView = kwargs.get('DepartmentView', base['DepartmentView'])
DepartmentView.defaults(config)
def includeme(config):
defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2021 Lance Edgar
# Copyright © 2010-2022 Lance Edgar
#
# This file is part of Rattail.
#
@ -64,5 +64,12 @@ class DepositLinkView(MasterView):
DepositLinksView = DepositLinkView
def includeme(config):
def defaults(config, **kwargs):
base = globals()
DepositLinkView = kwargs.get('DepositLinkView', base['DepositLinkView'])
DepositLinkView.defaults(config)
def includeme(config):
defaults(config)

View file

@ -108,5 +108,12 @@ class FamilyView(MasterView):
FamiliesView = FamilyView
def includeme(config):
def defaults(config, **kwargs):
base = globals()
FamilyView = kwargs.get('FamilyView', base['FamilyView'])
FamilyView.defaults(config)
def includeme(config):
defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2021 Lance Edgar
# Copyright © 2010-2022 Lance Edgar
#
# This file is part of Rattail.
#
@ -112,5 +112,12 @@ class GenerateFeatureView(View):
renderer='/generate_feature.mako')
def includeme(config):
def defaults(config, **kwargs):
base = globals()
GenerateFeatureView = kwargs.get('GenerateFeatureView', base['GenerateFeatureView'])
GenerateFeatureView.defaults(config)
def includeme(config):
defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2018 Lance Edgar
# Copyright © 2010-2022 Lance Edgar
#
# This file is part of Rattail.
#
@ -63,5 +63,12 @@ class FilemonView(View):
config.add_view(cls, attr='restart', route_name='filemon.restart', permission='filemon.restart')
def includeme(config):
def defaults(config, **kwargs):
base = globals()
FilemonView = kwargs.get('FilemonView', base['FilemonView'])
FilemonView.defaults(config)
def includeme(config):
defaults(config)

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.
#
@ -90,5 +90,12 @@ class IFPS_PLUView(MasterView):
def includeme(config):
def defaults(config, **kwargs):
base = globals()
IFPS_PLUView = kwargs.get('IFPS_PLUView', base['IFPS_PLUView'])
IFPS_PLUView.defaults(config)
def includeme(config):
defaults(config)

View file

@ -650,5 +650,12 @@ class RunJobSchema(colander.MappingSchema):
warnings = colander.SchemaNode(colander.Bool())
def includeme(config):
def defaults(config, **kwargs):
base = globals()
ImportingView = kwargs.get('ImportingView', base['ImportingView'])
ImportingView.defaults(config)
def includeme(config):
defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2021 Lance Edgar
# Copyright © 2010-2022 Lance Edgar
#
# This file is part of Rattail.
#
@ -70,5 +70,12 @@ class InventoryAdjustmentReasonView(MasterView):
InventoryAdjustmentReasonsView = InventoryAdjustmentReasonView
def includeme(config):
def defaults(config, **kwargs):
base = globals()
InventoryAdjustmentReasonView = kwargs.get('InventoryAdjustmentReasonView', base['InventoryAdjustmentReasonView'])
InventoryAdjustmentReasonView.defaults(config)
def includeme(config):
defaults(config)

View file

@ -177,5 +177,12 @@ class LabelProfileView(MasterView):
ProfilesView = LabelProfileView
def includeme(config):
def defaults(config, **kwargs):
base = globals()
LabelProfileView = kwargs.get('LabelProfileView', base['LabelProfileView'])
LabelProfileView.defaults(config)
def includeme(config):
defaults(config)

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.
#
@ -189,5 +189,12 @@ class MemberView(MasterView):
return member.phones[0].number
def includeme(config):
def defaults(config, **kwargs):
base = globals()
MemberView = kwargs.get('MemberView', base['MemberView'])
MemberView.defaults(config)
def includeme(config):
defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2021 Lance Edgar
# Copyright © 2010-2022 Lance Edgar
#
# This file is part of Rattail.
#
@ -575,23 +575,36 @@ class RecipientsWidgetBuefy(dfwidget.Widget):
return field.renderer(template, **values)
def includeme(config):
def defaults(config, **kwargs):
base = globals()
config.add_tailbone_permission('messages', 'messages.list', "List/Search Messages")
config.add_tailbone_permission('messages', 'messages.list',
"List/Search Messages")
# inbox
InboxView = kwargs.get('InboxView', base['InboxView'])
config.add_route('messages.inbox', '/messages/inbox/')
config.add_view(InboxView, attr='index', route_name='messages.inbox',
config.add_view(InboxView, attr='index',
route_name='messages.inbox',
permission='messages.list')
# archive
ArchiveView = kwargs.get('ArchiveView', base['ArchiveView'])
config.add_route('messages.archive', '/messages/archive/')
config.add_view(ArchiveView, attr='index', route_name='messages.archive',
config.add_view(ArchiveView, attr='index',
route_name='messages.archive',
permission='messages.list')
# sent
SentView = kwargs.get('SentView', base['SentView'])
config.add_route('messages.sent', '/messages/sent/')
config.add_view(SentView, attr='index', route_name='messages.sent',
config.add_view(SentView, attr='index',
route_name='messages.sent',
permission='messages.list')
MessageView = kwargs.get('MessageView', base['MessageView'])
MessageView.defaults(config)
def includeme(config):
defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2021 Lance Edgar
# Copyright © 2010-2022 Lance Edgar
#
# This file is part of Rattail.
#
@ -54,5 +54,12 @@ class PermissionView(MasterView):
return query
def includeme(config):
def defaults(config, **kwargs):
base = globals()
PermissionView = kwargs.get('PermissionView', base['PermissionView'])
PermissionView.defaults(config)
def includeme(config):
defaults(config)

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.
#
@ -65,9 +65,17 @@ def cancel(request):
return {}
def includeme(config):
def defaults(config, **kwargs):
base = globals()
progress = kwargs.get('progress', base['progress'])
config.add_route('progress', '/progress/{key}')
config.add_view(progress, route_name='progress', renderer='json')
cancel = kwargs.get('cancel', base['cancel'])
config.add_route('progress.cancel', '/progress/{key}/cancel')
config.add_view(cancel, route_name='progress.cancel', renderer='json')
def includeme(config):
defaults(config)

View file

@ -223,5 +223,12 @@ class GenerateProjectView(View):
renderer='/generate_project.mako')
def includeme(config):
def defaults(config, **kwargs):
base = globals()
GenerateProjectView = kwargs.get('GenerateProjectView', base['GenerateProjectView'])
GenerateProjectView.defaults(config)
def includeme(config):
defaults(config)

View file

@ -408,5 +408,12 @@ class PurchaseView(MasterView):
permission='{}.receiving_worksheet'.format(permission_prefix))
def includeme(config):
def defaults(config, **kwargs):
base = globals()
PurchaseView = kwargs.get('PurchaseView', base['PurchaseView'])
PurchaseView.defaults(config)
def includeme(config):
defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2021 Lance Edgar
# Copyright © 2010-2022 Lance Edgar
#
# This file is part of Rattail.
#
@ -201,5 +201,12 @@ class PurchaseCreditView(MasterView):
permission='{}.change_status'.format(permission_prefix))
def includeme(config):
def defaults(config, **kwargs):
base = globals()
PurchaseCreditView = kwargs.get('PurchaseCreditView', base['PurchaseCreditView'])
PurchaseCreditView.defaults(config)
def includeme(config):
defaults(config)

View file

@ -377,5 +377,12 @@ class NewCostingBatch(colander.Schema):
validator=valid_workflow)
def includeme(config):
def defaults(config, **kwargs):
base = globals()
CostingBatchView = kwargs.get('CostingBatchView', base['CostingBatchView'])
CostingBatchView.defaults(config)
def includeme(config):
defaults(config)

View file

@ -527,5 +527,12 @@ class OrderingBatchView(PurchasingBatchView):
"Download {} as Excel".format(model_title))
def includeme(config):
def defaults(config, **kwargs):
base = globals()
OrderingBatchView = kwargs.get('OrderingBatchView', base['OrderingBatchView'])
OrderingBatchView.defaults(config)
def includeme(config):
defaults(config)

View file

@ -2082,5 +2082,12 @@ class DeclareCreditForm(colander.MappingSchema):
missing=colander.null)
def includeme(config):
def defaults(config, **kwargs):
base = globals()
ReceivingBatchView = kwargs.get('ReceivingBatchView', base['ReceivingBatchView'])
ReceivingBatchView.defaults(config)
def includeme(config):
defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2021 Lance Edgar
# Copyright © 2010-2022 Lance Edgar
#
# This file is part of Rattail.
#
@ -107,5 +107,12 @@ class ReportCodeView(MasterView):
ReportCodesView = ReportCodeView
def includeme(config):
def defaults(config, **kwargs):
base = globals()
ReportCodeView = kwargs.get('ReportCodeView', base['ReportCodeView'])
ReportCodeView.defaults(config)
def includeme(config):
defaults(config)

View file

@ -800,14 +800,24 @@ def add_routes(config):
config.add_route('reports.inventory', '/reports/inventory')
def includeme(config):
def defaults(config, **kwargs):
base = globals()
# TODO: not in love with this pattern, but works for now
add_routes(config)
OrderingWorksheet = kwargs.get('OrderingWorksheet', base['OrderingWorksheet'])
config.add_view(OrderingWorksheet, route_name='reports.ordering',
renderer='/reports/ordering.mako')
InventoryWorksheet = kwargs.get('InventoryWorksheet', base['InventoryWorksheet'])
config.add_view(InventoryWorksheet, route_name='reports.inventory',
renderer='/reports/inventory.mako')
ReportOutputView = kwargs.get('ReportOutputView', base['ReportOutputView'])
ReportOutputView.defaults(config)
ProblemReportView = kwargs.get('ProblemReportView', base['ProblemReportView'])
ProblemReportView.defaults(config)
def includeme(config):
defaults(config)

View file

@ -529,5 +529,12 @@ class PermissionsWidget(dfwidget.Widget):
return field.renderer(template, **values)
def includeme(config):
def defaults(config, **kwargs):
base = globals()
RoleView = kwargs.get('RoleView', base['RoleView'])
RoleView.defaults(config)
def includeme(config):
defaults(config)

View file

@ -310,6 +310,15 @@ class AppSettingsView(View):
permission='settings.edit')
def includeme(config):
def defaults(config, **kwargs):
base = globals()
AppSettingsView = kwargs.get('AppSettingsView', base['AppSettingsView'])
AppSettingsView.defaults(config)
SettingView = kwargs.get('SettingView', base['SettingView'])
SettingView.defaults(config)
def includeme(config):
defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2021 Lance Edgar
# Copyright © 2010-2022 Lance Edgar
#
# This file is part of Rattail.
#
@ -207,6 +207,15 @@ class WorkedShiftView(MasterView):
WorkedShiftsView = WorkedShiftView
def includeme(config):
def defaults(config, **kwargs):
base = globals()
ScheduledShiftView = kwargs.get('ScheduledShiftView', base['ScheduledShiftView'])
ScheduledShiftView.defaults(config)
WorkedShiftView = kwargs.get('WorkedShiftView', base['WorkedShiftView'])
WorkedShiftView.defaults(config)
def includeme(config):
defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2018 Lance Edgar
# Copyright © 2010-2022 Lance Edgar
#
# This file is part of Rattail.
#
@ -212,5 +212,12 @@ class ScheduleView(TimeSheetView):
permission='schedule.print')
def includeme(config):
def defaults(config, **kwargs):
base = globals()
ScheduleView = kwargs.get('ScheduleView', base['ScheduleView'])
ScheduleView.defaults(config)
def includeme(config):
defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2018 Lance Edgar
# Copyright © 2010-2022 Lance Edgar
#
# This file is part of Rattail.
#
@ -133,5 +133,12 @@ class TimeSheetView(BaseTimeSheetView):
permission='timesheet.edit')
def includeme(config):
def defaults(config, **kwargs):
base = globals()
TimeSheetView = kwargs.get('TimeSheetView', base['TimeSheetView'])
TimeSheetView.defaults(config)
def includeme(config):
defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2021 Lance Edgar
# Copyright © 2010-2022 Lance Edgar
#
# This file is part of Rattail.
#
@ -121,5 +121,12 @@ class StoreView(MasterView):
StoresView = StoreView
def includeme(config):
def defaults(config, **kwargs):
base = globals()
StoreView = kwargs.get('StoreView', base['StoreView'])
StoreView.defaults(config)
def includeme(config):
defaults(config)

View file

@ -154,5 +154,12 @@ class SubdepartmentView(MasterView):
SubdepartmentsView = SubdepartmentView
def includeme(config):
def defaults(config, **kwargs):
base = globals()
SubdepartmentView = kwargs.get('SubdepartmentView', base['SubdepartmentView'])
SubdepartmentView.defaults(config)
def includeme(config):
defaults(config)

View file

@ -76,5 +76,12 @@ class TableView(MasterView):
TablesView = TableView
def includeme(config):
def defaults(config, **kwargs):
base = globals()
TableView = kwargs.get('TableView', base['TableView'])
TableView.defaults(config)
def includeme(config):
defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2021 Lance Edgar
# Copyright © 2010-2022 Lance Edgar
#
# This file is part of Rattail.
#
@ -64,5 +64,12 @@ class TaxView(MasterView):
TaxesView = TaxView
def includeme(config):
def defaults(config, **kwargs):
base = globals()
TaxView = kwargs.get('TaxView', base['TaxView'])
TaxView.defaults(config)
def includeme(config):
defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2018 Lance Edgar
# Copyright © 2010-2022 Lance Edgar
#
# This file is part of Rattail.
#
@ -187,5 +187,12 @@ class TempmonApplianceView(MasterView):
raise NotImplementedError("too many uploads?")
def includeme(config):
def defaults(config, **kwargs):
base = globals()
TempmonApplianceView = kwargs.get('TempmonApplianceView', base['TempmonApplianceView'])
TempmonApplianceView.defaults(config)
def includeme(config):
defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2019 Lance Edgar
# Copyright © 2010-2022 Lance Edgar
#
# This file is part of Rattail.
#
@ -276,5 +276,12 @@ class TempmonClientView(MasterView):
permission='{}.restart'.format(permission_prefix))
def includeme(config):
def defaults(config, **kwargs):
base = globals()
TempmonClientView = kwargs.get('TempmonClientView', base['TempmonClientView'])
TempmonClientView.defaults(config)
def includeme(config):
defaults(config)

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.
#
@ -158,5 +158,12 @@ class TempmonDashboardView(View):
renderer='json')
def includeme(config):
def defaults(config, **kwargs):
base = globals()
TempmonDashboardView = kwargs.get('TempmonDashboardView', base['TempmonDashboardView'])
TempmonDashboardView.defaults(config)
def includeme(config):
defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2019 Lance Edgar
# Copyright © 2010-2022 Lance Edgar
#
# This file is part of Rattail.
#
@ -344,5 +344,12 @@ class TempmonProbeView(MasterView):
cls._defaults(config)
def includeme(config):
def defaults(config, **kwargs):
base = globals()
TempmonProbeView = kwargs.get('TempmonProbeView', base['TempmonProbeView'])
TempmonProbeView.defaults(config)
def includeme(config):
defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2018 Lance Edgar
# Copyright © 2010-2022 Lance Edgar
#
# This file is part of Rattail.
#
@ -125,5 +125,12 @@ class TempmonReadingView(MasterView):
return tags.link_to(text, url)
def includeme(config):
def defaults(config, **kwargs):
base = globals()
TempmonReadingView = kwargs.get('TempmonReadingView', base['TempmonReadingView'])
TempmonReadingView.defaults(config)
def includeme(config):
defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2021 Lance Edgar
# Copyright © 2010-2022 Lance Edgar
#
# This file is part of Rattail.
#
@ -39,5 +39,12 @@ class TransactionView(base.TransactionView):
model_row_class = trainwreck.TransactionItem
def includeme(config):
def defaults(config, **kwargs):
base = globals()
TransactionView = kwargs.get('TransactionView', base['TransactionView'])
TransactionView.defaults(config)
def includeme(config):
defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2021 Lance Edgar
# Copyright © 2010-2022 Lance Edgar
#
# This file is part of Rattail.
#
@ -126,5 +126,12 @@ class UnitOfMeasureView(MasterView):
permission='{}.collect_wild_uoms'.format(permission_prefix))
def includeme(config):
def defaults(config, **kwargs):
base = globals()
UnitOfMeasureView = kwargs.get('UnitOfMeasureView', base['UnitOfMeasureView'])
UnitOfMeasureView.defaults(config)
def includeme(config):
defaults(config)