- input_lines += f'{inpu(f"line_{i}_account", account, "accounts", size=40)} {inpu(f"line_{i}_amount", amount, "", "number", size=10)} {inpu(f"line_{i}_currency", currency, "currencies", size=3)} ; {self.textarea(f"line_{i}_comment", [comments[i]])} {inpu(f"line_{i}_delete", "[x]", "", "submit")} {inpu(f"line_{i}_add", "[+]", "", "submit")}<br />'
- datalist_sets = {'descriptions': set(), 'accounts': set(), 'currencies': set()}
- for b in db.bookings:
- datalist_sets['descriptions'].add(b.description)
- for account, moneys in b.account_changes.items():
- datalist_sets['accounts'].add(account)
- for currency in moneys.keys():
- datalist_sets['currencies'].add(currency)
- def build_datalist(name):
- datalist = f'<datalist id="{name}">' + "\n"
- for item in datalist_sets[name]:
- safe_item = html.escape(item)
- datalist += f'<option value="{safe_item}">{safe_item}</option>' + "\n"
- return f"{datalist}</datalist>\n"
- datalists = build_datalist('descriptions')
- datalists += build_datalist('accounts')
- datalists += build_datalist('currencies')
- return f'{self.header_add_form("add_structured")}{input_lines}{datalists}{self.footer_add_form(start, end, copy)}'
+ booking_lines += [{
+ 'i': i,
+ 'acc': account,
+ 'amt': amount,
+ 'curr': currency if currency else '',
+ 'comment': comments[i],
+ 'comm_cols': len(comments[i])}]
+ content += tmpl.render(
+ action=action,
+ date=date,
+ desc=desc,
+ head_comment=head_comment,
+ booking_lines=booking_lines,
+ datalist_sets=datalist_sets,
+ start=start,
+ end=end)
+ return content