StevenWeir038 / Kennel39

A CRUD based booking site for a small dog grooming business
2 stars 2 forks source link

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

Closed StevenWeir038 closed 2 years ago

StevenWeir038 commented 2 years ago

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

StevenWeir038 commented 2 years ago

The answer to this conundrum lay within Django documentation. Querysets

It's abstracted so no need to open database connection, perform actions, close 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.