Becky139 / mutts-cuts

0 stars 3 forks source link

Write view logic in booking view to prevent created and updated bookings from clashing an existing booking. #56

Open Becky139 opened 1 year ago

Becky139 commented 1 year ago

Note, as a small business only one client can be taken at a time.

Becky139 commented 1 year ago

The answer to this conundrum lay within Django documentation. Querysets

It's abstracted so there is no need to open the database connection, perform actions, or close the connection.

Applied logic within the bookings/views.py function. Essentially, if a record exists for a specific date AND specific time, the program can branch to tell the user their attempt to create or edit an appointment to the same time cannot be done. The business can only perform one appointment at a time as there is 1 member of staff.