X-Git-Url: https://plomlompom.com/repos/do_day?a=blobdiff_plain;ds=inline;f=ledger.py;h=ee6ed807ef72b4a9601acf32d25fad6ec1e0757a;hb=ebc562af576469da5f0011e10f80c7b0490ed959;hp=0785b1a7559869c074080b0775d16f1a81c2cb3a;hpb=3edadb6c0b977d0362ca8344303b3260184bebae;p=misc
diff --git a/ledger.py b/ledger.py
index 0785b1a..ee6ed80 100755
--- a/ledger.py
+++ b/ledger.py
@@ -422,10 +422,11 @@ input[type=number] { text-align: right; font-family: monospace; }
if 'save' in postvars.keys():
if start == end == 0:
db.append(lines)
+ redir_url = f'/#last'
else:
db.replace(start, end, lines)
+ redir_url = f'/#{start}'
self.send_response(301)
- redir_url = '/'
self.send_header('Location', redir_url)
self.end_headers()
else:
@@ -495,7 +496,7 @@ input[type=number] { text-align: right; font-family: monospace; }
def ledger2_as_html(self, db):
single_c_tmpl = jinja2.Template('{{c|e}}
')
booking_tmpl = jinja2.Template("""
-
{{date}} {{desc}} {{head_comment|e}} +
{{date}} {{desc}} {{head_comment|e}}
[edit: structured
/ free
| copy:structured
@@ -558,7 +559,7 @@ input[type=number] { text-align: right; font-family: monospace; }
def ledger_as_html(self, db):
single_c_tmpl = jinja2.Template('{{c|e}}
')
booking_tmpl = jinja2.Template("""
-
{{date}} {{desc}} {{head_comment|e}} +
{{date}} {{desc}} {{head_comment|e}} [edit: structured / free | copy:structured @@ -575,6 +576,7 @@ input[type=number] { text-align: right; font-family: monospace; } """) elements_to_write = [] last_i = i = 0 + last_start = db.bookings[-1].start_line for booking in db.bookings: i = booking.start_line elements_to_write += [single_c_tmpl.render(c=c) for c in db.comments[last_i:i] if c != ''] @@ -592,6 +594,7 @@ input[type=number] { text-align: right; font-family: monospace; } money = f'{booking_line[1]} {booking_line[2]}' booking_lines += [{'acc': booking_line[0], 'money':money, 'comment':comment}] elements_to_write += [booking_tmpl.render( + last=booking.start_line == last_start, start=booking.start_line, end=booking_end, date=booking.date_string, @@ -603,7 +606,7 @@ input[type=number] { text-align: right; font-family: monospace; } def add_free(self, db, start=0, end=0, copy=False): tmpl = jinja2.Template(""" -