Add support for courseware partitioning based on cohort.

@andy-armstrong @cahrens 

suspect i'm going to need to wire something into stevedore - @andy-armstrong ?

please take heed of the notes in the first commit message - there's a database migration needed. 
Can you add some tests around invalid ids of all kinds. I presume that these are foreign key constraints so an error should be thrown immediately.