From d4089fbc6eac3d42dff09e07635df7a86c988def Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sun, 14 Apr 2024 20:56:11 -0500 Subject: [PATCH] Some more tweaks to remove "buefy" references mostly just docstring / comments but there were some code changes too --- tailbone/grids/core.py | 6 ++--- tailbone/subscribers.py | 5 +--- tailbone/templates/grids/complete.mako | 3 --- tailbone/views/batch/core.py | 2 +- tailbone/views/batch/importer.py | 4 +-- tailbone/views/customers.py | 24 ++++++++++-------- tailbone/views/messages.py | 2 +- tailbone/views/people.py | 2 +- tailbone/views/products.py | 4 +-- tailbone/views/upgrades.py | 35 +++++++++++++------------- 10 files changed, 42 insertions(+), 45 deletions(-) diff --git a/tailbone/grids/core.py b/tailbone/grids/core.py index b2f90204..f905659e 100644 --- a/tailbone/grids/core.py +++ b/tailbone/grids/core.py @@ -1335,7 +1335,7 @@ class Grid(object): def render_complete(self, template='/grids/complete.mako', **kwargs): """ - Render the Buefy grid, complete with filters. Note that this also + Render the grid, complete with filters. Note that this also includes the context menu items and grid tools. """ if 'grid_columns' not in kwargs: @@ -1437,7 +1437,7 @@ class Grid(object): def get_filters_data(self): """ - Returns a dict of current filters data, for use with Buefy grid view. + Returns a dict of current filters data, for use with index view. """ data = {} for filtr in self.filters.values(): @@ -1703,7 +1703,7 @@ class Grid(object): def set_action_urls(self, row, rowobj, i): """ Pre-generate all action URLs for the given data row. Meant for use - with Buefy table, since we can't generate URLs from JS. + with client-side table, since we can't generate URLs from JS. """ for action in (self.main_actions + self.more_actions): url = action.get_url(rowobj, i) diff --git a/tailbone/subscribers.py b/tailbone/subscribers.py index d05b8bd5..dce8b3ba 100644 --- a/tailbone/subscribers.py +++ b/tailbone/subscribers.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. # @@ -178,9 +178,6 @@ def before_render(event): renderer_globals['background_color'] = request.rattail_config.get( 'tailbone', 'background_color') - # TODO: remove this hack once nothing references it - renderer_globals['buefy_0_8'] = False - # maybe set custom stylesheet css = None if request.user: diff --git a/tailbone/templates/grids/complete.mako b/tailbone/templates/grids/complete.mako index 73c7e415..f9e665dc 100644 --- a/tailbone/templates/grids/complete.mako +++ b/tailbone/templates/grids/complete.mako @@ -171,9 +171,6 @@ :loading="loading" :row-class="getRowClass" - ## TODO: this should be more configurable, maybe auto-detect based - ## on buefy version?? probably cannot do that, but this feature - ## is only supported with buefy 0.8.13 and newer % if request.rattail_config.getbool('tailbone', 'sticky_headers'): sticky-header height="600px" diff --git a/tailbone/views/batch/core.py b/tailbone/views/batch/core.py index 46bdbb17..4df3d911 100644 --- a/tailbone/views/batch/core.py +++ b/tailbone/views/batch/core.py @@ -202,7 +202,7 @@ class BatchMasterView(MasterView): action_url=action_url, component='upload-worksheet-form') form.set_type('worksheet_file', 'file') - # TODO: must set these to avoid some default Buefy code + # TODO: must set these to avoid some default code form.auto_disable = False form.auto_disable_save = False return form diff --git a/tailbone/views/batch/importer.py b/tailbone/views/batch/importer.py index 962093da..ea4e1c74 100644 --- a/tailbone/views/batch/importer.py +++ b/tailbone/views/batch/importer.py @@ -145,9 +145,7 @@ class ImporterBatchView(BatchMasterView): make_filter('object_key') make_filter('object_str') - # for some reason we have to do this differently for Buefy? - kwargs = {} - make_filter('status_code', label="Status", **kwargs) + make_filter('status_code', label="Status") g.filters['status_code'].set_choices(self.enum.IMPORTER_BATCH_ROW_STATUS) def make_sorter(field): diff --git a/tailbone/views/customers.py b/tailbone/views/customers.py index dcd0e943..2958a98a 100644 --- a/tailbone/views/customers.py +++ b/tailbone/views/customers.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. # @@ -37,14 +37,14 @@ from tailbone import grids from tailbone.db import Session from tailbone.views import MasterView -from rattail.db import model +from rattail.db.model import Customer, CustomerShopper, PendingCustomer class CustomerView(MasterView): """ Master view for the Customer class. """ - model_class = model.Customer + model_class = Customer is_contact = True has_versions = True results_downloadable = True @@ -251,6 +251,7 @@ class CustomerView(MasterView): if instance: return instance + model = self.model key = self.request.matchdict['uuid'] # search by Customer.id @@ -270,7 +271,7 @@ class CustomerView(MasterView): if instance: return instance.customer - raise HTTPNotFound + raise self.notfound() def configure_form(self, f): super().configure_form(f) @@ -436,6 +437,7 @@ class CustomerView(MasterView): return kwargs def unique_id(self, node, value): + model = self.model query = self.Session.query(model.Customer)\ .filter(model.Customer.id == value) if self.editing: @@ -545,6 +547,7 @@ class CustomerView(MasterView): def get_version_child_classes(self): classes = super().get_version_child_classes() + model = self.model classes.extend([ (model.CustomerGroupAssignment, 'customer_uuid'), (model.CustomerPhoneNumber, 'parent_uuid'), @@ -556,6 +559,7 @@ class CustomerView(MasterView): return classes def detach_person(self): + model = self.model customer = self.get_instance() person = self.Session.get(model.Person, self.request.matchdict['person_uuid']) if not person: @@ -651,9 +655,7 @@ class CustomerView(MasterView): config.add_tailbone_permission(permission_prefix, '{}.detach_person'.format(permission_prefix), "Detach a Person from a {}".format(model_title)) - # TODO: this should require POST, but we'll add that once - # we can assume a Buefy theme is present, to avoid having - # to implement the logic in old jquery... + # TODO: this should require POST! config.add_route('{}.detach_person'.format(route_prefix), '{}/detach-person/{{person_uuid}}'.format(instance_url_prefix), # request_method='POST', @@ -667,7 +669,7 @@ class CustomerShopperView(MasterView): """ Master view for the CustomerShopper class. """ - model_class = model.CustomerShopper + model_class = CustomerShopper route_prefix = 'customer_shoppers' url_prefix = '/customer-shoppers' @@ -748,7 +750,7 @@ class PendingCustomerView(MasterView): """ Master view for the Pending Customer class. """ - model_class = model.PendingCustomer + model_class = PendingCustomer route_prefix = 'pending_customers' url_prefix = '/customers/pending' @@ -877,7 +879,7 @@ class PendingCustomerView(MasterView): # TODO: this only works when creating, need to add edit support? # TODO: can this just go away? since we have unique_id() view method above def unique_id(node, value): - customers = Session.query(model.Customer).filter(model.Customer.id == value) + customers = Session.query(Customer).filter(Customer.id == value) if customers.count(): raise colander.Invalid(node, "Customer ID must be unique") @@ -886,6 +888,8 @@ def customer_info(request): """ View which returns simple dictionary of info for a particular customer. """ + app = request.rattail_config.get_app() + model = app.model uuid = request.params.get('uuid') customer = Session.get(model.Customer, uuid) if uuid else None if not customer: diff --git a/tailbone/views/messages.py b/tailbone/views/messages.py index bf460436..ae050784 100644 --- a/tailbone/views/messages.py +++ b/tailbone/views/messages.py @@ -516,7 +516,7 @@ class SentView(MessageView): class RecipientsWidgetBuefy(dfwidget.Widget): """ - Custom "message recipients" widget, for use with Buefy / Vue.js themes. + Custom "message recipients" widget, for use with Vue.js themes. """ template = 'message_recipients' diff --git a/tailbone/views/people.py b/tailbone/views/people.py index 7b175e25..d8e36ec9 100644 --- a/tailbone/views/people.py +++ b/tailbone/views/people.py @@ -1404,7 +1404,7 @@ class PersonView(MasterView): """ View which locates and organizes all relevant "transaction" (version) history data for a given Person. Returns JSON, for - use with the Buefy table element on the full profile view. + use with the table element on the full profile view. """ person = self.get_instance() versions = self.profile_revisions_collect(person) diff --git a/tailbone/views/products.py b/tailbone/views/products.py index 1a928d67..788cc24d 100644 --- a/tailbone/views/products.py +++ b/tailbone/views/products.py @@ -1800,8 +1800,8 @@ class ProductView(MasterView): def search(self): """ Perform a product search across multiple fields, and return - the results as JSON suitable for row data for a Buefy - ```` component. + the results as JSON suitable for row data for a table + component. """ if 'term' not in self.request.GET: # TODO: deprecate / remove this? not sure if/where it is used diff --git a/tailbone/views/upgrades.py b/tailbone/views/upgrades.py index f7c83eec..a281062e 100644 --- a/tailbone/views/upgrades.py +++ b/tailbone/views/upgrades.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. # @@ -33,9 +33,7 @@ from collections import OrderedDict import sqlalchemy as sa -from rattail.core import Object -from rattail.db import model, Session as RattailSession -from rattail.time import make_utc +from rattail.db.model import Upgrade from rattail.threads import Thread from deform import widget as dfwidget @@ -53,7 +51,7 @@ class UpgradeView(MasterView): """ Master view for all user events """ - model_class = model.Upgrade + model_class = Upgrade downloadable = True cloneable = True configurable = True @@ -100,7 +98,7 @@ class UpgradeView(MasterView): ] def __init__(self, request): - super(UpgradeView, self).__init__(request) + super().__init__(request) if hasattr(self, 'get_handler'): warnings.warn("defining get_handler() is deprecated. please " @@ -120,7 +118,8 @@ class UpgradeView(MasterView): return self.upgrade_handler def configure_grid(self, g): - super(UpgradeView, self).configure_grid(g) + super().configure_grid(g) + model = self.model # system systems = self.upgrade_handler.get_all_systems() @@ -147,7 +146,8 @@ class UpgradeView(MasterView): return 'notice' def template_kwargs_view(self, **kwargs): - kwargs = super(UpgradeView, self).template_kwargs_view(**kwargs) + kwargs = super().template_kwargs_view(**kwargs) + model = self.model upgrade = kwargs['instance'] kwargs['system_title'] = self.rattail_config.app_title() @@ -177,7 +177,7 @@ class UpgradeView(MasterView): return kwargs def configure_form(self, f): - super(UpgradeView, self).configure_form(f) + super().configure_form(f) upgrade = f.model_instance # system @@ -275,9 +275,10 @@ class UpgradeView(MasterView): f.fields = ['system', 'description', 'notes', 'enabled'] def clone_instance(self, original): + app = self.get_rattail_app() cloned = self.model_class() cloned.system = original.system - cloned.created = make_utc() + cloned.created = app.make_utc() cloned.created_by = self.request.user cloned.description = original.description cloned.notes = original.notes @@ -335,7 +336,6 @@ class UpgradeView(MasterView): return HTML.tag('div', c="(not available for this upgrade)") def get_extra_diff_row_attrs(self, field, attrs): - # note, this is only needed/used with Buefy extra = {} if attrs.get('class') != 'diff': extra['v-show'] = "showingPackages == 'all'" @@ -449,13 +449,14 @@ class UpgradeView(MasterView): return packages def parse_requirement(self, line): + app = self.get_rattail_app() match = re.match(r'^.*@(.*)#egg=(.*)$', line) if match: - return Object(name=match.group(2), version=match.group(1)) + return app.make_object(name=match.group(2), version=match.group(1)) match = re.match(r'^(.*)==(.*)$', line) if match: - return Object(name=match.group(1), version=match.group(2)) + return app.make_object(name=match.group(1), version=match.group(2)) def download_path(self, upgrade, filename): return self.rattail_config.upgrade_filepath(upgrade.uuid, filename=filename) @@ -537,17 +538,17 @@ class UpgradeView(MasterView): def delete_instance(self, upgrade): self.handler.delete_files(upgrade) - super(UpgradeView, self).delete_instance(upgrade) + super().delete_instance(upgrade) def configure_get_context(self, **kwargs): - context = super(UpgradeView, self).configure_get_context(**kwargs) + context = super().configure_get_context(**kwargs) context['upgrade_systems'] = self.upgrade_handler.get_all_systems() return context def configure_gather_settings(self, data): - settings = super(UpgradeView, self).configure_gather_settings(data) + settings = super().configure_gather_settings(data) keys = [] for system in json.loads(data['upgrade_systems']): @@ -568,7 +569,7 @@ class UpgradeView(MasterView): return settings def configure_remove_settings(self): - super(UpgradeView, self).configure_remove_settings() + super().configure_remove_settings() app = self.get_rattail_app() model = self.model