- if submit_button in {'save', 'copy'}:
- if index != -1 and submit_button != 'copy':
- if booking.date == db.bookings[index].date:
- db.bookings[index] = booking
- booking_is_placed = True
- else:
- db.bookings = db.bookings[:index] + db.bookings[index+1:]
- db.insert_booking_at_date(booking)
+ 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():
+ del db.bookings[index]
+ # if not creating new Booking, and date unchanged, keep it in place
+ elif booking.date == db.bookings[index].date:
+ db.bookings[index] = booking
+ else:
+ del db.bookings[index]
+ db.insert_booking_at_date(booking)