X-Git-Url: https://plomlompom.com/repos/?p=misc;a=blobdiff_plain;f=ledger.py;fp=ledger.py;h=958852aa56b0e747c1c2ad36f78f0d054f255310;hp=656a26e95656a6d83e6c23a7814be7f648728076;hb=59056f396c4761f9cd7ffbc569e3ddf8994d5e83;hpb=38b9ce0ba2b5af072554999bc5836ffe455f06db diff --git a/ledger.py b/ledger.py index 656a26e..958852a 100755 --- a/ledger.py +++ b/ledger.py @@ -531,14 +531,19 @@ class LedgerHandler(PlomHandler): edit_mode = postvars['edit_mode'][0] validate = submit_button in {'update', 'add', 'copy', 'check'} starts_at = '?' if index == -1 else db.bookings[index].starts_at + delete = False if 'textarea' == edit_mode: lines = [LedgerTextLine(line) for line in postvars['booking'][0].rstrip().split('\n')] - booking = Booking(lines, starts_at, validate=validate) + if len(lines) == 1 and lines[0].text_line == 'delete': + delete = True + else: + booking = Booking(lines, starts_at, validate=validate) else: booking = Booking.from_postvars(postvars, starts_at, validate) if submit_button in {'update', 'add'}: if submit_button == 'update': - if 'textarea' == edit_mode and 'delete' == ''.join([l.text_line for l in lines]).strip(): + # if 'textarea' == edit_mode and 'delete' == ''.join([l.text_line for l in lines]).strip(): + if 'textarea' == edit_mode and delete: del db.bookings[index] # if not creating new Booking, and date unchanged, keep it in place elif booking.date == db.bookings[index].date: