Add refresh_many()
method for batch handlers
This commit is contained in:
parent
20a14ca39f
commit
2cbbbfdb37
|
@ -99,6 +99,8 @@
|
|||
|
||||
.. automethod:: refresh
|
||||
|
||||
.. automethod:: refresh_many
|
||||
|
||||
.. automethod:: refresh_row
|
||||
|
||||
.. automethod:: locate_product_for_entry
|
||||
|
|
|
@ -411,6 +411,27 @@ class BatchHandler(object):
|
|||
self.teardown_refresh(batch, progress=progress)
|
||||
return True
|
||||
|
||||
def refresh_many(self, batches, user=None, progress=None):
|
||||
"""
|
||||
Refresh a set of batches, with given progress. Default behavior is to
|
||||
simply refresh each batch in succession. Any batches which are already
|
||||
executed are skipped.
|
||||
|
||||
Handlers may have to override this method if "grouping" or other
|
||||
special behavior is needed.
|
||||
"""
|
||||
needs_refresh = [batch for batch in batches
|
||||
if not batch.executed]
|
||||
if not needs_refresh:
|
||||
return
|
||||
|
||||
# TODO: should perhaps try to make the progress indicator reflect the
|
||||
# "total" number of rows across all batches being refreshed? seems
|
||||
# like that might be more accurate, for the user. but also harder.
|
||||
|
||||
for batch in needs_refresh:
|
||||
self.do_refresh(batch, user, progress=progress)
|
||||
|
||||
def refresh_row(self, row):
|
||||
"""
|
||||
This method will be passed a row object which has already been properly
|
||||
|
|
Loading…
Reference in a new issue