From ab61778d3547e38cb0faf46364e57ffba861272d Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Fri, 7 Jan 2022 15:03:56 -0600 Subject: [PATCH] Some aesthetic improvements for vendor catalog batch hopefully they're improvements... --- .../batch/vendorcatalog/view_row.mako | 13 ++++ tailbone/templates/batch/view.mako | 63 +++++++++++++++++++ tailbone/templates/master/view.mako | 22 ++++++- tailbone/views/batch/core.py | 4 +- tailbone/views/batch/vendorcatalog.py | 39 ++++++++---- 5 files changed, 124 insertions(+), 17 deletions(-) create mode 100644 tailbone/templates/batch/vendorcatalog/view_row.mako diff --git a/tailbone/templates/batch/vendorcatalog/view_row.mako b/tailbone/templates/batch/vendorcatalog/view_row.mako new file mode 100644 index 00000000..6aaf9bf4 --- /dev/null +++ b/tailbone/templates/batch/vendorcatalog/view_row.mako @@ -0,0 +1,13 @@ +## -*- coding: utf-8; -*- +<%inherit file="/master/view_row.mako" /> + +<%def name="render_buefy_form()"> +
+ +
+ ${catalog_entry_diff.render_html()} +
+ + + +${parent.body()} diff --git a/tailbone/templates/batch/view.mako b/tailbone/templates/batch/view.mako index 36b9b633..1b7787bb 100644 --- a/tailbone/templates/batch/view.mako +++ b/tailbone/templates/batch/view.mako @@ -351,6 +351,58 @@ +<%def name="render_row_grid_tools()"> + ${parent.render_row_grid_tools()} + % if use_buefy and master.rows_bulk_deletable and not batch.executed and master.has_perm('delete_rows'): + + Delete Results + + + + + % endif + + <%def name="modify_this_page_vars()"> ${parent.modify_this_page_vars()} diff --git a/tailbone/templates/master/view.mako b/tailbone/templates/master/view.mako index 37d60c39..f361ad04 100644 --- a/tailbone/templates/master/view.mako +++ b/tailbone/templates/master/view.mako @@ -71,16 +71,32 @@ % if master.touchable and request.has_perm('{}.touch'.format(permission_prefix)):
  • ${h.link_to("\"Touch\" this {}".format(model_title), url('{}.touch'.format(route_prefix), uuid=instance.uuid))}
  • % endif - % if master.has_rows and master.rows_downloadable_csv and request.has_perm('{}.row_results_csv'.format(permission_prefix)): -
  • ${h.link_to("Download row results as CSV", url('{}.row_results_csv'.format(route_prefix), uuid=instance.uuid))}
  • + % if not use_buefy and master.has_rows and master.rows_downloadable_csv and master.has_perm('row_results_csv'): +
  • ${h.link_to("Download row results as CSV", master.get_action_url('row_results_csv', instance))}
  • % endif - % if master.has_rows and master.rows_downloadable_xlsx and master.has_perm('row_results_xlsx'): + % if not use_buefy and master.has_rows and master.rows_downloadable_xlsx and master.has_perm('row_results_xlsx'):
  • ${h.link_to("Download row results as XLSX", master.get_action_url('row_results_xlsx', instance))}
  • % endif <%def name="render_row_grid_tools()"> ${rows_grid_tools} + % if use_buefy: + % if master.rows_downloadable_xlsx and master.has_perm('row_results_xlsx'): + + Download Results XLSX + + % endif + % if master.rows_downloadable_csv and master.has_perm('row_results_csv'): + + Download Results CSV + + % endif + % endif <%def name="render_this_page()"> diff --git a/tailbone/views/batch/core.py b/tailbone/views/batch/core.py index 2f73de53..36ad341b 100644 --- a/tailbone/views/batch/core.py +++ b/tailbone/views/batch/core.py @@ -2,7 +2,7 @@ ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2021 Lance Edgar +# Copyright © 2010-2022 Lance Edgar # # This file is part of Rattail. # @@ -686,6 +686,8 @@ class BatchMasterView(MasterView): return HTML.tag('p', c=[link]) def make_batch_row_grid_tools(self, batch): + if self.get_use_buefy(): + return if self.rows_bulk_deletable and not batch.executed and self.request.has_perm('{}.delete_rows'.format(self.get_permission_prefix())): url = self.request.route_url('{}.delete_rows'.format(self.get_route_prefix()), uuid=batch.uuid) return HTML.tag('p', c=[tags.link_to("Delete all rows matching current search", url)]) diff --git a/tailbone/views/batch/vendorcatalog.py b/tailbone/views/batch/vendorcatalog.py index 5436f7d7..3668500a 100644 --- a/tailbone/views/batch/vendorcatalog.py +++ b/tailbone/views/batch/vendorcatalog.py @@ -40,6 +40,7 @@ from webhelpers2.html import tags from tailbone import forms from tailbone.db import Session from tailbone.views.batch import FileBatchMasterView +from tailbone.diffs import Diff log = logging.getLogger(__name__) @@ -76,11 +77,12 @@ class VendorCatalogView(FileBatchMasterView): form_fields = [ 'id', - 'description', - 'vendor', 'filename', + 'parser_key', + 'vendor', 'future', 'effective', + 'description', 'notes', 'created', 'created_by', @@ -114,16 +116,6 @@ class VendorCatalogView(FileBatchMasterView): 'description', 'size', 'is_preferred_vendor', - 'old_vendor_code', - 'vendor_code', - 'old_case_size', - 'case_size', - 'old_case_cost', - 'case_cost', - 'case_cost_diff', - 'old_unit_cost', - 'unit_cost', - 'unit_cost_diff', 'suggested_retail', 'starts', 'ends', @@ -131,6 +123,8 @@ class VendorCatalogView(FileBatchMasterView): 'discount_ends', 'discount_amount', 'discount_percent', + 'case_cost_diff', + 'unit_cost_diff', 'status_code', 'status_text', ] @@ -228,7 +222,7 @@ class VendorCatalogView(FileBatchMasterView): # starts if not batch.future: - g.hide_column('starts') + g.remove('starts') g.set_type('old_unit_cost', 'currency') g.set_type('unit_cost', 'currency') @@ -262,6 +256,25 @@ class VendorCatalogView(FileBatchMasterView): f.set_type('upc', 'gpc') f.set_type('discount_percent', 'percent') + def template_kwargs_view_row(self, **kwargs): + row = kwargs['instance'] + batch = row.batch + + fields = [ + 'vendor_code', + 'case_size', + 'case_cost', + 'unit_cost', + ] + old_data = dict([(field, getattr(row, 'old_{}'.format(field))) + for field in fields]) + new_data = dict([(field, getattr(row, field)) + for field in fields]) + kwargs['catalog_entry_diff'] = Diff(old_data, new_data, fields=fields, + monospace=True) + + return kwargs + def template_kwargs_create(self, **kwargs): parsers = self.get_parsers() for parser in parsers: