ficlatte / main

Ficlatté website main code
GNU Affero General Public License v3.0
2 stars 2 forks source link

ch_winner = models.FloatField(default=0.0, null=True) #30

Closed ethel-t-frog closed 7 years ago

ethel-t-frog commented 7 years ago

Jim,

what is this new field for in Story?

HSAR commented 7 years ago

I assume this is for storing which challenges the story has won.

stitzelj commented 7 years ago

It's specifically for the story view to do a reverse lookup of the challenge the story won. I have a tag that conditionally displays the challenge information in the story's sidebar and I also use it to display the glyphicon that appears at the end of the story's title.

ethel-t-frog commented 7 years ago

You don't need additional fields to do reverse lookups, and why is it floating point?

stitzelj commented 7 years ago

Yeah, I realized this morning after you brought this up that I can think of a better way to handle this by calling the challenge object and pulling the winning story ID from there. The floating point thing was an oversight on my part. It should have been an integer. Let me go back over the code and make some changes. I'll drop that field off the Story table and update all the reverse lookups.

ethel-t-frog commented 7 years ago

I tweaked your Challenges code a bit to make better use of internal object representations and removed this field in the process. I'll merge your pull request soon (as it conflicts with mine).

stitzelj commented 7 years ago

I looked at your commit. That's definitely better than what I was trying to do.

stitzelj commented 7 years ago

I'm still figuring out models and everything you can do with them aside from just creating databases. :)

ethel-t-frog commented 7 years ago

No worries, Jim. It takes a bit of time to work it all out. It's all part of the Scout Method: "learn by doing".

http://members.scouts.org.uk/supportresources/957/scout-method

stitzelj commented 7 years ago

That's the way I learn best, honestly -- jump in with both feet and splash around until things make sense. I liked what you did with the model to simple things up, so I'll keep that in mind for the future and see if I can't bone up some more on just exactly how models work. The Django documentation is, of course, unpleasantly opaque most of the time, so reading that hasn't been nearly as helpful as I hoped it'd be.

I also went ahead and resolved the merge issues and committed a couple of minor lingering error fixes from my side, so that should be all set and ready for you to pull at your leisure.