OisinWrites / Byte

A Restaurant Booking Page
0 stars 2 forks source link

epic 2 user story 2: Handling the TableAvailability Model #6

Open OisinWrites opened 1 year ago

OisinWrites commented 1 year ago

The TableAvailability mode creates time slot instances for bookings, but they need to either edit or delete and renew when a booking is adjusted. This is because the cascade function of a foreign key as an attribute triggers on a delete, but does nothing for an edit. The associated time slot object has to be found and deleted in this event, otherwise the booked slot will remain, disallowing others from making a booking and potentially costing the restaurant business money.

ref -> README ISSUE #8:

8:
Issue: When a table is edited by its start time it leaves behind the table availability instance, which only collapses with a delete.
Resolve: The code I've tried is attempting to delete old instances of availability, but I believe its tracking them using the id of the edited booking which has changed from the original booking.
- The table availability model doesn't take in the booking's id. In fact the booking only gets an id on its instansiation, which naturally is after the table availability instansiation since it is a requirement for the booking to exist. Maybe I can edit the table availability instance after the booking is created.
- Changed the booking view block for making a table availability object. Table availability object now takes in the whole booking object and generates an attribute 'id_of_booking' from the objects id. The edit view now finds the objects that have that attribute = to its own booking objects id and deletes them before creating a new one. It does this now whether or not the edit involved the start date, and thus warranted a new time slot in the form of the table availability object.