Open elthran opened 6 years ago
A store will have a set of hours. One for each day of the week. Anytime you make a change it should delete all of the hours for your business and rebuild it.
Here is the one from the site Melissa uses. You can see, to make a change it brings up all your hours. You adjust them all as you like and submit. Mine is the same. You bring up all the hours at once and submit, so it erases any database content involving your store location and replaces it with the updated version. There will be one entry for each day of the week and then a holidays entry. so 8 entries per business. (each Location will have 8 Hours entries in the Hours table). Each entry has a
That's all I currently need. It all works. I don't need help making it work. Just improving the code because it's shit and hard to read. I just wrote the explanation so you can understand it more easily!
Also the very first if/else statement will be removed. It was in place because there was no hours object when you first loaded it and it needed to check for one to find the preset values. But I will add a prebuilt hours object for eachlocation (defaulting to being closed every day and with hours of 9-5, so when you open i, it starts at nice hours). So dont worry about improving that very first if/else, but everything else needs help being more generic
I have an idea ... I posted a bunch of stuff in comments on your commits. Would you be able you review (an merge) my current pull request first though? If you wait too long it won't be able to merge cleanly and I'll have to redo it.
In brief it looks like this:
location.availablities -> ordered list of Availabilities (sorted by day_of_the_week, start_time)
Avaiability -closed -start_time -duration -day_of_the_week (as an int) -> use CONSTANTS for readability i.e SUNDAY = 0, MONDAY = 1
Display code (in jinja but I was too lazy to write it that way): for availability in location.availabilities: # ordered list render_field(availability) -> This should be a custom widget with Open or Closed states.
Output Sun: Unavailable # closed state ->add time slot # additional slot on Sunday Mon: _____ to __ x # open state -> add time slot # additional slot on Monday etc.
https://wtforms.readthedocs.io/en/latest/widgets.html#custom-widgets, check out my first pull request https://github.com/elthran/BookingSystem/pull/22 for an example
templates/edit_store_hours.html
Any way to improve this?
Even worse: routes/business/edit_store_hours.py
Everything about this is awful. Please take a look at these two and help make it more generic before I add the other days of the week. Maybe making day objects that have a opening time and closing time etc, and iterating through a bunch? What I have is awful.