I would like to desing web application in django to make reservations for gym classes. I have some problems desiging it, because I don’t know how usually such problems are solved.
So one gym class takes place once a week, f.e. monday at 19.00 and only 20 people can attend it. Reservation should be possible one week before, so if class takes place 28 May at 19.00, reservation should be possible since 21 May 00:00.
And now some questions:
1. One class should be one object in a model (one record), right? But should it be one kind of class (so class that takes place every monday is one record) or class that occurs at specific date (so one class in one week is one record, after 3 weeks, we have 3 records of this class)?
2. How to create these records? Should I make automatic copy of today’s classes, changing date to +1 week?
How to solve these problems?
Well, you can create, f.e. a model that will represent a current timetable (schedule) for a gym class and another model that will represent a particular record for some day.
For example smth like that:
So, you can specify a schedule and class types if they will change in the future. You can create a command (see manage.py commands in django documentation) that will create a ClassRecord for the next week and set this command on cron (or celery for example), so it will run once a week and create new records when needed.