wafflesfm / batter

It makes Waffles.
Other
84 stars 17 forks source link

Switch to using a GenericForeignKey #25

Closed senturio closed 11 years ago

senturio commented 11 years ago

This is so we can insert things in places they shouldn't go.

coveralls commented 11 years ago

Coverage remained the same when pulling 4b82a2631de3c363ef7ca1090387698b004246b8 on feature/torrent-model-rethink into 2c733b51be7f912fc5975ccbc45e1f93b2aa9ed9 on develop.

View Details

coveralls commented 11 years ago

Coverage remained the same when pulling 85d3ec7c8a4bc9a615f6ee91be28216e26d88e6a on feature/torrent-model-rethink into 2c733b51be7f912fc5975ccbc45e1f93b2aa9ed9 on develop.

View Details

senturio commented 11 years ago

Assigning to @superbobry so he can tell me if I'm being an idiot with this and merge it if its a lgth :-)

ghost commented 11 years ago

:+1:

superbobry commented 11 years ago

Looks good, except for the unchecked _children usage in DescendingMixin. Merge?

senturio commented 11 years ago

@superbobry made a few more tweaks.

Usecase of the direct root link from Upload to UploadGroup (woo, I renamed it) is that UploadGroup needs to be able to find things out like the total number of uploads associated with it, or the maximum number of seeders for all of its torrents. It's a bit icky, but it does automatically update in an attempt to keep it up to sync.

I experimented with other ways, but this is the easiest and probably the cleanest.

As for the _children usage, the class, once instantiated, is guaranteed to have either a _children or a GenericForeignKey on them due to the checks I perform in DescendingMixin.__new__.

If it still looks good to you, please merge. :ok: