Normalize naming of all traditional master views

such names should never use plural forms.  for now what plural forms were
previously in use, should still work.  ideally can remove those at some point
This commit is contained in:
Lance Edgar 2021-01-28 16:32:25 -06:00
parent 3ad19d05e5
commit 719e7c8441
30 changed files with 273 additions and 177 deletions

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2019 Lance Edgar # Copyright © 2010-2021 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -45,7 +45,7 @@ from tailbone.views.batch import FileBatchMasterView
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class VendorCatalogsView(FileBatchMasterView): class VendorCatalogView(FileBatchMasterView):
""" """
Master view for vendor catalog batches. Master view for vendor catalog batches.
""" """
@ -132,7 +132,7 @@ class VendorCatalogsView(FileBatchMasterView):
return self.parsers return self.parsers
def configure_grid(self, g): def configure_grid(self, g):
super(VendorCatalogsView, self).configure_grid(g) super(VendorCatalogView, self).configure_grid(g)
g.joiners['vendor'] = lambda q: q.join(model.Vendor) g.joiners['vendor'] = lambda q: q.join(model.Vendor)
g.filters['vendor'] = g.make_filter('vendor', model.Vendor.name, g.filters['vendor'] = g.make_filter('vendor', model.Vendor.name,
default_active=True, default_verb='contains') default_active=True, default_verb='contains')
@ -145,7 +145,7 @@ class VendorCatalogsView(FileBatchMasterView):
return six.text_type(batch.vendor) return six.text_type(batch.vendor)
def configure_form(self, f): def configure_form(self, f):
super(VendorCatalogsView, self).configure_form(f) super(VendorCatalogView, self).configure_form(f)
# vendor # vendor
f.set_renderer('vendor', self.render_vendor) f.set_renderer('vendor', self.render_vendor)
@ -187,7 +187,7 @@ class VendorCatalogsView(FileBatchMasterView):
f.set_readonly('effective') f.set_readonly('effective')
def get_batch_kwargs(self, batch): def get_batch_kwargs(self, batch):
kwargs = super(VendorCatalogsView, self).get_batch_kwargs(batch) kwargs = super(VendorCatalogView, self).get_batch_kwargs(batch)
kwargs['parser_key'] = batch.parser_key kwargs['parser_key'] = batch.parser_key
if batch.vendor: if batch.vendor:
kwargs['vendor'] = batch.vendor kwargs['vendor'] = batch.vendor
@ -197,7 +197,7 @@ class VendorCatalogsView(FileBatchMasterView):
return kwargs return kwargs
def configure_row_grid(self, g): def configure_row_grid(self, g):
super(VendorCatalogsView, self).configure_row_grid(g) super(VendorCatalogView, self).configure_row_grid(g)
batch = self.get_instance() batch = self.get_instance()
# starts # starts
@ -230,7 +230,7 @@ class VendorCatalogsView(FileBatchMasterView):
return 'notice' return 'notice'
def configure_row_form(self, f): def configure_row_form(self, f):
super(VendorCatalogsView, self).configure_row_form(f) super(VendorCatalogView, self).configure_row_form(f)
f.set_renderer('product', self.render_product) f.set_renderer('product', self.render_product)
f.set_type('discount_percent', 'percent') f.set_type('discount_percent', 'percent')
@ -251,6 +251,9 @@ class VendorCatalogsView(FileBatchMasterView):
kwargs['parsers'] = parsers kwargs['parsers'] = parsers
return kwargs return kwargs
# TODO: deprecate / remove this
VendorCatalogsView = VendorCatalogView
def includeme(config): def includeme(config):
VendorCatalogsView.defaults(config) VendorCatalogView.defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2019 Lance Edgar # Copyright © 2010-2021 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -38,7 +38,7 @@ from deform import widget as dfwidget
from tailbone.views.batch import FileBatchMasterView from tailbone.views.batch import FileBatchMasterView
class VendorInvoicesView(FileBatchMasterView): class VendorInvoiceView(FileBatchMasterView):
""" """
Master view for vendor invoice batches. Master view for vendor invoice batches.
""" """
@ -91,7 +91,7 @@ class VendorInvoicesView(FileBatchMasterView):
return six.text_type(batch.vendor) return six.text_type(batch.vendor)
def configure_grid(self, g): def configure_grid(self, g):
super(VendorInvoicesView, self).configure_grid(g) super(VendorInvoiceView, self).configure_grid(g)
# vendor # vendor
g.set_joiner('vendor', lambda q: q.join(model.Vendor)) g.set_joiner('vendor', lambda q: q.join(model.Vendor))
@ -117,7 +117,7 @@ class VendorInvoicesView(FileBatchMasterView):
g.set_link('executed', False) g.set_link('executed', False)
def configure_form(self, f): def configure_form(self, f):
super(VendorInvoicesView, self).configure_form(f) super(VendorInvoiceView, self).configure_form(f)
# vendor # vendor
if self.creating: if self.creating:
@ -166,7 +166,7 @@ class VendorInvoicesView(FileBatchMasterView):
# raise formalchemy.ValidationError(unicode(error)) # raise formalchemy.ValidationError(unicode(error))
def get_batch_kwargs(self, batch): def get_batch_kwargs(self, batch):
kwargs = super(VendorInvoicesView, self).get_batch_kwargs(batch) kwargs = super(VendorInvoiceView, self).get_batch_kwargs(batch)
kwargs['parser_key'] = batch.parser_key kwargs['parser_key'] = batch.parser_key
return kwargs return kwargs
@ -180,7 +180,7 @@ class VendorInvoicesView(FileBatchMasterView):
return True return True
def configure_row_grid(self, g): def configure_row_grid(self, g):
super(VendorInvoicesView, self).configure_row_grid(g) super(VendorInvoiceView, self).configure_row_grid(g)
g.set_label('upc', "UPC") g.set_label('upc', "UPC")
g.set_label('brand_name', "Brand") g.set_label('brand_name', "Brand")
g.set_label('shipped_cases', "Cases") g.set_label('shipped_cases', "Cases")
@ -197,6 +197,9 @@ class VendorInvoicesView(FileBatchMasterView):
row.STATUS_UNIT_COST_DIFFERS): row.STATUS_UNIT_COST_DIFFERS):
return 'notice' return 'notice'
# TODO: deprecate / remove this
VendorInvoicesView = VendorInvoiceView
def includeme(config): def includeme(config):
VendorInvoicesView.defaults(config) VendorInvoiceView.defaults(config)

View file

