bmun/huxley — pull request #328 by kmeht (2014-09-21 10:20:19+00:00)
Title: Use a property to back country_preferences in SchoolSerializer.

This uses Python's property feature to serialize the school's
country preferences in a sane way, i.e. a list of country IDs.
We do this by making the getter just fetch the countries and
return their IDs. We then use the ListField provided by
the drf-compound-fields package to serialize it.

The setter is slightly more involved. Since the school may not
even exist in the DB when the setter is called (e.g, on create),
we have to store the IDs in a temporary variable, and then override
School's save() method to update the preferences if they're there.
However, I think that's FAR less hacky than what we were doing
before with putting the logic in the views.

**TEST PLAN:** Updated the unit tests; they all pass.

Resolves #327.