{"action":"created","comment":{"url":"https://api.github.com/repos/Brown-University-Library/ttwr/pulls/comments/59757179","id":59757179,"diff_hunk":"@@ -100,17 +101,29 @@ def annotations_by_books_and_prints(self, group_amount=50):\n \n         return (books,prints)\n \n+    def format_trp_id(self, trp_id):\n+        return '%04d' % int(trp_id)\n \n     def _get_trp_id(self):\n-        last_bio = Biography.objects.order_by('-trp_id')[0]\n+        ordered_bios = Biography.objects.order_by('-trp_id')\n+        index = 0\n+        last_bio = ordered_bios[index]\n+        while last_bio.trp_id != self.format_trp_id(last_bio.trp_id):\n+            last_bio = ordered_bios[index+1]\n         last_trp_id = int(last_bio.trp_id)\n         new_trp_id = last_trp_id + 1\n         return '%04d' % new_trp_id\n \n     def save(self, *args, **kwargs):\n         if not self.trp_id:\n             self.trp_id = self._get_trp_id()\n-        super(Biography, self).save(*args, **kwargs)\n+        else:\n+            self.trp_id = self.format_trp_id(self.trp_id)        \n+        self.roles = self.roles.replace(\",\",\";\"); \n+        try:\n+            super(Biography, self).save(*args, **kwargs)\n+        except IntegrityError as e:\n+            print e.message","path":"models.py","position":36,"original_position":36,"commit_id":"7fe16d336fd0db8eb73924c3018e34e91e136cf9","original_commit_id":"26218a9875cffcadf4e940fb26a7c8765299865d","user":{"login":"lucyvk","id":6878858,"avatar_url":"https://avatars.githubusercontent.com/u/6878858?v=3","gravatar_id":"","url":"https://api.github.com/users/lucyvk","html_url":"https://github.com/lucyvk","followers_url":"https://api.github.com/users/lucyvk/followers","following_url":"https://api.github.com/users/lucyvk/following{/other_user}","gists_url":"https://api.github.com/users/lucyvk/gists{/gist_id}","starred_url":"https://api.github.com/users/lucyvk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lucyvk/subscriptions","organizations_url":"https://api.github.com/users/lucyvk/orgs","repos_url":"https://api.github.com/users/lucyvk/repos","events_url":"https://api.github.com/users/lucyvk/events{/privacy}","received_events_url":"https://api.github.com/users/lucyvk/received_events","type":"User","site_admin":false},"body":"Makes sense. I'll check with Elli on this.\n\nOn Thu, Apr 14, 2016 at 12:55 PM, bcail <notifications@github.com> wrote:\n\n> In models.py\n> <https://github.com/Brown-University-Library/ttwr/pull/155#discussion_r59752376>\n> :\n>\n> >          last_trp_id = int(last_bio.trp_id)\n> >          new_trp_id = last_trp_id + 1\n> >          return '%04d' % new_trp_id\n> >\n> >      def save(self, *args, **kwargs):\n> >          if not self.trp_id:\n> >              self.trp_id = self._get_trp_id()\n> > -        super(Biography, self).save(*args, **kwargs)\n> > +        else:\n> > +            self.trp_id = self.format_trp_id(self.trp_id)\n> > +        self.roles = self.roles.replace(\",\",\";\");\n> > +        try:\n> > +            super(Biography, self).save(*args, **kwargs)\n> > +        except IntegrityError as e:\n> > +            print e.message\n>\n> Sounds fine to me to just automatically generate a new TRP ID for the user\n> - if we do that, though, I would either remove the option from the user\n> (hide the field on the form, or make it un-editable), or add a note to the\n> user that the TRP ID could/will be changed from what they enter.\n>\n> I would check with Elli about this, though - there may be some cases where\n> she or others need to change the TRP ID. If some people do need to edit or\n> change the TRP ID, maybe the best option is a note to the user saying it\n> might be changed if it's not unique.\n>\n> —\n> You are receiving this because you authored the thread.\n> Reply to this email directly or view it on GitHub\n> <https://github.com/Brown-University-Library/ttwr/pull/155/files/26218a9875cffcadf4e940fb26a7c8765299865d#r59752376>\n>\n","created_at":"2016-04-14T17:27:07Z","updated_at":"2016-04-14T17:27:07Z","html_url":"https://github.com/Brown-University-Library/ttwr/pull/155#discussion_r59757179","pull_request_url":"https://api.github.com/repos/Brown-University-Library/ttwr/pulls/155","_links":{"self":{"href":"https://api.github.com/repos/Brown-University-Library/ttwr/pulls/comments/59757179"},"html":{"href":"https://github.com/Brown-University-Library/ttwr/pull/155#discussion_r59757179"},"pull_request":{"href":"https://api.github.com/repos/Brown-University-Library/ttwr/pulls/155"}}},"pull_request":{"url":"https://api.github.com/repos/Brown-University-Library/ttwr/pulls/155","id":66363915,"html_url":"https://github.com/Brown-University-Library/ttwr/pull/155","diff_url":"https://github.com/Brown-University-Library/ttwr/pull/155.diff","patch_url":"https://github.com/Brown-University-Library/ttwr/pull/155.patch","issue_url":"https://api.github.com/repos/Brown-University-Library/ttwr/issues/155","number":155,"state":"open","locked":false,"title":"Refinements to essay feature and some data-entry restrictions","user":{"login":"lucyvk","id":6878858,"avatar_url":"https://avatars.githubusercontent.com/u/6878858?v=3","gravatar_id":"","url":"https://api.github.com/users/lucyvk","html_url":"https://github.com/lucyvk","followers_url":"https://api.github.com/users/lucyvk/followers","following_url":"https://api.github.com/users/lucyvk/following{/other_user}","gists_url":"https://api.github.com/users/lucyvk/gists{/gist_id}","starred_url":"https://api.github.com/users/lucyvk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lucyvk/subscriptions","organizations_url":"https://api.github.com/users/lucyvk/orgs","repos_url":"https://api.github.com/users/lucyvk/repos","events_url":"https://api.github.com/users/lucyvk/events{/privacy}","received_events_url":"https://api.github.com/users/lucyvk/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-04-13T17:55:23Z","updated_at":"2016-04-14T17:27:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"827de2d631606cdc97e9946c97aba4c8169af5a3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Brown-University-Library/ttwr/pulls/155/commits","review_comments_url":"https://api.github.com/repos/Brown-University-Library/ttwr/pulls/155/comments","review_comment_url":"https://api.github.com/repos/Brown-University-Library/ttwr/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Brown-University-Library/ttwr/issues/155/comments","statuses_url":"https://api.github.com/repos/Brown-University-Library/ttwr/statuses/7fe16d336fd0db8eb73924c3018e34e91e136cf9","head":{"label":"lucyvk:master","ref":"master","sha":"7fe16d336fd0db8eb73924c3018e34e91e136cf9","user":{"login":"lucyvk","id":6878858,"avatar_url":"https://avatars.githubusercontent.com/u/6878858?v=3","gravatar_id":"","url":"https://api.github.com/users/lucyvk","html_url":"https://github.com/lucyvk","followers_url":"https://api.github.com/users/lucyvk/followers","following_url":"https://api.github.com/users/lucyvk/following{/other_user}","gists_url":"https://api.github.com/users/lucyvk/gists{/gist_id}","starred_url":"https://api.github.com/users/lucyvk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lucyvk/subscriptions","organizations_url":"https://api.github.com/users/lucyvk/orgs","repos_url":"https://api.github.com/users/lucyvk/repos","events_url":"https://api.github.com/users/lucyvk/events{/privacy}","received_events_url":"https://api.github.com/users/lucyvk/received_events","type":"User","site_admin":false},"repo":{"id":51611392,"name":"ttwr","full_name":"lucyvk/ttwr","owner":{"login":"lucyvk","id":6878858,"avatar_url":"https://avatars.githubusercontent.com/u/6878858?v=3","gravatar_id":"","url":"https://api.github.com/users/lucyvk","html_url":"https://github.com/lucyvk","followers_url":"https://api.github.com/users/lucyvk/followers","following_url":"https://api.github.com/users/lucyvk/following{/other_user}","gists_url":"https://api.github.com/users/lucyvk/gists{/gist_id}","starred_url":"https://api.github.com/users/lucyvk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lucyvk/subscriptions","organizations_url":"https://api.github.com/users/lucyvk/orgs","repos_url":"https://api.github.com/users/lucyvk/repos","events_url":"https://api.github.com/users/lucyvk/events{/privacy}","received_events_url":"https://api.github.com/users/lucyvk/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lucyvk/ttwr","description":"This is the django app that runs the Theater That Was Rome project website.","fork":true,"url":"https://api.github.com/repos/lucyvk/ttwr","forks_url":"https://api.github.com/repos/lucyvk/ttwr/forks","keys_url":"https://api.github.com/repos/lucyvk/ttwr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lucyvk/ttwr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lucyvk/ttwr/teams","hooks_url":"https://api.github.com/repos/lucyvk/ttwr/hooks","issue_events_url":"https://api.github.com/repos/lucyvk/ttwr/issues/events{/number}","events_url":"https://api.github.com/repos/lucyvk/ttwr/events","assignees_url":"https://api.github.com/repos/lucyvk/ttwr/assignees{/user}","branches_url":"https://api.github.com/repos/lucyvk/ttwr/branches{/branch}","tags_url":"https://api.github.com/repos/lucyvk/ttwr/tags","blobs_url":"https://api.github.com/repos/lucyvk/ttwr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lucyvk/ttwr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lucyvk/ttwr/git/refs{/sha}","trees_url":"https://api.github.com/repos/lucyvk/ttwr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lucyvk/ttwr/statuses/{sha}","languages_url":"https://api.github.com/repos/lucyvk/ttwr/languages","stargazers_url":"https://api.github.com/repos/lucyvk/ttwr/stargazers","contributors_url":"https://api.github.com/repos/lucyvk/ttwr/contributors","subscribers_url":"https://api.github.com/repos/lucyvk/ttwr/subscribers","subscription_url":"https://api.github.com/repos/lucyvk/ttwr/subscription","commits_url":"https://api.github.com/repos/lucyvk/ttwr/commits{/sha}","git_commits_url":"https://api.github.com/repos/lucyvk/ttwr/git/commits{/sha}","comments_url":"https://api.github.com/repos/lucyvk/ttwr/comments{/number}","issue_comment_url":"https://api.github.com/repos/lucyvk/ttwr/issues/comments{/number}","contents_url":"https://api.github.com/repos/lucyvk/ttwr/contents/{+path}","compare_url":"https://api.github.com/repos/lucyvk/ttwr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lucyvk/ttwr/merges","archive_url":"https://api.github.com/repos/lucyvk/ttwr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lucyvk/ttwr/downloads","issues_url":"https://api.github.com/repos/lucyvk/ttwr/issues{/number}","pulls_url":"https://api.github.com/repos/lucyvk/ttwr/pulls{/number}","milestones_url":"https://api.github.com/repos/lucyvk/ttwr/milestones{/number}","notifications_url":"https://api.github.com/repos/lucyvk/ttwr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lucyvk/ttwr/labels{/name}","releases_url":"https://api.github.com/repos/lucyvk/ttwr/releases{/id}","deployments_url":"https://api.github.com/repos/lucyvk/ttwr/deployments","created_at":"2016-02-12T19:34:43Z","updated_at":"2016-02-12T19:34:43Z","pushed_at":"2016-04-14T16:40:17Z","git_url":"git://github.com/lucyvk/ttwr.git","ssh_url":"git@github.com:lucyvk/ttwr.git","clone_url":"https://github.com/lucyvk/ttwr.git","svn_url":"https://github.com/lucyvk/ttwr","homepage":null,"size":1723,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Brown-University-Library:master","ref":"master","sha":"173fadcfd43fcf9350c65603ad5b3760146fee33","user":{"login":"Brown-University-Library","id":1258826,"avatar_url":"https://avatars.githubusercontent.com/u/1258826?v=3","gravatar_id":"","url":"https://api.github.com/users/Brown-University-Library","html_url":"https://github.com/Brown-University-Library","followers_url":"https://api.github.com/users/Brown-University-Library/followers","following_url":"https://api.github.com/users/Brown-University-Library/following{/other_user}","gists_url":"https://api.github.com/users/Brown-University-Library/gists{/gist_id}","starred_url":"https://api.github.com/users/Brown-University-Library/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Brown-University-Library/subscriptions","organizations_url":"https://api.github.com/users/Brown-University-Library/orgs","repos_url":"https://api.github.com/users/Brown-University-Library/repos","events_url":"https://api.github.com/users/Brown-University-Library/events{/privacy}","received_events_url":"https://api.github.com/users/Brown-University-Library/received_events","type":"Organization","site_admin":false},"repo":{"id":12572314,"name":"ttwr","full_name":"Brown-University-Library/ttwr","owner":{"login":"Brown-University-Library","id":1258826,"avatar_url":"https://avatars.githubusercontent.com/u/1258826?v=3","gravatar_id":"","url":"https://api.github.com/users/Brown-University-Library","html_url":"https://github.com/Brown-University-Library","followers_url":"https://api.github.com/users/Brown-University-Library/followers","following_url":"https://api.github.com/users/Brown-University-Library/following{/other_user}","gists_url":"https://api.github.com/users/Brown-University-Library/gists{/gist_id}","starred_url":"https://api.github.com/users/Brown-University-Library/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Brown-University-Library/subscriptions","organizations_url":"https://api.github.com/users/Brown-University-Library/orgs","repos_url":"https://api.github.com/users/Brown-University-Library/repos","events_url":"https://api.github.com/users/Brown-University-Library/events{/privacy}","received_events_url":"https://api.github.com/users/Brown-University-Library/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Brown-University-Library/ttwr","description":"This is the django app that runs the Theater That Was Rome project website.","fork":false,"url":"https://api.github.com/repos/Brown-University-Library/ttwr","forks_url":"https://api.github.com/repos/Brown-University-Library/ttwr/forks","keys_url":"https://api.github.com/repos/Brown-University-Library/ttwr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Brown-University-Library/ttwr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Brown-University-Library/ttwr/teams","hooks_url":"https://api.github.com/repos/Brown-University-Library/ttwr/hooks","issue_events_url":"https://api.github.com/repos/Brown-University-Library/ttwr/issues/events{/number}","events_url":"https://api.github.com/repos/Brown-University-Library/ttwr/events","assignees_url":"https://api.github.com/repos/Brown-University-Library/ttwr/assignees{/user}","branches_url":"https://api.github.com/repos/Brown-University-Library/ttwr/branches{/branch}","tags_url":"https://api.github.com/repos/Brown-University-Library/ttwr/tags","blobs_url":"https://api.github.com/repos/Brown-University-Library/ttwr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Brown-University-Library/ttwr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Brown-University-Library/ttwr/git/refs{/sha}","trees_url":"https://api.github.com/repos/Brown-University-Library/ttwr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Brown-University-Library/ttwr/statuses/{sha}","languages_url":"https://api.github.com/repos/Brown-University-Library/ttwr/languages","stargazers_url":"https://api.github.com/repos/Brown-University-Library/ttwr/stargazers","contributors_url":"https://api.github.com/repos/Brown-University-Library/ttwr/contributors","subscribers_url":"https://api.github.com/repos/Brown-University-Library/ttwr/subscribers","subscription_url":"https://api.github.com/repos/Brown-University-Library/ttwr/subscription","commits_url":"https://api.github.com/repos/Brown-University-Library/ttwr/commits{/sha}","git_commits_url":"https://api.github.com/repos/Brown-University-Library/ttwr/git/commits{/sha}","comments_url":"https://api.github.com/repos/Brown-University-Library/ttwr/comments{/number}","issue_comment_url":"https://api.github.com/repos/Brown-University-Library/ttwr/issues/comments{/number}","contents_url":"https://api.github.com/repos/Brown-University-Library/ttwr/contents/{+path}","compare_url":"https://api.github.com/repos/Brown-University-Library/ttwr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Brown-University-Library/ttwr/merges","archive_url":"https://api.github.com/repos/Brown-University-Library/ttwr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Brown-University-Library/ttwr/downloads","issues_url":"https://api.github.com/repos/Brown-University-Library/ttwr/issues{/number}","pulls_url":"https://api.github.com/repos/Brown-University-Library/ttwr/pulls{/number}","milestones_url":"https://api.github.com/repos/Brown-University-Library/ttwr/milestones{/number}","notifications_url":"https://api.github.com/repos/Brown-University-Library/ttwr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Brown-University-Library/ttwr/labels{/name}","releases_url":"https://api.github.com/repos/Brown-University-Library/ttwr/releases{/id}","deployments_url":"https://api.github.com/repos/Brown-University-Library/ttwr/deployments","created_at":"2013-09-03T19:06:29Z","updated_at":"2016-02-03T20:49:41Z","pushed_at":"2016-04-14T16:32:35Z","git_url":"git://github.com/Brown-University-Library/ttwr.git","ssh_url":"git@github.com:Brown-University-Library/ttwr.git","clone_url":"https://github.com/Brown-University-Library/ttwr.git","svn_url":"https://github.com/Brown-University-Library/ttwr","homepage":null,"size":1676,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":25,"forks":4,"open_issues":25,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Brown-University-Library/ttwr/pulls/155"},"html":{"href":"https://github.com/Brown-University-Library/ttwr/pull/155"},"issue":{"href":"https://api.github.com/repos/Brown-University-Library/ttwr/issues/155"},"comments":{"href":"https://api.github.com/repos/Brown-University-Library/ttwr/issues/155/comments"},"review_comments":{"href":"https://api.github.com/repos/Brown-University-Library/ttwr/pulls/155/comments"},"review_comment":{"href":"https://api.github.com/repos/Brown-University-Library/ttwr/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Brown-University-Library/ttwr/pulls/155/commits"},"statuses":{"href":"https://api.github.com/repos/Brown-University-Library/ttwr/statuses/7fe16d336fd0db8eb73924c3018e34e91e136cf9"}}}}