Add support for Row Status Breakdown, for Import/Export batches

This commit is contained in:
Lance Edgar 2020-01-14 11:54:00 -06:00
parent 02649709aa
commit 234fd8b2e1
4 changed files with 23 additions and 10 deletions

View file

@ -58,7 +58,7 @@ master_doc = 'index'
# General information about the project.
project = u'Tailbone'
copyright = u'2010 - 2018, Lance Edgar'
copyright = u'2010 - 2020, Lance Edgar'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2019 Lance Edgar
# Copyright © 2010-2020 Lance Edgar
#
# This file is part of Rattail.
#

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2019 Lance Edgar
# Copyright © 2010-2020 Lance Edgar
#
# This file is part of Rattail.
#
@ -166,19 +166,22 @@ class BatchMasterView(MasterView):
kwargs['status_breakdown'] = self.make_status_breakdown(batch)
return kwargs
def make_status_breakdown(self, batch):
def make_status_breakdown(self, batch, rows=None, status_enum=None):
"""
Returns a simple list of 2-tuples, each of which has the status display
title as first member, and number of rows with that status as second
member.
"""
breakdown = {}
for row in batch.active_rows():
if rows is None:
rows = batch.active_rows()
for row in rows:
if row.status_code is not None:
if row.status_code not in breakdown:
status = status_enum or row.STATUS
breakdown[row.status_code] = {
'code': row.status_code,
'title': row.STATUS[row.status_code],
'title': status[row.status_code],
'count': 0,
}
breakdown[row.status_code]['count'] += 1

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2018 Lance Edgar
# Copyright © 2010-2020 Lance Edgar
#
# This file is part of Rattail.
#
@ -103,9 +103,19 @@ class ImporterBatchView(BatchMasterView):
f.set_readonly('importer_key')
f.set_readonly('row_table')
def make_status_breakdown(self, batch):
# TODO: should implement this, just can't use batch.data_rows apparently
pass
def make_status_breakdown(self, batch, **kwargs):
"""
Returns a simple list of 2-tuples, each of which has the status display
title as first member, and number of rows with that status as second
member.
"""
if kwargs.get('rows') is None:
self.make_row_table(batch.row_table)
kwargs['rows'] = self.Session.query(self.current_row_table).all()
kwargs.setdefault('status_enum', self.enum.IMPORTER_BATCH_ROW_STATUS)
breakdown = super(ImporterBatchView, self).make_status_breakdown(
batch, **kwargs)
return breakdown
def delete_instance(self, batch):
self.make_row_table(batch.row_table)