Add views for "delete product" batch

This commit is contained in:
Lance Edgar 2021-01-19 12:18:56 -06:00
parent af99ca7905
commit f480c046f6
2 changed files with 99 additions and 5 deletions

View file

@ -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 <http://www.gnu.org/licenses/>.
#
################################################################################
"""
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)

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.
# #
@ -1583,10 +1583,20 @@ class ProductsView(MasterView):
return {'product': data} return {'product': data}
def get_supported_batches(self): def get_supported_batches(self):
return { return OrderedDict([
'labels': 'rattail.batch.labels:LabelBatchHandler', ('labels', {
'pricing': 'rattail.batch.pricing:PricingBatchHandler', '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): def make_batch(self):
""" """
@ -1716,6 +1726,8 @@ class ProductsView(MasterView):
return self.request.route_url('labels.batch.view', uuid=batch.uuid) return self.request.route_url('labels.batch.view', uuid=batch.uuid)
if batch.batch_key == 'pricing': if batch.batch_key == 'pricing':
return self.request.route_url('batch.pricing.view', uuid=batch.uuid) 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 @classmethod
def defaults(cls, config): def defaults(cls, config):