'Update the model with external data (usually passed via API call).'

def update(self, attrs):

    self.verification_deadline = attrs.get('verification_deadline')
    existing_modes = {mode.mode_slug: mode for mode in self.modes}
    merged_modes = set()
    merged_mode_keys = set()
    for posted_mode in attrs.get('modes', []):
        merged_mode = existing_modes.get(posted_mode.mode_slug, CourseMode())
        merged_mode.course_id = self.id
        merged_mode.mode_slug = posted_mode.mode_slug
        merged_mode.mode_display_name = posted_mode.mode_slug
        merged_mode.min_price = posted_mode.min_price
        merged_mode.currency = posted_mode.currency
        merged_mode.sku = posted_mode.sku
        merged_mode.bulk_sku = posted_mode.bulk_sku
        merged_mode.expiration_datetime = posted_mode.expiration_datetime
        merged_mode.save()
        merged_modes.add(merged_mode)
        merged_mode_keys.add(merged_mode.mode_slug)
    deleted_modes = (set(existing_modes.keys()) - merged_mode_keys)
    self._deleted_modes = [existing_modes[mode] for mode in deleted_modes]
    self.modes = list(merged_modes)
