{"action":"created","issue":{"url":"https://api.github.com/repos/mitodl/micromasters/issues/173","repository_url":"https://api.github.com/repos/mitodl/micromasters","labels_url":"https://api.github.com/repos/mitodl/micromasters/issues/173/labels{/name}","comments_url":"https://api.github.com/repos/mitodl/micromasters/issues/173/comments","events_url":"https://api.github.com/repos/mitodl/micromasters/issues/173/events","html_url":"https://github.com/mitodl/micromasters/pull/173","id":147853800,"number":173,"title":"Added auto-incrementing `student_id` field to `Profile`","user":{"login":"aliceriot","id":6207644,"avatar_url":"https://avatars.githubusercontent.com/u/6207644?v=3","gravatar_id":"","url":"https://api.github.com/users/aliceriot","html_url":"https://github.com/aliceriot","followers_url":"https://api.github.com/users/aliceriot/followers","following_url":"https://api.github.com/users/aliceriot/following{/other_user}","gists_url":"https://api.github.com/users/aliceriot/gists{/gist_id}","starred_url":"https://api.github.com/users/aliceriot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aliceriot/subscriptions","organizations_url":"https://api.github.com/users/aliceriot/orgs","repos_url":"https://api.github.com/users/aliceriot/repos","events_url":"https://api.github.com/users/aliceriot/events{/privacy}","received_events_url":"https://api.github.com/users/aliceriot/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/mitodl/micromasters/labels/Waiting%20on%20Author","name":"Waiting on Author","color":"d4c5f9"}],"state":"open","locked":false,"assignee":{"login":"giocalitri","id":1005204,"avatar_url":"https://avatars.githubusercontent.com/u/1005204?v=3","gravatar_id":"","url":"https://api.github.com/users/giocalitri","html_url":"https://github.com/giocalitri","followers_url":"https://api.github.com/users/giocalitri/followers","following_url":"https://api.github.com/users/giocalitri/following{/other_user}","gists_url":"https://api.github.com/users/giocalitri/gists{/gist_id}","starred_url":"https://api.github.com/users/giocalitri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/giocalitri/subscriptions","organizations_url":"https://api.github.com/users/giocalitri/orgs","repos_url":"https://api.github.com/users/giocalitri/repos","events_url":"https://api.github.com/users/giocalitri/events{/privacy}","received_events_url":"https://api.github.com/users/giocalitri/received_events","type":"User","site_admin":false},"milestone":null,"comments":8,"created_at":"2016-04-12T19:43:36Z","updated_at":"2016-04-15T18:02:40Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/mitodl/micromasters/pulls/173","html_url":"https://github.com/mitodl/micromasters/pull/173","diff_url":"https://github.com/mitodl/micromasters/pull/173.diff","patch_url":"https://github.com/mitodl/micromasters/pull/173.patch"},"body":"#### relevant tickets:\r\n\r\nthis accomplishes part of #69\r\n\r\n#### what's this pr do?\r\n\r\nthis adds a new attribute to the Profile model (`student_id`) that we\r\nbasically keep incremented.\r\n\r\nto do so we override the `save` method on the Profile model, so that we\r\ncan insert our own logic to set the correct `student_id` on `self`\r\nbefore we save (only if the model is new or the `student_id` field is\r\ncurrently empty).\r\n\r\nwe also add this attribute to the `ProfileSerializer`, which is what\r\nspits the profile JSON to the frontend.\r\n\r\n#### where should the reviewer start?\r\n\r\nthe migration and the model change:\r\n\r\n\tnew file:   profiles/migrations/0005_profile_student_id.py\r\n\tmodified:   profiles/models.py\r\n\r\nthe serializer change is smaller, I think\r\n\r\n\tmodified:   profiles/serializers.py\r\n\r\n#### how should this be manually tested?\r\n\r\nI think the key thing is testing that when you save a `Profile` instance\r\nit has a unique `student_id`. It should save a `student_id` when saving\r\nboth new and previously created objects.\r\n\r\n#### any background context?\r\n\r\nI modeled this change over how we accomplished a somewhat (I think?)\r\nsimilar thing over in Lore.\r\n\r\nThe relevant pieces are here:\r\n\r\nhttps://github.com/mitodl/lore/blob/master/learningresources/models.py#L163\r\n\r\nhttps://github.com/mitodl/lore/blob/master/rest/util.py#L66"},"comment":{"url":"https://api.github.com/repos/mitodl/micromasters/issues/comments/210566737","html_url":"https://github.com/mitodl/micromasters/pull/173#issuecomment-210566737","issue_url":"https://api.github.com/repos/mitodl/micromasters/issues/173","id":210566737,"user":{"login":"aliceriot","id":6207644,"avatar_url":"https://avatars.githubusercontent.com/u/6207644?v=3","gravatar_id":"","url":"https://api.github.com/users/aliceriot","html_url":"https://github.com/aliceriot","followers_url":"https://api.github.com/users/aliceriot/followers","following_url":"https://api.github.com/users/aliceriot/following{/other_user}","gists_url":"https://api.github.com/users/aliceriot/gists{/gist_id}","starred_url":"https://api.github.com/users/aliceriot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aliceriot/subscriptions","organizations_url":"https://api.github.com/users/aliceriot/orgs","repos_url":"https://api.github.com/users/aliceriot/repos","events_url":"https://api.github.com/users/aliceriot/events{/privacy}","received_events_url":"https://api.github.com/users/aliceriot/received_events","type":"User","site_admin":false},"created_at":"2016-04-15T18:02:40Z","updated_at":"2016-04-15T18:02:40Z","body":"woooo"}}