{"action":"created","issue":{"url":"https://api.github.com/repos/NeuroVault/NeuroVault/issues/234","labels_url":"https://api.github.com/repos/NeuroVault/NeuroVault/issues/234/labels{/name}","comments_url":"https://api.github.com/repos/NeuroVault/NeuroVault/issues/234/comments","events_url":"https://api.github.com/repos/NeuroVault/NeuroVault/issues/234/events","html_url":"https://github.com/NeuroVault/NeuroVault/pull/234","id":73021328,"number":234,"title":"WIP: Support \"fixed\" image fields in metadata import","user":{"login":"burnash","id":264674,"avatar_url":"https://avatars.githubusercontent.com/u/264674?v=3","gravatar_id":"","url":"https://api.github.com/users/burnash","html_url":"https://github.com/burnash","followers_url":"https://api.github.com/users/burnash/followers","following_url":"https://api.github.com/users/burnash/following{/other_user}","gists_url":"https://api.github.com/users/burnash/gists{/gist_id}","starred_url":"https://api.github.com/users/burnash/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/burnash/subscriptions","organizations_url":"https://api.github.com/users/burnash/orgs","repos_url":"https://api.github.com/users/burnash/repos","events_url":"https://api.github.com/users/burnash/events{/privacy}","received_events_url":"https://api.github.com/users/burnash/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":61,"created_at":"2015-05-04T13:39:00Z","updated_at":"2015-06-08T15:23:21Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/NeuroVault/NeuroVault/pulls/234","html_url":"https://github.com/NeuroVault/NeuroVault/pull/234","diff_url":"https://github.com/NeuroVault/NeuroVault/pull/234.diff","patch_url":"https://github.com/NeuroVault/NeuroVault/pull/234.patch"},"body":"This my take to address UX consistency issues described in @chrisfilo's [comment](https://github.com/NeuroVault/NeuroVault/pull/184#issuecomment-94373548) to #184 :\r\n\r\n* \"Fixed\" metadata fields in statistical map objects are updated through the CSV upload in the same way as custom metadata fields.\r\n* In the API, custom metadata fields are exposed in the same way as \"fixed\" fields.\r\n\r\nMy initial approach was to replace \"fixed\" fields in models with \"virtual\" fields described in Images model using hstore's [schema mode](https://github.com/NeuroVault/NeuroVault/pull/184#issuecomment-94580050) or some custom \"virtual\" fields implementation. This led to numerous inheritance errors and conflicts with PolymorphicModel. \r\n\r\nIn this branch I took a different, more explicit and more flexible way to solve the problem.\r\n\r\n1. Each model that needs to define \"fixed\" fields implements a class method `get_fixed_fields` which returns a tuple of field names.\r\n2. Upon saving metadata key/value fields in database the code checks if a key corresponds to a \"fixed\" field and saves this field to a model if it does. This works both for import a new CSV file and for editing metadata as a grid.\r\n3. When serializing an image model for API response, the code merges \"fixed\" metadata fields with custom metadata fields giving precedence to the former.\r\n\r\nThis PR is branched from #184 all modifications are in d71705b.\r\n"},"comment":{"url":"https://api.github.com/repos/NeuroVault/NeuroVault/issues/comments/110038773","html_url":"https://github.com/NeuroVault/NeuroVault/pull/234#issuecomment-110038773","issue_url":"https://api.github.com/repos/NeuroVault/NeuroVault/issues/234","id":110038773,"user":{"login":"chrisfilo","id":238759,"avatar_url":"https://avatars.githubusercontent.com/u/238759?v=3","gravatar_id":"","url":"https://api.github.com/users/chrisfilo","html_url":"https://github.com/chrisfilo","followers_url":"https://api.github.com/users/chrisfilo/followers","following_url":"https://api.github.com/users/chrisfilo/following{/other_user}","gists_url":"https://api.github.com/users/chrisfilo/gists{/gist_id}","starred_url":"https://api.github.com/users/chrisfilo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrisfilo/subscriptions","organizations_url":"https://api.github.com/users/chrisfilo/orgs","repos_url":"https://api.github.com/users/chrisfilo/repos","events_url":"https://api.github.com/users/chrisfilo/events{/privacy}","received_events_url":"https://api.github.com/users/chrisfilo/received_events","type":"User","site_admin":false},"created_at":"2015-06-08T15:23:21Z","updated_at":"2015-06-08T15:23:21Z","body":"Might be of interest: https://docs.djangoproject.com/en/1.8/ref/contrib/postgres/fields/#hstorefield"}}