@ -41,7 +41,7 @@ from webhelpers2.html import HTML, tags
from tailbone.views import MasterView from tailbone.views import MasterView
class EmailBouncesView(MasterView): class EmailBounceView(MasterView):
""" """
Master view for email bounces. Master view for email bounces.
""" """
@ -66,14 +66,14 @@ class EmailBouncesView(MasterView):
] ]
def __init__(self, request): def __init__(self, request):
super(EmailBouncesView, self).__init__(request) super(EmailBounceView, self).__init__(request)
self.handler_options = sorted(get_profile_keys(self.rattail_config)) self.handler_options = sorted(get_profile_keys(self.rattail_config))
def get_handler(self, bounce): def get_handler(self, bounce):
return get_handler(self.rattail_config, bounce.config_key) return get_handler(self.rattail_config, bounce.config_key)
def configure_grid(self, g): def configure_grid(self, g):
super(EmailBouncesView, self).configure_grid(g) super(EmailBounceView, self).configure_grid(g)
g.filters['config_key'].set_choices(self.handler_options) g.filters['config_key'].set_choices(self.handler_options)
g.filters['config_key'].default_active = True g.filters['config_key'].default_active = True
@ -93,7 +93,7 @@ class EmailBouncesView(MasterView):
g.set_link('intended_recipient_address') g.set_link('intended_recipient_address')
def configure_form(self, f): def configure_form(self, f):
super(EmailBouncesView, self).configure_form(f) super(EmailBounceView, self).configure_form(f)
bounce = f.model_instance bounce = f.model_instance
f.set_renderer('message', self.render_message_file) f.set_renderer('message', self.render_message_file)
f.set_renderer('links', self.render_links) f.set_renderer('links', self.render_links)
@ -207,6 +207,9 @@ class EmailBouncesView(MasterView):
cls._defaults(config) cls._defaults(config)
# TODO: deprecate / remove this
EmailBouncesView = EmailBounceView
def includeme(config): def includeme(config):
EmailBouncesView.defaults(config) EmailBounceView.defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2018 Lance Edgar # Copyright © 2010-2021 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -31,7 +31,7 @@ from rattail.db import model
from tailbone.views import MasterView, AutocompleteView from tailbone.views import MasterView, AutocompleteView
class BrandsView(MasterView): class BrandView(MasterView):
""" """
Master view for the Brand class. Master view for the Brand class.
""" """
@ -59,7 +59,7 @@ class BrandsView(MasterView):
] ]
def configure_grid(self, g): def configure_grid(self, g):
super(BrandsView, self).configure_grid(g) super(BrandView, self).configure_grid(g)
# name # name
g.filters['name'].default_active = True g.filters['name'].default_active = True
@ -90,6 +90,9 @@ class BrandsView(MasterView):
self.Session.flush() self.Session.flush()
self.Session.delete(removing) self.Session.delete(removing)
# TODO: deprecate / remove this
BrandsView = BrandView
class BrandsAutocomplete(AutocompleteView): class BrandsAutocomplete(AutocompleteView):
@ -104,4 +107,4 @@ def includeme(config):
config.add_view(BrandsAutocomplete, route_name='brands.autocomplete', config.add_view(BrandsAutocomplete, route_name='brands.autocomplete',
renderer='json', permission='brands.list') renderer='json', permission='brands.list')
BrandsView.defaults(config) BrandView.defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2018 Lance Edgar # Copyright © 2010-2021 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -32,7 +32,7 @@ from tailbone import forms
from tailbone.views import MasterView from tailbone.views import MasterView
class CategoriesView(MasterView): class CategoryView(MasterView):
""" """
Master view for the Category class. Master view for the Category class.
""" """
@ -55,7 +55,7 @@ class CategoriesView(MasterView):
] ]
def configure_grid(self, g): def configure_grid(self, g):
super(CategoriesView, self).configure_grid(g) super(CategoryView, self).configure_grid(g)
g.filters['name'].default_active = True g.filters['name'].default_active = True
g.filters['name'].default_verb = 'contains' g.filters['name'].default_verb = 'contains'
@ -68,7 +68,7 @@ class CategoriesView(MasterView):
g.set_link('name') g.set_link('name')
def get_xlsx_fields(self): def get_xlsx_fields(self):
fields = super(CategoriesView, self).get_xlsx_fields() fields = super(CategoryView, self).get_xlsx_fields()
fields.extend([ fields.extend([
'department_number', 'department_number',
'department_name', 'department_name',
@ -76,7 +76,7 @@ class CategoriesView(MasterView):
return fields return fields
def get_xlsx_row(self, category, fields): def get_xlsx_row(self, category, fields):
row = super(CategoriesView, self).get_xlsx_row(category, fields) row = super(CategoryView, self).get_xlsx_row(category, fields)
dept = category.department dept = category.department
if dept: if dept:
row['department_number'] = dept.number row['department_number'] = dept.number
@ -87,7 +87,7 @@ class CategoriesView(MasterView):
return row return row
def configure_form(self, f): def configure_form(self, f):
super(CategoriesView, self).configure_form(f) super(CategoryView, self).configure_form(f)
# department # department
if self.creating or self.editing: if self.creating or self.editing:
@ -106,6 +106,9 @@ class CategoriesView(MasterView):
return [(dept.uuid, "{} {}".format(dept.number, dept.name)) return [(dept.uuid, "{} {}".format(dept.number, dept.name))
for dept in departments] for dept in departments]
# TODO: deprecate / remove this
CategoriesView = CategoryView
def includeme(config): def includeme(config):
CategoriesView.defaults(config) CategoryView.defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2018 Lance Edgar # Copyright © 2010-2021 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -32,7 +32,7 @@ from tailbone.db import Session
from tailbone.views import MasterView from tailbone.views import MasterView
class CustomerGroupsView(MasterView): class CustomerGroupView(MasterView):
""" """
Master view for the CustomerGroup class. Master view for the CustomerGroup class.
""" """
@ -54,7 +54,7 @@ class CustomerGroupsView(MasterView):
] ]
def configure_grid(self, g): def configure_grid(self, g):
super(CustomerGroupsView, self).configure_grid(g) super(CustomerGroupView, self).configure_grid(g)
g.filters['name'].default_active = True g.filters['name'].default_active = True
g.filters['name'].default_verb = 'contains' g.filters['name'].default_verb = 'contains'
g.set_sort_defaults('name') g.set_sort_defaults('name')
@ -76,6 +76,9 @@ class CustomerGroupsView(MasterView):
cls._defaults(config) cls._defaults(config)
# TODO: deprecate / remove this
CustomerGroupsView = CustomerGroupView
def includeme(config): def includeme(config):
CustomerGroupsView.defaults(config) CustomerGroupView.defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2020 Lance Edgar # Copyright © 2010-2021 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -43,7 +43,7 @@ from tailbone.views import MasterView, AutocompleteView
from rattail.db import model from rattail.db import model
class CustomersView(MasterView): class CustomerView(MasterView):
""" """
Master view for the Customer class. Master view for the Customer class.
""" """
@ -110,7 +110,7 @@ class CustomersView(MasterView):
] ]
def configure_grid(self, g): def configure_grid(self, g):
super(CustomersView, self).configure_grid(g) super(CustomerView, self).configure_grid(g)
# name # name
g.filters['name'].default_active = True g.filters['name'].default_active = True
@ -160,7 +160,7 @@ class CustomersView(MasterView):
def get_instance(self): def get_instance(self):
try: try:
instance = super(CustomersView, self).get_instance() instance = super(CustomerView, self).get_instance()
except HTTPNotFound: except HTTPNotFound:
pass pass
else: else:
@ -189,7 +189,7 @@ class CustomersView(MasterView):
raise HTTPNotFound raise HTTPNotFound
def configure_common_form(self, f): def configure_common_form(self, f):
super(CustomersView, self).configure_common_form(f) super(CustomerView, self).configure_common_form(f)
customer = f.model_instance customer = f.model_instance
permission_prefix = self.get_permission_prefix() permission_prefix = self.get_permission_prefix()
@ -252,7 +252,7 @@ class CustomersView(MasterView):
f.set_readonly('groups') f.set_readonly('groups')
def configure_form(self, f): def configure_form(self, f):
super(CustomersView, self).configure_form(f) super(CustomerView, self).configure_form(f)
customer = f.model_instance customer = f.model_instance
permission_prefix = self.get_permission_prefix() permission_prefix = self.get_permission_prefix()
@ -406,6 +406,9 @@ class CustomersView(MasterView):
config.add_view(cls, attr='detach_person', route_name='{}.detach_person'.format(route_prefix), config.add_view(cls, attr='detach_person', route_name='{}.detach_person'.format(route_prefix),
permission='{}.detach_person'.format(permission_prefix)) permission='{}.detach_person'.format(permission_prefix))
# TODO: deprecate / remove this
CustomersView = CustomerView
# # TODO: this is referenced by some custom apps, but should be moved?? # # TODO: this is referenced by some custom apps, but should be moved??
# def unique_id(value, field): # def unique_id(value, field):
@ -492,4 +495,4 @@ def includeme(config):
config.add_view(customer_info, route_name='customer.info', config.add_view(customer_info, route_name='customer.info',
renderer='json', permission='customers.view') renderer='json', permission='customers.view')
CustomersView.defaults(config) CustomerView.defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2018 Lance Edgar # Copyright © 2010-2021 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -40,7 +40,7 @@ from tailbone.views import MasterView
from tailbone.util import raw_datetime from tailbone.util import raw_datetime
class CustomerOrderItemsView(MasterView): class CustomerOrderItemView(MasterView):
""" """
Master view for customer order items Master view for customer order items
""" """
@ -100,7 +100,7 @@ class CustomerOrderItemsView(MasterView):
.joinedload(model.CustomerOrder.person)) .joinedload(model.CustomerOrder.person))
def configure_grid(self, g): def configure_grid(self, g):
super(CustomerOrderItemsView, self).configure_grid(g) super(CustomerOrderItemView, self).configure_grid(g)
g.set_joiner('person', lambda q: q.outerjoin(model.Person)) g.set_joiner('person', lambda q: q.outerjoin(model.Person))
@ -134,7 +134,7 @@ class CustomerOrderItemsView(MasterView):
return raw_datetime(self.rattail_config, value) return raw_datetime(self.rattail_config, value)
def configure_form(self, f): def configure_form(self, f):
super(CustomerOrderItemsView, self).configure_form(f) super(CustomerOrderItemView, self).configure_form(f)
# order # order
f.set_renderer('order', self.render_order) f.set_renderer('order', self.render_order)
@ -176,12 +176,15 @@ class CustomerOrderItemsView(MasterView):
model.CustomerOrderItemEvent.type_code) model.CustomerOrderItemEvent.type_code)
def configure_row_grid(self, g): def configure_row_grid(self, g):
super(CustomerOrderItemsView, self).configure_row_grid(g) super(CustomerOrderItemView, self).configure_row_grid(g)
g.set_label('occurred', "When") g.set_label('occurred', "When")
g.set_label('type_code', "What") # TODO: enum renderer g.set_label('type_code', "What") # TODO: enum renderer
g.set_label('user', "Who") g.set_label('user', "Who")
g.set_label('note', "Notes") g.set_label('note', "Notes")
# TODO: deprecate / remove this
CustomerOrderItemsView = CustomerOrderItemView
def includeme(config): def includeme(config):
CustomerOrderItemsView.defaults(config) CustomerOrderItemView.defaults(config)

