From f480c046f63197743165d70ecc1479a2e1b7c4c3 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 19 Jan 2021 12:18:56 -0600 Subject: [PATCH] Add views for "delete product" batch --- tailbone/views/batch/delproduct.py | 82 ++++++++++++++++++++++++++++++ tailbone/views/products.py | 22 ++++++-- 2 files changed, 99 insertions(+), 5 deletions(-) create mode 100644 tailbone/views/batch/delproduct.py diff --git a/tailbone/views/batch/delproduct.py b/tailbone/views/batch/delproduct.py new file mode 100644 index 00000000..775e2e79 --- /dev/null +++ b/tailbone/views/batch/delproduct.py @@ -0,0 +1,82 @@ +# -*- coding: utf-8; -*- +################################################################################ +# +# Rattail -- Retail Software Framework +# Copyright © 2010-2021 Lance Edgar +# +# This file is part of Rattail. +# +# Rattail is free software: you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation, either version 3 of the License, or (at your option) any later +# version. +# +# Rattail is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# +# You should have received a copy of the GNU General Public License along with +# Rattail. If not, see . +# +################################################################################ +""" +Views for "delete product" batches +""" + +from __future__ import unicode_literals, absolute_import + +from rattail.db import model + +from tailbone.views.batch import BatchMasterView + + +class DeleteProductBatchView(BatchMasterView): + """ + Master view for delete product batches. + """ + model_class = model.DeleteProductBatch + model_row_class = model.DeleteProductBatchRow + default_handler_spec = 'rattail.batch.delproduct:DeleteProductBatchHandler' + route_prefix = 'batch.delproduct' + url_prefix = '/batches/delproduct' + template_prefix = '/batch/delproduct' + creatable = False + bulk_deletable = True + rows_bulk_deletable = True + + row_grid_columns = [ + 'sequence', + 'upc', + 'brand_name', + 'description', + 'size', + 'department_name', + 'subdepartment_name', + 'status_code', + ] + + row_form_fields = [ + 'sequence', + 'product', + 'upc', + 'brand_name', + 'description', + 'size', + 'department_number', + 'department_name', + 'subdepartment_number', + 'subdepartment_name', + 'status_code', + 'status_text', + ] + + def row_grid_extra_class(self, row, i): + if row.status_code == row.STATUS_PRODUCT_NOT_FOUND: + return 'warning' + if row.status_code == row.STATUS_DEPARTMENT_NOT_ALLOWED: + return 'notice' + + +def includeme(config): + DeleteProductBatchView.defaults(config) diff --git a/tailbone/views/products.py b/tailbone/views/products.py index cce79659..34887021 100644 --- a/tailbone/views/products.py +++ b/tailbone/views/products.py @@ -2,7 +2,7 @@ ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2020 Lance Edgar +# Copyright © 2010-2021 Lance Edgar # # This file is part of Rattail. # @@ -1583,10 +1583,20 @@ class ProductsView(MasterView): return {'product': data} def get_supported_batches(self): - return { - 'labels': 'rattail.batch.labels:LabelBatchHandler', - 'pricing': 'rattail.batch.pricing:PricingBatchHandler', - } + return OrderedDict([ + ('labels', { + 'spec': self.rattail_config.get('rattail.batch', 'labels.handler', + default='rattail.batch.labels:LabelBatchHandler'), + }), + ('pricing', { + 'spec': self.rattail_config.get('rattail.batch', 'pricing.handler', + default='rattail.batch.pricing:PricingBatchHandler'), + }), + ('delproduct', { + 'spec': self.rattail_config.get('rattail.batch', 'delproduct.handler', + default='rattail.batch.delproduct:DeleteProductBatchHandler'), + }), + ]) def make_batch(self): """ @@ -1716,6 +1726,8 @@ class ProductsView(MasterView): return self.request.route_url('labels.batch.view', uuid=batch.uuid) if batch.batch_key == 'pricing': return self.request.route_url('batch.pricing.view', uuid=batch.uuid) + if batch.batch_key == 'delproduct': + return self.request.route_url('batch.delproduct.view', uuid=batch.uuid) @classmethod def defaults(cls, config):