From: Christian Heller Date: Sun, 29 Oct 2023 03:05:36 +0000 (+0100) Subject: Improve ledger.py. X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/%7B%7B%20web_path%20%7D%7D/decks/condition_titles?a=commitdiff_plain;h=255b10fbe4b0c688828d510868017565af50b57f;p=misc Improve ledger.py. --- diff --git a/ledger.py b/ledger.py index 2a9a89c..27675da 100755 --- a/ledger.py +++ b/ledger.py @@ -336,7 +336,6 @@ class Database: f.close() total_lines = self.real_lines[:start] + lines + self.real_lines[end:] text = '\n'.join(total_lines) - # text = '\n'.join(self.real_lines[:start]) + '\n'.join(lines) + '\n'.join(self.real_lines[end:]) with open(self.db_file, 'w') as f: f.write(text); os.remove(self.lock_file) @@ -413,7 +412,6 @@ input[type=number] { text-align: right; font-family: monospace; } lines += add_taxes(lines) elif '/add_free' == parsed_url.path: lines = postvars['booking'][0].splitlines() - lines += [''] # to ensure Booking-ending last line start = int(postvars['start'][0]) end = int(postvars['end'][0]) try: @@ -490,9 +488,9 @@ input[type=number] { text-align: right; font-family: monospace; } return f"
{content}
" def ledger_as_html(self, db): - single_c_tmpl = jinja2.Template('{{c}}
') + single_c_tmpl = jinja2.Template('{{c|e}}
') booking_tmpl = jinja2.Template(""" -

{{date}} {{desc}} {{head_comment}} +

{{date}} {{desc}} {{head_comment|e}} [edit: structured / free | copy:structured @@ -500,9 +498,9 @@ input[type=number] { text-align: right; font-family: monospace; } {% for l in booking_lines %} {% if l.acc %} - + {% else %} - + {% endif %} {% endfor %}
{{l.acc}}{{l.money}}{{l.comment}}
{{l.acc|e}}{{l.money|e}}{{l.comment|e}}
{{l.comment}}
{{l.comment|e}}

@@ -553,21 +551,21 @@ input[type=number] { text-align: right; font-family: monospace; } def add_structured(self, db, start=0, end=0, copy=False, temp_lines=[], add_empty_line=None): tmpl = jinja2.Template(""" -
+
- - - + + +
{% for line in booking_lines %} - + - - + +
@@ -575,7 +573,7 @@ input[type=number] { text-align: right; font-family: monospace; } {% for name, items in datalist_sets.items() %} {% for item in items %} - + {% endfor %} {% endfor %}