blreams / collegefootballpick10

Football pool web app
4 stars 2 forks source link

Automatically make the pick deadline be the earliest kickoff #111

Closed blreams closed 8 years ago

blreams commented 8 years ago

This would require removing Pick Deadline as an input to the form. Would need to change kickoff to make it required. Then figure out how to set pick deadline based on validated form input.

blreams commented 8 years ago

This is partially completed. I created a new function in models, get_pick_deadline() that does the following:

  1. Returns the earliest kickoff in the specified week if any kickoffs are assigned.
  2. Returns the current pick_deadline for the specified week if it has been set.
  3. Returns calc_default_pick_deadline(), which is 4:00pm on the Thursday before the Saturday of Week being setup.

Doing it this way does not require changing the Game model to make kickoff a required field. It doesn't require changing any of the models, which I will not do until after the season is over. The only other remaining piece is to remove pick_deadline as a field to be entered, but for now I'm keeping it shown just so the commissioners know what value it has in the model without consulting the Admin interface.

blreams commented 8 years ago

I made a few additional modifications to insure that the initial submit of the create/edit week form will calculate the earliest kickoff from the cleaned form entries and do a second Week object save with that as the pick deadline. Also, I was able to set the kickoff field for each game as a required form field. This insures that the submit is not successful unless all the kickoffs are filled in. Likewise, I was able to set the pick_deadline field as not required...allowing it to be blank when the form is submitted. Neither of those changes (required/not required) necessitates a change to the model or existing records, so I'm ok with making this change during the season since there would be no db migration.

blreams commented 8 years ago

Closing