View file

@ -42,7 +42,7 @@ from tailbone.db import Session
from tailbone.views import MasterView from tailbone.views import MasterView
class CustomerOrdersView(MasterView): class CustomerOrderView(MasterView):
""" """
Master view for customer orders Master view for customer orders
""" """
@ -74,7 +74,7 @@ class CustomerOrdersView(MasterView):
.options(orm.joinedload(model.CustomerOrder.customer)) .options(orm.joinedload(model.CustomerOrder.customer))
def configure_grid(self, g): def configure_grid(self, g):
super(CustomerOrdersView, self).configure_grid(g) super(CustomerOrderView, self).configure_grid(g)
g.set_joiner('customer', lambda q: q.outerjoin(model.Customer)) g.set_joiner('customer', lambda q: q.outerjoin(model.Customer))
g.set_joiner('person', lambda q: q.outerjoin(model.Person)) g.set_joiner('person', lambda q: q.outerjoin(model.Person))
@ -98,7 +98,7 @@ class CustomerOrdersView(MasterView):
g.set_label('id', "ID") g.set_label('id', "ID")
def configure_form(self, f): def configure_form(self, f):
super(CustomerOrdersView, self).configure_form(f) super(CustomerOrderView, self).configure_form(f)
# id # id
f.set_readonly('id') f.set_readonly('id')
@ -476,6 +476,9 @@ class CustomerOrdersView(MasterView):
return {'ok': True, 'next_url': next_url} return {'ok': True, 'next_url': next_url}
# TODO: deprecate / remove this
CustomerOrdersView = CustomerOrderView
def includeme(config): def includeme(config):
CustomerOrdersView.defaults(config) CustomerOrderView.defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2020 Lance Edgar # Copyright © 2010-2021 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -37,7 +37,7 @@ from tailbone.views import MasterView
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class DataSyncChangesView(MasterView): class DataSyncChangeView(MasterView):
""" """
Master view for the DataSyncChange model. Master view for the DataSyncChange model.
""" """
@ -64,7 +64,7 @@ class DataSyncChangesView(MasterView):
] ]
def configure_grid(self, g): def configure_grid(self, g):
super(DataSyncChangesView, self).configure_grid(g) super(DataSyncChangeView, self).configure_grid(g)
# batch_sequence # batch_sequence
g.set_label('batch_sequence', "Batch Seq.") g.set_label('batch_sequence', "Batch Seq.")
@ -113,6 +113,9 @@ class DataSyncChangesView(MasterView):
cls._defaults(config) cls._defaults(config)
# TODO: deprecate / remove this
DataSyncChangesView = DataSyncChangeView
def includeme(config): def includeme(config):
DataSyncChangesView.defaults(config) DataSyncChangeView.defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2020 Lance Edgar # Copyright © 2010-2021 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -36,7 +36,7 @@ from tailbone import grids
from tailbone.views import MasterView, AutocompleteView from tailbone.views import MasterView, AutocompleteView
class DepartmentsView(MasterView): class DepartmentView(MasterView):
""" """
Master view for the Department class. Master view for the Department class.
""" """
@ -61,7 +61,7 @@ class DepartmentsView(MasterView):
] ]
def configure_grid(self, g): def configure_grid(self, g):
super(DepartmentsView, self).configure_grid(g) super(DepartmentView, self).configure_grid(g)
g.filters['name'].default_active = True g.filters['name'].default_active = True
g.filters['name'].default_verb = 'contains' g.filters['name'].default_verb = 'contains'
g.set_sort_defaults('number') g.set_sort_defaults('number')
@ -71,7 +71,7 @@ class DepartmentsView(MasterView):
g.set_link('name') g.set_link('name')
def configure_form(self, f): def configure_form(self, f):
super(DepartmentsView, self).configure_form(f) super(DepartmentView, self).configure_form(f)
f.remove_field('subdepartments') f.remove_field('subdepartments')
f.remove_field('employees') f.remove_field('employees')
f.set_type('product', 'boolean') f.set_type('product', 'boolean')
@ -144,6 +144,9 @@ class DepartmentsView(MasterView):
cls._defaults(config) cls._defaults(config)
# TODO: deprecate / remove this
DepartmentsView = DepartmentView
class DepartmentsAutocomplete(AutocompleteView): class DepartmentsAutocomplete(AutocompleteView):
@ -158,4 +161,4 @@ def includeme(config):
config.add_view(DepartmentsAutocomplete, route_name='departments.autocomplete', config.add_view(DepartmentsAutocomplete, route_name='departments.autocomplete',
renderer='json', permission='departments.list') renderer='json', permission='departments.list')
DepartmentsView.defaults(config) DepartmentView.defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2018 Lance Edgar # Copyright © 2010-2021 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -31,7 +31,7 @@ from rattail.db import model
from tailbone.views import MasterView from tailbone.views import MasterView
class DepositLinksView(MasterView): class DepositLinkView(MasterView):
""" """
Master view for deposit links. Master view for deposit links.
""" """
@ -52,7 +52,7 @@ class DepositLinksView(MasterView):
] ]
def configure_grid(self, g): def configure_grid(self, g):
super(DepositLinksView, self).configure_grid(g) super(DepositLinkView, self).configure_grid(g)
g.filters['description'].default_active = True g.filters['description'].default_active = True
g.filters['description'].default_verb = 'contains' g.filters['description'].default_verb = 'contains'
g.set_sort_defaults('code') g.set_sort_defaults('code')
@ -60,6 +60,9 @@ class DepositLinksView(MasterView):
g.set_link('code') g.set_link('code')
g.set_link('description') g.set_link('description')
# TODO: deprecate / remove this
DepositLinksView = DepositLinkView
def includeme(config): def includeme(config):
DepositLinksView.defaults(config) DepositLinkView.defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2020 Lance Edgar # Copyright © 2010-2021 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -40,7 +40,7 @@ from tailbone.db import Session
from tailbone.views import View, MasterView from tailbone.views import View, MasterView
class ProfilesView(MasterView): class EmailSettingView(MasterView):
""" """
Master view for email admin (settings/preview). Master view for email admin (settings/preview).
""" """
@ -76,7 +76,7 @@ class ProfilesView(MasterView):
] ]
def __init__(self, request): def __init__(self, request):
super(ProfilesView, self).__init__(request) super(EmailSettingView, self).__init__(request)
self.handler = self.get_handler() self.handler = self.get_handler()
def get_handler(self): def get_handler(self):
@ -159,7 +159,7 @@ class ProfilesView(MasterView):
return True return True
def configure_form(self, f): def configure_form(self, f):
super(ProfilesView, self).configure_form(f) super(EmailSettingView, self).configure_form(f)
profile = f.model_instance['_email'] profile = f.model_instance['_email']
# key # key
@ -222,6 +222,9 @@ class ProfilesView(MasterView):
kwargs['email'] = self.handler.get_email(key) kwargs['email'] = self.handler.get_email(key)
return kwargs return kwargs
# TODO: deprecate / remove this
ProfilesView = EmailSettingView
class RecipientsType(colander.String): class RecipientsType(colander.String):
""" """
@ -396,6 +399,6 @@ class EmailAttemptView(MasterView):
def includeme(config): def includeme(config):
ProfilesView.defaults(config) EmailSettingView.defaults(config)
EmailPreview.defaults(config) EmailPreview.defaults(config)
EmailAttemptView.defaults(config) EmailAttemptView.defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2019 Lance Edgar # Copyright © 2010-2021 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -40,7 +40,7 @@ from tailbone.db import Session
from tailbone.views import MasterView, AutocompleteView from tailbone.views import MasterView, AutocompleteView
class EmployeesView(MasterView): class EmployeeView(MasterView):
""" """
Master view for the Employee class. Master view for the Employee class.
""" """
@ -80,7 +80,7 @@ class EmployeesView(MasterView):
] ]
def configure_grid(self, g): def configure_grid(self, g):
super(EmployeesView, self).configure_grid(g) super(EmployeeView, self).configure_grid(g)
route_prefix = self.get_route_prefix() route_prefix = self.get_route_prefix()
# phone # phone
@ -181,7 +181,7 @@ class EmployeesView(MasterView):
return not self.is_employee_protected(employee) return not self.is_employee_protected(employee)
def configure_form(self, f): def configure_form(self, f):
super(EmployeesView, self).configure_form(f) super(EmployeeView, self).configure_form(f)
employee = f.model_instance employee = f.model_instance
f.set_renderer('person', self.render_person) f.set_renderer('person', self.render_person)
@ -230,7 +230,7 @@ class EmployeesView(MasterView):
def objectify(self, form, data=None): def objectify(self, form, data=None):
if data is None: if data is None:
data = form.validated data = form.validated
employee = super(EmployeesView, self).objectify(form, data) employee = super(EmployeeView, self).objectify(form, data)
self.update_stores(employee, data) self.update_stores(employee, data)
self.update_departments(employee, data) self.update_departments(employee, data)
return employee return employee
@ -304,6 +304,9 @@ class EmployeesView(MasterView):
(model.EmployeeDepartment, 'employee_uuid'), (model.EmployeeDepartment, 'employee_uuid'),
] ]
# TODO: deprecate / remove this
EmployeesView = EmployeeView
class EmployeesAutocomplete(AutocompleteView): class EmployeesAutocomplete(AutocompleteView):
""" """
@ -328,4 +331,4 @@ def includeme(config):
config.add_view(EmployeesAutocomplete, route_name='employees.autocomplete', config.add_view(EmployeesAutocomplete, route_name='employees.autocomplete',
renderer='json', permission='employees.list') renderer='json', permission='employees.list')
EmployeesView.defaults(config) EmployeeView.defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2018 Lance Edgar # Copyright © 2010-2021 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -31,7 +31,7 @@ from rattail.db import model
from tailbone.views import MasterView from tailbone.views import MasterView
class FamiliesView(MasterView): class FamilyView(MasterView):
""" """
Master view for the Family class. Master view for the Family class.
""" """
@ -52,11 +52,14 @@ class FamiliesView(MasterView):
] ]
def configure_grid(self, g): def configure_grid(self, g):
super(FamiliesView, self).configure_grid(g) super(FamilyView, self).configure_grid(g)
g.filters['name'].default_active = True g.filters['name'].default_active = True
g.filters['name'].default_verb = 'contains' g.filters['name'].default_verb = 'contains'
g.set_sort_defaults('code') g.set_sort_defaults('code')
# TODO: deprecate / remove this
FamiliesView = FamilyView
def includeme(config): def includeme(config):
FamiliesView.defaults(config) FamilyView.defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2018 Lance Edgar # Copyright © 2010-2021 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -33,7 +33,7 @@ import colander
from tailbone.views import MasterView from tailbone.views import MasterView
class InventoryAdjustmentReasonsView(MasterView): class InventoryAdjustmentReasonView(MasterView):
""" """
Master view for inventory adjustment reasons. Master view for inventory adjustment reasons.
""" """
@ -48,11 +48,11 @@ class InventoryAdjustmentReasonsView(MasterView):
] ]
def configure_grid(self, g): def configure_grid(self, g):
super(InventoryAdjustmentReasonsView, self).configure_grid(g) super(InventoryAdjustmentReasonView, self).configure_grid(g)
g.set_sort_defaults('code') g.set_sort_defaults('code')
def configure_form(self, f): def configure_form(self, f):
super(InventoryAdjustmentReasonsView, self).configure_form(f) super(InventoryAdjustmentReasonView, self).configure_form(f)
# code # code
f.set_validator('code', self.unique_code) f.set_validator('code', self.unique_code)
@ -66,6 +66,9 @@ class InventoryAdjustmentReasonsView(MasterView):
if query.count(): if query.count():
raise colander.Invalid(node, "Code must be unique") raise colander.Invalid(node, "Code must be unique")
# TODO: deprecate / remove this
InventoryAdjustmentReasonsView = InventoryAdjustmentReasonView
def includeme(config): def includeme(config):
InventoryAdjustmentReasonsView.defaults(config) InventoryAdjustmentReasonView.defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2019 Lance Edgar # Copyright © 2010-2021 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -34,7 +34,7 @@ from tailbone import forms
from tailbone.views import MasterView from tailbone.views import MasterView
class ProfilesView(MasterView): class LabelProfileView(MasterView):
""" """
Master view for the LabelProfile model. Master view for the LabelProfile model.
""" """
@ -63,14 +63,14 @@ class ProfilesView(MasterView):
] ]
def configure_grid(self, g): def configure_grid(self, g):
super(ProfilesView, self).configure_grid(g) super(LabelProfileView, self).configure_grid(g)
g.set_sort_defaults('ordinal') g.set_sort_defaults('ordinal')
g.set_type('visible', 'boolean') g.set_type('visible', 'boolean')
g.set_link('code') g.set_link('code')
g.set_link('description') g.set_link('description')
def configure_form(self, f): def configure_form(self, f):
super(ProfilesView, self).configure_form(f) super(LabelProfileView, self).configure_form(f)
# format # format
f.set_type('format', 'codeblock') f.set_type('format', 'codeblock')
@ -167,6 +167,9 @@ class ProfilesView(MasterView):
config.add_view(cls, attr='printer_settings', route_name='{}.printer_settings'.format(route_prefix), config.add_view(cls, attr='printer_settings', route_name='{}.printer_settings'.format(route_prefix),
permission='{}.edit'.format(permission_prefix)) permission='{}.edit'.format(permission_prefix))
# TODO: deprecate / remove this
ProfilesView = LabelProfileView
def includeme(config): def includeme(config):
ProfilesView.defaults(config) LabelProfileView.defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2019 Lance Edgar # Copyright © 2010-2021 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -42,7 +42,7 @@ from tailbone.views import MasterView
from tailbone.util import raw_datetime from tailbone.util import raw_datetime
class MessagesView(MasterView): class MessageView(MasterView):
""" """
Base class for message views. Base class for message views.
""" """
@ -87,12 +87,12 @@ class MessagesView(MasterView):
def index(self): def index(self):
if not self.request.user: if not self.request.user:
raise httpexceptions.HTTPForbidden raise httpexceptions.HTTPForbidden
return super(MessagesView, self).index() return super(MessageView, self).index()
def get_instance(self): def get_instance(self):
if not self.request.user: if not self.request.user:
raise httpexceptions.HTTPForbidden raise httpexceptions.HTTPForbidden
message = super(MessagesView, self).get_instance() message = super(MessageView, self).get_instance()
if not self.associated_with(message): if not self.associated_with(message):
raise httpexceptions.HTTPForbidden raise httpexceptions.HTTPForbidden
return message return message
@ -204,7 +204,7 @@ class MessagesView(MasterView):
# TODO!! # TODO!!
# def make_form(self, instance, **kwargs): # def make_form(self, instance, **kwargs):
# form = super(MessagesView, self).make_form(instance, **kwargs) # form = super(MessageView, self).make_form(instance, **kwargs)
# if self.creating: # if self.creating:
# form.id = 'new-message' # form.id = 'new-message'
# form.cancel_url = self.request.get_referrer(default=self.request.route_url('messages.inbox')) # form.cancel_url = self.request.get_referrer(default=self.request.route_url('messages.inbox'))
@ -212,7 +212,7 @@ class MessagesView(MasterView):
# return form # return form
def configure_form(self, f): def configure_form(self, f):
super(MessagesView, self).configure_form(f) super(MessageView, self).configure_form(f)
use_buefy = self.get_use_buefy() use_buefy = self.get_use_buefy()
f.submit_label = "Send Message" f.submit_label = "Send Message"
@ -293,7 +293,7 @@ class MessagesView(MasterView):
def objectify(self, form, data=None): def objectify(self, form, data=None):
if data is None: if data is None:
data = form.validated data = form.validated
message = super(MessagesView, self).objectify(form, data) message = super(MessageView, self).objectify(form, data)
if self.creating: if self.creating:
if self.request.user: if self.request.user:
@ -469,8 +469,11 @@ class MessagesView(MasterView):
cls._defaults(config) cls._defaults(config)
# TODO: deprecate / remove this
MessagesView = MessageView
class InboxView(MessagesView):
class InboxView(MessageView):
""" """
Inbox message view. Inbox message view.
""" """
@ -486,7 +489,7 @@ class InboxView(MessagesView):
return q.filter(model.MessageRecipient.status == self.enum.MESSAGE_STATUS_INBOX) return q.filter(model.MessageRecipient.status == self.enum.MESSAGE_STATUS_INBOX)
class ArchiveView(MessagesView): class ArchiveView(MessageView):
""" """
Archived message view. Archived message view.
""" """
@ -502,7 +505,7 @@ class ArchiveView(MessagesView):
return q.filter(model.MessageRecipient.status == self.enum.MESSAGE_STATUS_ARCHIVE) return q.filter(model.MessageRecipient.status == self.enum.MESSAGE_STATUS_ARCHIVE)
class SentView(MessagesView): class SentView(MessageView):
""" """
Sent messages view. Sent messages view.
""" """
@ -585,4 +588,4 @@ def includeme(config):
config.add_view(SentView, attr='index', route_name='messages.sent', config.add_view(SentView, attr='index', route_name='messages.sent',
permission='messages.list') permission='messages.list')
MessagesView.defaults(config) MessageView.defaults(config)

