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: