get_with_indexed_value is now an iterator (#23551)

This commit is contained in:
Thomas NOËL 2018-05-03 11:36:26 +02:00
parent dadd54bca8
commit 51889bd567
3 changed files with 10 additions and 9 deletions

View File

@ -123,7 +123,8 @@ def synchronize_domino(publisher):
if getattr(payment_invoice, 'domino_knows_its_paid', None) or getattr(payment_invoice, 'paid_by_domino', None):
# synchronization of payment already done, skip
continue
transactions = Transaction.get_with_indexed_value('invoice_ids', payment_invoice.id)
transactions = list(Transaction.get_with_indexed_value('invoice_ids',
payment_invoice.id))
if not transactions:
logger.warning("domino cron: invoice %s is marked paid but does "
"not have any linked transaction.", payment_invoice.id)

View File

@ -136,8 +136,8 @@ class StrongboxDirectory(Directory):
# TODO: a paragraph of explanations here could be useful
sffiles = StrongboxItem.get_with_indexed_value(
str('user_id'), str(get_request().user.id))
sffiles = list(StrongboxItem.get_with_indexed_value(
str('user_id'), str(get_request().user.id)))
if sffiles:
r += htmltext('<table id="strongbox-items">')
r += htmltext('<tr><th></th><th>%s</th><th>%s</th><th></th></tr>') % (
@ -332,8 +332,8 @@ class StrongboxDirectory(Directory):
return self.picked_file()
r = TemplateIO(html=True)
root_url = get_publisher().get_root_url()
sffiles = StrongboxItem.get_with_indexed_value(
str('user_id'), str(get_request().user.id))
sffiles = list(StrongboxItem.get_with_indexed_value(
str('user_id'), str(get_request().user.id)))
r += htmltext('<h2>%s</h2>') % _('Pick a file')
if not sffiles:

View File

@ -360,8 +360,8 @@ class RegieDirectory(Directory):
def get_invoices(self):
sort_by = self.get_sort_by()
invoices = Invoice.get_with_indexed_value('regie_id', self.regie.id,
ignore_errors=True)
invoices = list(Invoice.get_with_indexed_value('regie_id', self.regie.id,
ignore_errors=True))
if 'date' in sort_by:
reverse = True
key = lambda i: getattr(i, sort_by) or datetime.datetime.now()
@ -456,8 +456,8 @@ class RegieDirectory(Directory):
r += htmltext('</form>')
r += htmltext('</td></tr>')
transactions = Transaction.get_with_indexed_value('invoice_ids',
invoice.id)
transactions = list(Transaction.get_with_indexed_value('invoice_ids',
invoice.id))
for transaction in sorted(transactions, key=lambda x: x.start):
r += htmltext('<tr>')
r += htmltext('<td></td>')