View file

@ -44,7 +44,7 @@ from tailbone import forms, grids
from tailbone.views import MasterView, AutocompleteView from tailbone.views import MasterView, AutocompleteView
class PeopleView(MasterView): class PersonView(MasterView):
""" """
Master view for the Person class. Master view for the Person class.
""" """
@ -111,7 +111,7 @@ class PeopleView(MasterView):
] ]
def configure_grid(self, g): def configure_grid(self, g):
super(PeopleView, self).configure_grid(g) super(PersonView, self).configure_grid(g)
g.joiners['email'] = lambda q: q.outerjoin(model.PersonEmailAddress, sa.and_( g.joiners['email'] = lambda q: q.outerjoin(model.PersonEmailAddress, sa.and_(
model.PersonEmailAddress.parent_uuid == model.Person.uuid, model.PersonEmailAddress.parent_uuid == model.Person.uuid,
@ -184,7 +184,7 @@ class PeopleView(MasterView):
data = form.validated data = form.validated
# do normal create/update # do normal create/update
person = super(PeopleView, self).objectify(form, data) person = super(PersonView, self).objectify(form, data)
# collect data from all name fields # collect data from all name fields
names = {} names = {}
@ -227,7 +227,7 @@ class PeopleView(MasterView):
customer._people.reorder() customer._people.reorder()
# continue with normal logic # continue with normal logic
super(PeopleView, self).delete_instance(person) super(PersonView, self).delete_instance(person)
def touch_instance(self, person): def touch_instance(self, person):
""" """
@ -237,7 +237,7 @@ class PeopleView(MasterView):
contact info record associated with them. contact info record associated with them.
""" """
# touch person, as per usual # touch person, as per usual
super(PeopleView, self).touch_instance(person) super(PersonView, self).touch_instance(person)
def touch(obj): def touch(obj):
change = model.Change() change = model.Change()
@ -259,7 +259,7 @@ class PeopleView(MasterView):
touch(address) touch(address)
def configure_common_form(self, f): def configure_common_form(self, f):
super(PeopleView, self).configure_common_form(f) super(PersonView, self).configure_common_form(f)
person = f.model_instance person = f.model_instance
f.set_label('display_name', "Full Name") f.set_label('display_name', "Full Name")
@ -800,6 +800,9 @@ class PeopleView(MasterView):
config.add_view(cls, attr='make_user', route_name='{}.make_user'.format(route_prefix), config.add_view(cls, attr='make_user', route_name='{}.make_user'.format(route_prefix),
permission='users.create') permission='users.create')
# TODO: deprecate / remove this
PeopleView = PersonView
class PeopleAutocomplete(AutocompleteView): class PeopleAutocomplete(AutocompleteView):
@ -918,5 +921,5 @@ def includeme(config):
config.add_view(PeopleEmployeesAutocomplete, route_name='people.autocomplete.employees', config.add_view(PeopleEmployeesAutocomplete, route_name='people.autocomplete.employees',
renderer='json', permission='people.list') renderer='json', permission='people.list')
PeopleView.defaults(config) PersonView.defaults(config)
PersonNoteView.defaults(config) PersonNoteView.defaults(config)

View file

@ -77,7 +77,7 @@ log = logging.getLogger(__name__)
# return query # return query
class ProductsView(MasterView): class ProductView(MasterView):
""" """
Master view for the Product class. Master view for the Product class.
""" """
@ -171,7 +171,7 @@ class ProductsView(MasterView):
CurrentPrice = orm.aliased(model.ProductPrice) CurrentPrice = orm.aliased(model.ProductPrice)
def __init__(self, request): def __init__(self, request):
super(ProductsView, self).__init__(request) super(ProductView, self).__init__(request)
self.print_labels = request.rattail_config.getbool('tailbone', 'products.print_labels', default=False) self.print_labels = request.rattail_config.getbool('tailbone', 'products.print_labels', default=False)
def query(self, session): def query(self, session):
@ -201,7 +201,7 @@ class ProductsView(MasterView):
return query return query
def configure_grid(self, g): def configure_grid(self, g):
super(ProductsView, self).configure_grid(g) super(ProductView, self).configure_grid(g)
def join_vendor(q): def join_vendor(q):
return q.outerjoin(self.ProductVendorCost, return q.outerjoin(self.ProductVendorCost,
@ -342,7 +342,7 @@ class ProductsView(MasterView):
g.set_label('vendor', "Pref. Vendor") g.set_label('vendor', "Pref. Vendor")
def configure_common_form(self, f): def configure_common_form(self, f):
super(ProductsView, self).configure_common_form(f) super(ProductView, self).configure_common_form(f)
product = f.model_instance product = f.model_instance
# upc # upc
@ -594,7 +594,7 @@ class ProductsView(MasterView):
return ' '.join(classes) return ' '.join(classes)
def get_xlsx_fields(self): def get_xlsx_fields(self):
fields = super(ProductsView, self).get_xlsx_fields() fields = super(ProductView, self).get_xlsx_fields()
i = fields.index('department_uuid') i = fields.index('department_uuid')
fields.insert(i + 1, 'department_number') fields.insert(i + 1, 'department_number')
@ -640,7 +640,7 @@ class ProductsView(MasterView):
return fields return fields
def get_xlsx_row(self, product, fields): def get_xlsx_row(self, product, fields):
row = super(ProductsView, self).get_xlsx_row(product, fields) row = super(ProductView, self).get_xlsx_row(product, fields)
if 'upc' in fields and isinstance(row['upc'], GPC): if 'upc' in fields and isinstance(row['upc'], GPC):
row['upc'] = row['upc'].pretty() row['upc'] = row['upc'].pretty()
@ -710,7 +710,7 @@ class ProductsView(MasterView):
raise httpexceptions.HTTPNotFound() raise httpexceptions.HTTPNotFound()
def configure_form(self, f): def configure_form(self, f):
super(ProductsView, self).configure_form(f) super(ProductView, self).configure_form(f)
product = f.model_instance product = f.model_instance
# department # department
@ -880,7 +880,7 @@ class ProductsView(MasterView):
def objectify(self, form, data=None): def objectify(self, form, data=None):
if data is None: if data is None:
data = form.validated data = form.validated
product = super(ProductsView, self).objectify(form, data=data) product = super(ProductView, self).objectify(form, data=data)
# regular_price_amount # regular_price_amount
if (self.creating or self.editing) and 'regular_price_amount' in form.fields: if (self.creating or self.editing) and 'regular_price_amount' in form.fields:
@ -1792,6 +1792,9 @@ class ProductsView(MasterView):
config.add_route('mobile.products.quick_lookup', '/mobile/products/quick-lookup') config.add_route('mobile.products.quick_lookup', '/mobile/products/quick-lookup')
config.add_view(cls, attr='mobile_quick_lookup', route_name='mobile.products.quick_lookup') config.add_view(cls, attr='mobile_quick_lookup', route_name='mobile.products.quick_lookup')
# TODO: deprecate / remove this
ProductsView = ProductView
class ProductsAutocomplete(AutocompleteView): class ProductsAutocomplete(AutocompleteView):
""" """
@ -1853,4 +1856,4 @@ def includeme(config):
config.add_view(print_labels, route_name='products.print_labels', config.add_view(print_labels, route_name='products.print_labels',
renderer='json', permission='products.print_labels') renderer='json', permission='products.print_labels')
ProductsView.defaults(config) ProductView.defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2018 Lance Edgar # Copyright © 2010-2021 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -31,7 +31,7 @@ from rattail.db import model
from tailbone.views import MasterView from tailbone.views import MasterView
class ReportCodesView(MasterView): class ReportCodeView(MasterView):
""" """
Master view for the ReportCode class. Master view for the ReportCode class.
""" """
@ -51,13 +51,16 @@ class ReportCodesView(MasterView):
] ]
def configure_grid(self, g): def configure_grid(self, g):
super(ReportCodesView, self).configure_grid(g) super(ReportCodeView, self).configure_grid(g)
g.filters['name'].default_active = True g.filters['name'].default_active = True
g.filters['name'].default_verb = 'contains' g.filters['name'].default_verb = 'contains'
g.set_sort_defaults('code') g.set_sort_defaults('code')
g.set_link('code') g.set_link('code')
g.set_link('name') g.set_link('name')
# TODO: deprecate / remove this
ReportCodesView = ReportCodeView
def includeme(config): def includeme(config):
ReportCodesView.defaults(config) ReportCodeView.defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2020 Lance Edgar # Copyright © 2010-2021 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -46,7 +46,7 @@ from tailbone.db import Session
from tailbone.views.principal import PrincipalMasterView, PermissionsRenderer from tailbone.views.principal import PrincipalMasterView, PermissionsRenderer
class RolesView(PrincipalMasterView): class RoleView(PrincipalMasterView):
""" """
Master view for the Role model. Master view for the Role model.
""" """
@ -67,7 +67,7 @@ class RolesView(PrincipalMasterView):
] ]
def configure_grid(self, g): def configure_grid(self, g):
super(RolesView, self).configure_grid(g) super(RoleView, self).configure_grid(g)
# name # name
g.filters['name'].default_active = True g.filters['name'].default_active = True
@ -139,7 +139,7 @@ class RolesView(PrincipalMasterView):
raise colander.Invalid(node, "Name must be unique") raise colander.Invalid(node, "Name must be unique")
def configure_form(self, f): def configure_form(self, f):
super(RolesView, self).configure_form(f) super(RoleView, self).configure_form(f)
role = f.model_instance role = f.model_instance
use_buefy = self.get_use_buefy() use_buefy = self.get_use_buefy()
@ -226,7 +226,7 @@ class RolesView(PrincipalMasterView):
""" """
if data is None: if data is None:
data = form.validated data = form.validated
role = super(RolesView, self).objectify(form, data) role = super(RoleView, self).objectify(form, data)
self.update_permissions(role, data['permissions']) self.update_permissions(role, data['permissions'])
return role return role
@ -373,6 +373,9 @@ class RolesView(PrincipalMasterView):
config.add_view(cls, attr='download_permissions_matrix', route_name='{}.download_permissions_matrix'.format(route_prefix), config.add_view(cls, attr='download_permissions_matrix', route_name='{}.download_permissions_matrix'.format(route_prefix),
permission='{}.download_permissions_matrix'.format(permission_prefix)) permission='{}.download_permissions_matrix'.format(permission_prefix))
# TODO: deprecate / remove this
RolesView = RoleView
class PermissionsWidget(dfwidget.Widget): class PermissionsWidget(dfwidget.Widget):
template = 'permissions' template = 'permissions'
@ -396,4 +399,4 @@ class PermissionsWidget(dfwidget.Widget):
def includeme(config): def includeme(config):
RolesView.defaults(config) RoleView.defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2020 Lance Edgar # Copyright © 2010-2021 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -43,7 +43,7 @@ from tailbone.db import Session
from tailbone.views import MasterView, View from tailbone.views import MasterView, View
class SettingsView(MasterView): class SettingView(MasterView):
""" """
Master view for the settings model. Master view for the settings model.
""" """
@ -59,14 +59,14 @@ class SettingsView(MasterView):
] ]
def configure_grid(self, g): def configure_grid(self, g):
super(SettingsView, self).configure_grid(g) super(SettingView, self).configure_grid(g)
g.filters['name'].default_active = True g.filters['name'].default_active = True
g.filters['name'].default_verb = 'contains' g.filters['name'].default_verb = 'contains'
g.set_sort_defaults('name') g.set_sort_defaults('name')
g.set_link('name') g.set_link('name')
def configure_form(self, f): def configure_form(self, f):
super(SettingsView, self).configure_form(f) super(SettingView, self).configure_form(f)
if self.creating: if self.creating:
f.set_validator('name', self.unique_name) f.set_validator('name', self.unique_name)
@ -85,6 +85,9 @@ class SettingsView(MasterView):
return not bool(self.feedback.match(setting.name)) return not bool(self.feedback.match(setting.name))
return True return True
# TODO: deprecate / remove this
SettingsView = SettingView
class AppSettingsForm(forms.Form): class AppSettingsForm(forms.Form):
@ -267,4 +270,4 @@ class AppSettingsView(View):
def includeme(config): def includeme(config):
AppSettingsView.defaults(config) AppSettingsView.defaults(config)
SettingsView.defaults(config) SettingView.defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2018 Lance Edgar # Copyright © 2010-2021 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -48,7 +48,7 @@ def render_shift_length(shift, field):
return HTML.tag('span', title="{} hrs".format(hours_as_decimal(length)), c=[pretty_hours(length)]) return HTML.tag('span', title="{} hrs".format(hours_as_decimal(length)), c=[pretty_hours(length)])
class ScheduledShiftsView(MasterView): class ScheduledShiftView(MasterView):
""" """
Master view for employee scheduled shifts. Master view for employee scheduled shifts.
""" """
@ -83,12 +83,15 @@ class ScheduledShiftsView(MasterView):
g.set_label('employee', "Employee Name") g.set_label('employee', "Employee Name")
def configure_form(self, f): def configure_form(self, f):
super(ScheduledShiftsView, self).configure_form(f) super(ScheduledShiftView, self).configure_form(f)
f.set_renderer('length', render_shift_length) f.set_renderer('length', render_shift_length)
# TODO: deprecate / remove this
ScheduledShiftsView = ScheduledShiftView
class WorkedShiftsView(MasterView):
class WorkedShiftView(MasterView):
""" """
Master view for employee worked shifts. Master view for employee worked shifts.
""" """
@ -114,7 +117,7 @@ class WorkedShiftsView(MasterView):
] ]
def configure_grid(self, g): def configure_grid(self, g):
super(WorkedShiftsView, self).configure_grid(g) super(WorkedShiftView, self).configure_grid(g)
g.joiners['employee'] = lambda q: q.join(model.Employee).join(model.Person) g.joiners['employee'] = lambda q: q.join(model.Employee).join(model.Person)
g.filters['employee'] = g.make_filter('employee', model.Person.display_name) g.filters['employee'] = g.make_filter('employee', model.Person.display_name)
@ -146,7 +149,7 @@ class WorkedShiftsView(MasterView):
return "WorkedShift: {}, {}".format(shift.employee, date) return "WorkedShift: {}, {}".format(shift.employee, date)
def configure_form(self, f): def configure_form(self, f):
super(WorkedShiftsView, self).configure_form(f) super(WorkedShiftView, self).configure_form(f)
f.set_readonly('employee') f.set_readonly('employee')
f.set_renderer('employee', self.render_employee) f.set_renderer('employee', self.render_employee)
@ -164,7 +167,7 @@ class WorkedShiftsView(MasterView):
return tags.link_to(text, url) return tags.link_to(text, url)
def get_xlsx_fields(self): def get_xlsx_fields(self):
fields = super(WorkedShiftsView, self).get_xlsx_fields() fields = super(WorkedShiftView, self).get_xlsx_fields()
# add employee name # add employee name
i = fields.index('employee_uuid') i = fields.index('employee_uuid')
@ -176,7 +179,7 @@ class WorkedShiftsView(MasterView):
return fields return fields
def get_xlsx_row(self, shift, fields): def get_xlsx_row(self, shift, fields):
row = super(WorkedShiftsView, self).get_xlsx_row(shift, fields) row = super(WorkedShiftView, self).get_xlsx_row(shift, fields)
# localize start and end times (Excel requires time with no zone) # localize start and end times (Excel requires time with no zone)
if shift.punch_in: if shift.punch_in:
@ -200,7 +203,10 @@ class WorkedShiftsView(MasterView):
return row return row
# TODO: deprecate / remove this
WorkedShiftsView = WorkedShiftView
def includeme(config): def includeme(config):
ScheduledShiftsView.defaults(config) ScheduledShiftView.defaults(config)
WorkedShiftsView.defaults(config) WorkedShiftView.defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2019 Lance Edgar # Copyright © 2010-2021 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -36,7 +36,7 @@ from tailbone import grids
from tailbone.views import MasterView from tailbone.views import MasterView
class StoresView(MasterView): class StoreView(MasterView):
""" """
Master view for the Store class. Master view for the Store class.
""" """
@ -65,7 +65,7 @@ class StoresView(MasterView):
} }
def configure_grid(self, g): def configure_grid(self, g):
super(StoresView, self).configure_grid(g) super(StoreView, self).configure_grid(g)
g.set_joiner('email', lambda q: q.outerjoin(model.StoreEmailAddress, sa.and_( g.set_joiner('email', lambda q: q.outerjoin(model.StoreEmailAddress, sa.and_(
model.StoreEmailAddress.parent_uuid == model.Store.uuid, model.StoreEmailAddress.parent_uuid == model.Store.uuid,
@ -88,7 +88,7 @@ class StoresView(MasterView):
g.set_link('name') g.set_link('name')
def configure_form(self, f): def configure_form(self, f):
super(StoresView, self).configure_form(f) super(StoreView, self).configure_form(f)
f.remove_field('employees') f.remove_field('employees')
f.remove_field('phones') f.remove_field('phones')
@ -107,6 +107,9 @@ class StoresView(MasterView):
(model.StoreEmailAddress, 'parent_uuid'), (model.StoreEmailAddress, 'parent_uuid'),
] ]
# TODO: deprecate / remove this
StoresView = StoreView
def includeme(config): def includeme(config):
StoresView.defaults(config) StoreView.defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2020 Lance Edgar # Copyright © 2010-2021 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -32,7 +32,7 @@ from tailbone.db import Session
from tailbone.views import MasterView from tailbone.views import MasterView
class SubdepartmentsView(MasterView): class SubdepartmentView(MasterView):
""" """
Master view for the Subdepartment class. Master view for the Subdepartment class.
""" """
@ -58,7 +58,7 @@ class SubdepartmentsView(MasterView):
] ]
def configure_grid(self, g): def configure_grid(self, g):
super(SubdepartmentsView, self).configure_grid(g) super(SubdepartmentView, self).configure_grid(g)
# name # name
g.filters['name'].default_active = True g.filters['name'].default_active = True
@ -74,7 +74,7 @@ class SubdepartmentsView(MasterView):
g.set_link('name') g.set_link('name')
def configure_form(self, f): def configure_form(self, f):
super(SubdepartmentsView, self).configure_form(f) super(SubdepartmentView, self).configure_form(f)
f.remove_field('products') f.remove_field('products')
# TODO: figure out this dang department situation.. # TODO: figure out this dang department situation..
@ -98,6 +98,9 @@ class SubdepartmentsView(MasterView):
Session.delete(removing) Session.delete(removing)
# TODO: deprecate / remove this
SubdepartmentsView = SubdepartmentView
def includeme(config): def includeme(config):
SubdepartmentsView.defaults(config) SubdepartmentView.defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2020 Lance Edgar # Copyright © 2010-2021 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -29,7 +29,7 @@ from __future__ import unicode_literals, absolute_import
from tailbone.views import MasterView from tailbone.views import MasterView
class TablesView(MasterView): class TableView(MasterView):
""" """
Master view for tables Master view for tables
""" """
@ -70,6 +70,9 @@ class TablesView(MasterView):
g.sorters['row_count'] = g.make_simple_sorter('row_count') g.sorters['row_count'] = g.make_simple_sorter('row_count')
g.set_sort_defaults('name') g.set_sort_defaults('name')
# TODO: deprecate / remove this
TablesView = TableView
def includeme(config): def includeme(config):
TablesView.defaults(config) TableView.defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2018 Lance Edgar # Copyright © 2010-2021 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -31,7 +31,7 @@ from rattail.db import model
from tailbone.views import MasterView from tailbone.views import MasterView
class TaxesView(MasterView): class TaxView(MasterView):
""" """
Master view for taxes. Master view for taxes.
""" """
@ -53,13 +53,16 @@ class TaxesView(MasterView):
] ]
def configure_grid(self, g): def configure_grid(self, g):
super(TaxesView, self).configure_grid(g) super(TaxView, self).configure_grid(g)
g.filters['description'].default_active = True g.filters['description'].default_active = True
g.filters['description'].default_verb = 'contains' g.filters['description'].default_verb = 'contains'
g.set_sort_defaults('code') g.set_sort_defaults('code')
g.set_link('code') g.set_link('code')
g.set_link('description') g.set_link('description')
# TODO: deprecate / remove this
TaxesView = TaxView
def includeme(config): def includeme(config):
TaxesView.defaults(config) TaxView.defaults(config)

