zooniverse / panoptes

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

Polymorphic links on serialised project response. #311

Closed camallen closed 9 years ago

camallen commented 10 years ago

Linked to #115 - The project owner relation is a polymorphic belongs_to (User & UserGroup). The serialised response returns the link to /owner which is not a valid URL.

"links"=>
  {"projects.workflows"=>{"href"=>"/workflows?project_id={projects.id}", "type"=>"workflows"},
   "projects.subject_sets"=>{"href"=>"/subject_sets?project_id={projects.id}", "type"=>"subject_sets"},
   "projects.owner"=>{"href"=>"/owners/{projects.owner}", "type"=>"owners"},
   "projects.project_contents"=>{"href"=>"/project_contents?project_id={projects.id}", "type"=>"project_contents"},
   "projects.project_roles"=>{"href"=>"/project_roles?project_id={projects.id}", "type"=>"project_roles"}}

We need to: a) override the href in the serialiser b) patch restpack-serializer to handle the polymorphic relations (https://github.com/RestPack/restpack_serializer/pull/81) c) Investigate porting to ActiveModelSerialisers, seems they handle polymorphic relations by default - @edpaget thoughts?

edpaget commented 10 years ago

@camallen I converted all our serializers to AMS in my branch https://github.com/edpaget/Panoptes/tree/ams. I'm not going to be working on it again until next week. There's a bunch of stuff that broke that I still need to resolve.