zooniverse / panoptes

Zooniverse API to support user defined volunteer research projects
Apache License 2.0
103 stars 41 forks source link

Fix serialised JSON representation of owner polymorphic links #115

Closed camallen closed 10 years ago

camallen commented 10 years ago

As the owner relationship is polymorphic and RestPack Serializer doesn't embed the resource class context the owner routes will be useless.

I've got a PR with RestPack serializer but haven't gotten around to implementing anyting there.

My plan is to introspect on the belongs_to association and if it's polymorphic then represent this link as a resource object (note the href override link), e.g.

{
  "id": "1",
  "links": {
    "owner": {
      "href": "http://api.panoptes.org/api/groups/17",
      "id": "17",
      "type": "user_group"
    }
  }
}
edpaget commented 10 years ago

That looks good to me.

camallen commented 10 years ago

We may not need this since ff23af61bfe62d81b028b6a0f9d9cad2e4636623 - added the owner_name attribute to User and UserGroup serializers. Perhaps we just don't expose the OwnerName relationship on the Namebale models to avoid this issue.

I do think it would be good to contribute back to RestpackSerialzer though.

edpaget commented 10 years ago

So that commit is merged is it okay to close this?

camallen commented 10 years ago

Yeah - I don't think we need to expose the polymorphic owner_name relationship in our serialized models via RestPack.

If we do i'll reopen and fix it.