View file

@ -44,7 +44,7 @@ from tailbone.views import MasterView
from tailbone.views.principal import PrincipalMasterView, PermissionsRenderer from tailbone.views.principal import PrincipalMasterView, PermissionsRenderer
class UsersView(PrincipalMasterView): class UserView(PrincipalMasterView):
""" """
Master view for the User model. Master view for the User model.
""" """
@ -96,7 +96,7 @@ class UsersView(PrincipalMasterView):
] ]
def query(self, session): def query(self, session):
query = super(UsersView, self).query(session) query = super(UserView, self).query(session)
# bring in the related Person(s) # bring in the related Person(s)
query = query.outerjoin(model.Person)\ query = query.outerjoin(model.Person)\
@ -105,7 +105,7 @@ class UsersView(PrincipalMasterView):
return query return query
def configure_grid(self, g): def configure_grid(self, g):
super(UsersView, self).configure_grid(g) super(UserView, self).configure_grid(g)
del g.filters['salt'] del g.filters['salt']
g.filters['username'].default_active = True g.filters['username'].default_active = True
@ -163,7 +163,7 @@ class UsersView(PrincipalMasterView):
raise colander.Invalid(node, "Username must be unique") raise colander.Invalid(node, "Username must be unique")
def configure_form(self, f): def configure_form(self, f):
super(UsersView, self).configure_form(f) super(UserView, self).configure_form(f)
user = f.model_instance user = f.model_instance
# username # username
@ -264,7 +264,7 @@ class UsersView(PrincipalMasterView):
# create/update user as per normal # create/update user as per normal
if data is None: if data is None:
data = form.validated data = form.validated
user = super(UsersView, self).objectify(form, data) user = super(UserView, self).objectify(form, data)
# create/update person as needed # create/update person as needed
names = {} names = {}
@ -356,7 +356,7 @@ class UsersView(PrincipalMasterView):
.filter(model.UserEvent.user == user) .filter(model.UserEvent.user == user)
def configure_row_grid(self, g): def configure_row_grid(self, g):
super(UsersView, self).configure_row_grid(g) super(UserView, self).configure_row_grid(g)
g.width = 'half' g.width = 'half'
g.filterable = False g.filterable = False
g.set_sort_defaults('occurred', 'desc') g.set_sort_defaults('occurred', 'desc')
@ -397,7 +397,7 @@ class UsersView(PrincipalMasterView):
} }
def get_merge_resulting_data(self, remove, keep): def get_merge_resulting_data(self, remove, keep):
result = super(UsersView, self).get_merge_resulting_data(remove, keep) result = super(UserView, self).get_merge_resulting_data(remove, keep)
result['role_count'] = len(set(remove['_roles'] + keep['_roles'])) result['role_count'] = len(set(remove['_roles'] + keep['_roles']))
return result return result
@ -428,8 +428,11 @@ class UsersView(PrincipalMasterView):
config.add_tailbone_permission(permission_prefix, '{}.edit_roles'.format(permission_prefix), config.add_tailbone_permission(permission_prefix, '{}.edit_roles'.format(permission_prefix),
"Edit the Roles to which a {} belongs".format(model_title)) "Edit the Roles to which a {} belongs".format(model_title))
# TODO: deprecate / remove this
UsersView = UserView
class UserEventsView(MasterView):
class UserEventView(MasterView):
""" """
Master view for all user events Master view for all user events
""" """
@ -448,11 +451,11 @@ class UserEventsView(MasterView):
] ]
def get_data(self, session=None): def get_data(self, session=None):
query = super(UserEventsView, self).get_data(session=session) query = super(UserEventView, self).get_data(session=session)
return query.join(model.User) return query.join(model.User)
def configure_grid(self, g): def configure_grid(self, g):
super(UserEventsView, self).configure_grid(g) super(UserEventView, self).configure_grid(g)
g.set_joiner('person', lambda q: q.outerjoin(model.Person)) g.set_joiner('person', lambda q: q.outerjoin(model.Person))
g.set_sorter('user', model.User.username) g.set_sorter('user', model.User.username)
g.set_sorter('person', model.Person.display_name) g.set_sorter('person', model.Person.display_name)
@ -473,7 +476,10 @@ class UserEventsView(MasterView):
if event.user.person: if event.user.person:
return event.user.person.display_name return event.user.person.display_name
# TODO: deprecate / remove this
UserEventsView = UserEventView
def includeme(config): def includeme(config):
UsersView.defaults(config) UserView.defaults(config)
UserEventsView.defaults(config) UserEventView.defaults(config)

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2018 Lance Edgar # Copyright © 2010-2021 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -35,7 +35,7 @@ from webhelpers2.html import tags
from tailbone.views import MasterView, AutocompleteView from tailbone.views import MasterView, AutocompleteView
class VendorsView(MasterView): class VendorView(MasterView):
""" """
Master view for the Vendor class. Master view for the Vendor class.
""" """
@ -72,7 +72,7 @@ class VendorsView(MasterView):
] ]
def configure_grid(self, g): def configure_grid(self, g):
super(VendorsView, self).configure_grid(g) super(VendorView, self).configure_grid(g)
g.filters['name'].default_active = True g.filters['name'].default_active = True
g.filters['name'].default_verb = 'contains' g.filters['name'].default_verb = 'contains'
@ -86,7 +86,7 @@ class VendorsView(MasterView):
g.set_link('abbreviation') g.set_link('abbreviation')
def configure_form(self, f): def configure_form(self, f):
super(VendorsView, self).configure_form(f) super(VendorView, self).configure_form(f)
vendor = f.model_instance vendor = f.model_instance
# default_phone # default_phone
@ -114,7 +114,7 @@ class VendorsView(MasterView):
def objectify(self, form, data=None): def objectify(self, form, data=None):
if data is None: if data is None:
data = form.validated data = form.validated
vendor = super(VendorsView, self).objectify(form, data) vendor = super(VendorView, self).objectify(form, data)
vendor = self.objectify_contact(vendor, data) vendor = self.objectify_contact(vendor, data)
if 'orders_email' in data: if 'orders_email' in data:
@ -164,6 +164,9 @@ class VendorsView(MasterView):
(model.VendorContact, 'vendor_uuid'), (model.VendorContact, 'vendor_uuid'),
] ]
# TODO: deprecate / remove this
VendorsView = VendorView
class VendorsAutocomplete(AutocompleteView): class VendorsAutocomplete(AutocompleteView):
@ -178,4 +181,4 @@ def includeme(config):
config.add_view(VendorsAutocomplete, route_name='vendors.autocomplete', config.add_view(VendorsAutocomplete, route_name='vendors.autocomplete',
renderer='json', permission='vendors.list') renderer='json', permission='vendors.list')
VendorsView.defaults(config) VendorView.defaults(config)