From c036932ce482479c218b12c443a4e37bfba57fd3 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sun, 14 Apr 2024 19:54:29 -0500 Subject: [PATCH] Remove several references to "buefy" name class methods, template filenames, etc. also made various edits per newer conventions --- tailbone/forms/core.py | 25 +++--- tailbone/forms/widgets.py | 3 +- tailbone/grids/core.py | 28 +++---- tailbone/templates/appsettings.mako | 2 +- .../templates/batch/importer/view_row.mako | 2 +- .../batch/inventory/desktop_form.mako | 2 +- .../batch/vendorcatalog/view_row.mako | 2 +- tailbone/templates/batch/view.mako | 4 +- tailbone/templates/customers/view.mako | 2 +- tailbone/templates/custorders/items/view.mako | 2 +- ...ipients_buefy.pt => message_recipients.pt} | 0 tailbone/templates/form.mako | 8 +- tailbone/templates/forms/deform.mako | 4 +- tailbone/templates/forms/util.mako | 7 -- tailbone/templates/master/clone.mako | 4 +- tailbone/templates/master/delete.mako | 4 +- tailbone/templates/people/view.mako | 2 +- tailbone/templates/people/view_profile.mako | 8 +- .../templates/principal/find_by_perm.mako | 6 +- tailbone/templates/products/batch.mako | 2 +- tailbone/templates/products/view.mako | 20 ++--- .../templates/receiving/declare_credit.mako | 17 ++-- tailbone/templates/receiving/receive_row.mako | 17 ++-- .../templates/reports/generated/choose.mako | 2 +- .../templates/reports/generated/generate.mako | 2 +- tailbone/templates/settings/email/view.mako | 4 +- tailbone/templates/upgrades/view.mako | 2 +- tailbone/templates/users/preferences.mako | 4 +- tailbone/views/batch/core.py | 78 +++++++++++-------- tailbone/views/batch/handheld.py | 24 +++--- tailbone/views/batch/pos.py | 4 +- tailbone/views/batch/product.py | 27 +++---- tailbone/views/customers.py | 22 +----- tailbone/views/custorders/items.py | 4 +- tailbone/views/departments.py | 2 +- tailbone/views/master.py | 58 +++++++------- tailbone/views/messages.py | 14 ++-- tailbone/views/principal.py | 12 +-- tailbone/views/products.py | 66 +++++++++------- tailbone/views/purchasing/batch.py | 7 +- tailbone/views/purchasing/ordering.py | 6 +- tailbone/views/purchasing/receiving.py | 15 ++-- tailbone/views/reports.py | 51 ++++++------ tailbone/views/roles.py | 18 +++-- tailbone/views/settings.py | 27 +++---- tailbone/views/shifts/lib.py | 36 +++++---- tailbone/views/tables.py | 24 +++--- tailbone/views/tempmon/core.py | 4 +- tailbone/views/trainwreck/base.py | 20 ++--- tailbone/views/users.py | 30 +++---- 50 files changed, 373 insertions(+), 361 deletions(-) rename tailbone/templates/deform/{message_recipients_buefy.pt => message_recipients.pt} (100%) delete mode 100644 tailbone/templates/forms/util.mako diff --git a/tailbone/forms/core.py b/tailbone/forms/core.py index aee85330..9ef8cb2b 100644 --- a/tailbone/forms/core.py +++ b/tailbone/forms/core.py @@ -33,10 +33,9 @@ from collections import OrderedDict import sqlalchemy as sa from sqlalchemy import orm from sqlalchemy.ext.associationproxy import AssociationProxy, ASSOCIATION_PROXY +from wuttjamaican.util import UNSPECIFIED -from rattail.time import localtime -from rattail.util import prettify, pretty_boolean, pretty_quantity -from rattail.core import UNSPECIFIED +from rattail.util import prettify, pretty_boolean from rattail.db.util import get_fieldnames import colander @@ -50,10 +49,10 @@ from webhelpers2.html import tags, HTML from tailbone.db import Session from tailbone.util import raw_datetime, get_form_data, render_markdown -from . import types -from .widgets import (ReadonlyWidget, PlainDateWidget, - JQueryDateWidget, JQueryTimeWidget, - MultiFileUploadWidget) +from tailbone.forms import types +from tailbone.forms.widgets import (ReadonlyWidget, PlainDateWidget, + JQueryDateWidget, JQueryTimeWidget, + MultiFileUploadWidget) from tailbone.exceptions import TailboneJSONFieldError @@ -225,7 +224,7 @@ class CustomSchemaNode(SQLAlchemySchemaNode): if excludes: overrides['excludes'] = excludes - return super(CustomSchemaNode, self).get_schema_from_relationship(prop, overrides) + return super().get_schema_from_relationship(prop, overrides) def dictify(self, obj): """ Return a dictified version of `obj` using schema information. @@ -234,7 +233,7 @@ class CustomSchemaNode(SQLAlchemySchemaNode): This method was copied from upstream and modified to add automatic handling of "association proxy" fields. """ - dict_ = super(CustomSchemaNode, self).dictify(obj) + dict_ = super().dictify(obj) for node in self: name = node.name @@ -967,7 +966,7 @@ class Form(object): kwargs.setdefault(':configure-fields-help', 'configureFieldsHelp') return HTML.tag(self.component, **kwargs) - def render_buefy_field(self, fieldname, bfield_attrs={}): + def render_field_complete(self, fieldname, bfield_attrs={}): """ Render the given field in a Buefy-compatible way. Note that this is meant to render *editable* fields, i.e. showing a @@ -1131,7 +1130,8 @@ class Form(object): value = self.obtain_value(record, field_name) if value is None: return "" - value = localtime(self.request.rattail_config, value) + app = self.get_rattail_app() + value = app.localtime(value) return raw_datetime(self.request.rattail_config, value) def render_duration(self, record, field_name): @@ -1160,7 +1160,8 @@ class Form(object): value = self.obtain_value(obj, field) if value is None: return "" - return pretty_quantity(value) + app = self.get_rattail_app() + return app.render_quantity(value) def render_percent(self, obj, field): app = self.request.rattail_config.get_app() diff --git a/tailbone/forms/widgets.py b/tailbone/forms/widgets.py index db57f4f0..63813452 100644 --- a/tailbone/forms/widgets.py +++ b/tailbone/forms/widgets.py @@ -2,7 +2,7 @@ ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2023 Lance Edgar +# Copyright © 2010-2024 Lance Edgar # # This file is part of Rattail. # @@ -153,6 +153,7 @@ class DynamicCheckboxWidget(dfwidget.CheckboxWidget): template = 'checkbox_dynamic' +# TODO: deprecate / remove this class PlainSelectWidget(dfwidget.SelectWidget): template = 'select_plain' diff --git a/tailbone/grids/core.py b/tailbone/grids/core.py index c03ac2c0..b2f90204 100644 --- a/tailbone/grids/core.py +++ b/tailbone/grids/core.py @@ -1339,10 +1339,10 @@ class Grid(object): includes the context menu items and grid tools. """ if 'grid_columns' not in kwargs: - kwargs['grid_columns'] = self.get_buefy_columns() + kwargs['grid_columns'] = self.get_table_columns() if 'grid_data' not in kwargs: - kwargs['grid_data'] = self.get_buefy_data() + kwargs['grid_data'] = self.get_table_data() if 'static_data' not in kwargs: kwargs['static_data'] = self.has_static_data() @@ -1364,10 +1364,11 @@ class Grid(object): warnings.warn("Grid.render_buefy() is deprecated; " "please use Grid.render_complete() instead", DeprecationWarning, stacklevel=2) + return self.render_complete(**kwargs) - def render_buefy_table_element(self, template='/grids/b-table.mako', - data_prop='gridData', empty_labels=False, - **kwargs): + def render_table_element(self, template='/grids/b-table.mako', + data_prop='gridData', empty_labels=False, + **kwargs): """ This is intended for ad-hoc "small" grids with static data. Renders just a ```` element instead of the typical "full" grid. @@ -1377,7 +1378,7 @@ class Grid(object): context['data_prop'] = data_prop context['empty_labels'] = empty_labels if 'grid_columns' not in context: - context['grid_columns'] = self.get_buefy_columns() + context['grid_columns'] = self.get_table_columns() context.setdefault('paginated', False) if context['paginated']: context.setdefault('per_page', 20) @@ -1572,10 +1573,10 @@ class Grid(object): return True return False - def get_buefy_columns(self): + def get_table_columns(self): """ - Return a list of dicts representing all grid columns. Meant for use - with Buefy table. + Return a list of dicts representing all grid columns. Meant + for use with the client-side JS table. """ columns = [] for name in self.columns: @@ -1597,9 +1598,10 @@ class Grid(object): if hasattr(rowobj, 'uuid'): return rowobj.uuid - def get_buefy_data(self): + def get_table_data(self): """ - Returns a list of data rows for the grid, for use with Buefy table. + Returns a list of data rows for the grid, for use with + client-side JS table. """ # filter / sort / paginate to get "visible" data raw_data = self.make_visible_data() @@ -1635,8 +1637,8 @@ class Grid(object): # instance, when the "display" version is different than raw data. # here is the hack we use for that. columns = list(self.columns) - if hasattr(self, 'buefy_data_columns'): - columns.extend(self.buefy_data_columns) + if hasattr(self, 'raw_data_columns'): + columns.extend(self.raw_data_columns) # iterate over data fields for name in columns: diff --git a/tailbone/templates/appsettings.mako b/tailbone/templates/appsettings.mako index 46f4a7e3..4f935956 100644 --- a/tailbone/templates/appsettings.mako +++ b/tailbone/templates/appsettings.mako @@ -154,7 +154,7 @@ ${parent.modify_this_page_vars()} diff --git a/tailbone/templates/batch/importer/view_row.mako b/tailbone/templates/batch/importer/view_row.mako index 9e08cf43..7d6f121f 100644 --- a/tailbone/templates/batch/importer/view_row.mako +++ b/tailbone/templates/batch/importer/view_row.mako @@ -68,7 +68,7 @@ % endif -<%def name="render_buefy_form()"> +<%def name="render_form()">

diff --git a/tailbone/templates/batch/inventory/desktop_form.mako b/tailbone/templates/batch/inventory/desktop_form.mako index 9f13cbf9..7e4795a8 100644 --- a/tailbone/templates/batch/inventory/desktop_form.mako +++ b/tailbone/templates/batch/inventory/desktop_form.mako @@ -34,7 +34,7 @@ -<%def name="render_form()"> +<%def name="render_form_template()"> @@ -113,7 +113,7 @@ }, data() { return { - groupPermissions: ${json.dumps(buefy_perms.get(selected_group, {}).get('permissions', []))|n}, + groupPermissions: ${json.dumps(perms_data.get(selected_group, {}).get('permissions', []))|n}, permissionGroupTerm: '', permissionTerm: '', selectedGroup: ${json.dumps(selected_group)|n}, diff --git a/tailbone/templates/products/batch.mako b/tailbone/templates/products/batch.mako index 868ad9b1..e0b93bd6 100644 --- a/tailbone/templates/products/batch.mako +++ b/tailbone/templates/products/batch.mako @@ -54,7 +54,7 @@ ${h.end_form()} -<%def name="render_form()"> +<%def name="render_form_template()"> diff --git a/tailbone/templates/products/view.mako b/tailbone/templates/products/view.mako index 5de6d099..c4da08ba 100644 --- a/tailbone/templates/products/view.mako +++ b/tailbone/templates/products/view.mako @@ -108,7 +108,7 @@ <%def name="lookup_codes_grid()"> - ${lookup_codes['grid'].render_buefy_table_element(data_prop='lookupCodesData')|n} + ${lookup_codes['grid'].render_table_element(data_prop='lookupCodesData')|n} <%def name="lookup_codes_panel()"> @@ -121,7 +121,7 @@ <%def name="sources_grid()"> - ${vendor_sources['grid'].render_buefy_table_element(data_prop='vendorSourcesData')|n} + ${vendor_sources['grid'].render_table_element(data_prop='vendorSourcesData')|n} <%def name="sources_panel()"> @@ -175,7 +175,7 @@