I've built a scheduling web app where users can book a conference for a given date and time slot on that date.
Now I need to implement a booking lock, which means that the admin can apply this lock and users can no longer book from that time on.
My current design includes a model booking_lock that only has one attribute of "status" with values of "On" and "Off".
The model would have only one record in the database at any given time as its sole responsibility would be to provide the data to check if booking has been locked.
---------------------EDIT-----------------------------------
This is not meant to lock individual records (conferences). To do this I use the attribute of user_id. If that is 0, then the conference is available for booking.
What I want to do now is disable (lock) the booking entirely before the user hits the database.
For example:
When a user logs on they see a notification saying the booking is locked. Also, they wouldn't see a respective button to book a conference and if by chance they would navigate to the respective URL they would be redirected to home page with the same notice as above. I've got all this covered.
But I need a general switch to be turned on and off and be the basis for this kind of check. Hence the booking_lock model.
Note: I use hanami-model.
---------------------EDIT-----------------------------------
My question is twofold:
- Is there a better way of implementing such a lock?
- How to ensure there is only one record in the db for such lock?