{"action":"created","comment":{"url":"https://api.github.com/repos/biocore/american-gut-web/pulls/comments/25616723","id":25616723,"diff_hunk":"@@ -386,6 +386,68 @@ def updateAGBarcode(self, barcode, ag_kit_id, site_sampled,\n                                     refunded, withdrawn])\n         self.connection.commit()\n \n+    def registerHandoutKit(self, ag_login_id, supplied_kit_id):\n+        \"\"\"\n+        Returns\n+        -------\n+        int\n+            1:  success\n+            -1: insert failed due to IntegrityError\n+\n+        Notes\n+        -----\n+        Whatever is passed as kit_password will be added AS IS. This means you\n+        must hash the password before passing, if desired.\n+        \"\"\"\n+        kitinfo = self.getAGHandoutKitDetails(supplied_kit_id)\n+        printresults = self.checkPrintResults(supplied_kit_id)\n+        if printresults is None:\n+            printresults = 'n'\n+\n+        conn_handler = SQLConnectionHandler()\n+        queue = \"register_%s\" % supplied_kit_id\n+        conn_handler.create_queue(queue)\n+        # insert the actual kit into the kit table.\n+        # Needs to be done directly because ag_kit_id needed for rest\n+        kit_id = conn_handler.execute_fetchone(\n+            \"\"\"INSERT INTO ag_kit\n+            (ag_login_id, supplied_kit_id, kit_password, swabs_per_kit,\n+            kit_verification_code, print_results)\n+            VALUES (%s, %s, %s, %s, %s, %s) RETURNING ag_kit_id\"\"\",\n+            (ag_login_id, supplied_kit_id, kitinfo['password'],\n+             kitinfo['swabs_per_kit'], kitinfo['verification_code'],\n+             printresults))[0]\n+\n+        # get the barcodes and add them to the queue\n+        sql = \"SELECT barcode FROM ag_handout_kits WHERE kit_id = %s\"\n+        for row in conn_handler.execute_fetchall(sql, [supplied_kit_id]):\n+            barcode = row[0]\n+            conn_handler.add_to_queue(\n+                queue, \"INSERT INTO barcode (barcode) VALUES (%s)\", [barcode])\n+            conn_handler.add_to_queue(\n+                queue, \"INSERT INTO project_barcode (project_id, barcode) \"\n+                \"VALUES (1, %s)\", [barcode])","path":"amgut/lib/data_access/ag_data_access.py","position":44,"original_position":44,"commit_id":"72acdecfbfa52c8784cf3a15fa293b20e74247d4","original_commit_id":"72acdecfbfa52c8784cf3a15fa293b20e74247d4","user":{"login":"wasade","id":474290,"avatar_url":"https://avatars.githubusercontent.com/u/474290?v=3","gravatar_id":"","url":"https://api.github.com/users/wasade","html_url":"https://github.com/wasade","followers_url":"https://api.github.com/users/wasade/followers","following_url":"https://api.github.com/users/wasade/following{/other_user}","gists_url":"https://api.github.com/users/wasade/gists{/gist_id}","starred_url":"https://api.github.com/users/wasade/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wasade/subscriptions","organizations_url":"https://api.github.com/users/wasade/orgs","repos_url":"https://api.github.com/users/wasade/repos","events_url":"https://api.github.com/users/wasade/events{/privacy}","received_events_url":"https://api.github.com/users/wasade/received_events","type":"User","site_admin":false},"body":"Please do not hardcode IDs\r\n\r\nThe project ID is tied to the handout kit on handout kit creation, so this step is not necessary.","created_at":"2015-03-02T17:19:16Z","updated_at":"2015-03-02T17:19:16Z","html_url":"https://github.com/biocore/american-gut-web/pull/393#discussion_r25616723","pull_request_url":"https://api.github.com/repos/biocore/american-gut-web/pulls/393","_links":{"self":{"href":"https://api.github.com/repos/biocore/american-gut-web/pulls/comments/25616723"},"html":{"href":"https://github.com/biocore/american-gut-web/pull/393#discussion_r25616723"},"pull_request":{"href":"https://api.github.com/repos/biocore/american-gut-web/pulls/393"}}},"pull_request":{"url":"https://api.github.com/repos/biocore/american-gut-web/pulls/393","id":30298073,"html_url":"https://github.com/biocore/american-gut-web/pull/393","diff_url":"https://github.com/biocore/american-gut-web/pull/393.diff","patch_url":"https://github.com/biocore/american-gut-web/pull/393.patch","issue_url":"https://api.github.com/repos/biocore/american-gut-web/issues/393","number":393,"state":"open","locked":false,"title":"Queued register system","user":{"login":"squirrelo","id":3079066,"avatar_url":"https://avatars.githubusercontent.com/u/3079066?v=3","gravatar_id":"","url":"https://api.github.com/users/squirrelo","html_url":"https://github.com/squirrelo","followers_url":"https://api.github.com/users/squirrelo/followers","following_url":"https://api.github.com/users/squirrelo/following{/other_user}","gists_url":"https://api.github.com/users/squirrelo/gists{/gist_id}","starred_url":"https://api.github.com/users/squirrelo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/squirrelo/subscriptions","organizations_url":"https://api.github.com/users/squirrelo/orgs","repos_url":"https://api.github.com/users/squirrelo/repos","events_url":"https://api.github.com/users/squirrelo/events{/privacy}","received_events_url":"https://api.github.com/users/squirrelo/received_events","type":"User","site_admin":false},"body":"This adds the queue system from qiita to this repository and then uses it to register kits. It also disables the submit button on the register page once it's clicked, so we don't get the multiple registration eror we've been seeing.","created_at":"2015-03-02T16:37:45Z","updated_at":"2015-03-02T17:19:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0fe1127e0c575d3f8a13a5df13b760b40ec1b9d0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/biocore/american-gut-web/pulls/393/commits","review_comments_url":"https://api.github.com/repos/biocore/american-gut-web/pulls/393/comments","review_comment_url":"https://api.github.com/repos/biocore/american-gut-web/pulls/comments{/number}","comments_url":"https://api.github.com/repos/biocore/american-gut-web/issues/393/comments","statuses_url":"https://api.github.com/repos/biocore/american-gut-web/statuses/72acdecfbfa52c8784cf3a15fa293b20e74247d4","head":{"label":"squirrelo:queued-register-system","ref":"queued-register-system","sha":"72acdecfbfa52c8784cf3a15fa293b20e74247d4","user":{"login":"squirrelo","id":3079066,"avatar_url":"https://avatars.githubusercontent.com/u/3079066?v=3","gravatar_id":"","url":"https://api.github.com/users/squirrelo","html_url":"https://github.com/squirrelo","followers_url":"https://api.github.com/users/squirrelo/followers","following_url":"https://api.github.com/users/squirrelo/following{/other_user}","gists_url":"https://api.github.com/users/squirrelo/gists{/gist_id}","starred_url":"https://api.github.com/users/squirrelo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/squirrelo/subscriptions","organizations_url":"https://api.github.com/users/squirrelo/orgs","repos_url":"https://api.github.com/users/squirrelo/repos","events_url":"https://api.github.com/users/squirrelo/events{/privacy}","received_events_url":"https://api.github.com/users/squirrelo/received_events","type":"User","site_admin":false},"repo":{"id":22621217,"name":"american-gut-web","full_name":"squirrelo/american-gut-web","owner":{"login":"squirrelo","id":3079066,"avatar_url":"https://avatars.githubusercontent.com/u/3079066?v=3","gravatar_id":"","url":"https://api.github.com/users/squirrelo","html_url":"https://github.com/squirrelo","followers_url":"https://api.github.com/users/squirrelo/followers","following_url":"https://api.github.com/users/squirrelo/following{/other_user}","gists_url":"https://api.github.com/users/squirrelo/gists{/gist_id}","starred_url":"https://api.github.com/users/squirrelo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/squirrelo/subscriptions","organizations_url":"https://api.github.com/users/squirrelo/orgs","repos_url":"https://api.github.com/users/squirrelo/repos","events_url":"https://api.github.com/users/squirrelo/events{/privacy}","received_events_url":"https://api.github.com/users/squirrelo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/squirrelo/american-gut-web","description":"The website for the American Gut Project participant portal","fork":true,"url":"https://api.github.com/repos/squirrelo/american-gut-web","forks_url":"https://api.github.com/repos/squirrelo/american-gut-web/forks","keys_url":"https://api.github.com/repos/squirrelo/american-gut-web/keys{/key_id}","collaborators_url":"https://api.github.com/repos/squirrelo/american-gut-web/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/squirrelo/american-gut-web/teams","hooks_url":"https://api.github.com/repos/squirrelo/american-gut-web/hooks","issue_events_url":"https://api.github.com/repos/squirrelo/american-gut-web/issues/events{/number}","events_url":"https://api.github.com/repos/squirrelo/american-gut-web/events","assignees_url":"https://api.github.com/repos/squirrelo/american-gut-web/assignees{/user}","branches_url":"https://api.github.com/repos/squirrelo/american-gut-web/branches{/branch}","tags_url":"https://api.github.com/repos/squirrelo/american-gut-web/tags","blobs_url":"https://api.github.com/repos/squirrelo/american-gut-web/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/squirrelo/american-gut-web/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/squirrelo/american-gut-web/git/refs{/sha}","trees_url":"https://api.github.com/repos/squirrelo/american-gut-web/git/trees{/sha}","statuses_url":"https://api.github.com/repos/squirrelo/american-gut-web/statuses/{sha}","languages_url":"https://api.github.com/repos/squirrelo/american-gut-web/languages","stargazers_url":"https://api.github.com/repos/squirrelo/american-gut-web/stargazers","contributors_url":"https://api.github.com/repos/squirrelo/american-gut-web/contributors","subscribers_url":"https://api.github.com/repos/squirrelo/american-gut-web/subscribers","subscription_url":"https://api.github.com/repos/squirrelo/american-gut-web/subscription","commits_url":"https://api.github.com/repos/squirrelo/american-gut-web/commits{/sha}","git_commits_url":"https://api.github.com/repos/squirrelo/american-gut-web/git/commits{/sha}","comments_url":"https://api.github.com/repos/squirrelo/american-gut-web/comments{/number}","issue_comment_url":"https://api.github.com/repos/squirrelo/american-gut-web/issues/comments{/number}","contents_url":"https://api.github.com/repos/squirrelo/american-gut-web/contents/{+path}","compare_url":"https://api.github.com/repos/squirrelo/american-gut-web/compare/{base}...{head}","merges_url":"https://api.github.com/repos/squirrelo/american-gut-web/merges","archive_url":"https://api.github.com/repos/squirrelo/american-gut-web/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/squirrelo/american-gut-web/downloads","issues_url":"https://api.github.com/repos/squirrelo/american-gut-web/issues{/number}","pulls_url":"https://api.github.com/repos/squirrelo/american-gut-web/pulls{/number}","milestones_url":"https://api.github.com/repos/squirrelo/american-gut-web/milestones{/number}","notifications_url":"https://api.github.com/repos/squirrelo/american-gut-web/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/squirrelo/american-gut-web/labels{/name}","releases_url":"https://api.github.com/repos/squirrelo/american-gut-web/releases{/id}","created_at":"2014-08-04T21:49:51Z","updated_at":"2015-02-28T23:18:33Z","pushed_at":"2015-03-02T16:36:23Z","git_url":"git://github.com/squirrelo/american-gut-web.git","ssh_url":"git@github.com:squirrelo/american-gut-web.git","clone_url":"https://github.com/squirrelo/american-gut-web.git","svn_url":"https://github.com/squirrelo/american-gut-web","homepage":null,"size":31420,"stargazers_count":0,"watchers_count":0,"language":"Python","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":"biocore:master","ref":"master","sha":"48ccfe8e8412b1798a79a77353cbb097b62cada6","user":{"login":"biocore","id":6241857,"avatar_url":"https://avatars.githubusercontent.com/u/6241857?v=3","gravatar_id":"","url":"https://api.github.com/users/biocore","html_url":"https://github.com/biocore","followers_url":"https://api.github.com/users/biocore/followers","following_url":"https://api.github.com/users/biocore/following{/other_user}","gists_url":"https://api.github.com/users/biocore/gists{/gist_id}","starred_url":"https://api.github.com/users/biocore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/biocore/subscriptions","organizations_url":"https://api.github.com/users/biocore/orgs","repos_url":"https://api.github.com/users/biocore/repos","events_url":"https://api.github.com/users/biocore/events{/privacy}","received_events_url":"https://api.github.com/users/biocore/received_events","type":"Organization","site_admin":false},"repo":{"id":22621149,"name":"american-gut-web","full_name":"biocore/american-gut-web","owner":{"login":"biocore","id":6241857,"avatar_url":"https://avatars.githubusercontent.com/u/6241857?v=3","gravatar_id":"","url":"https://api.github.com/users/biocore","html_url":"https://github.com/biocore","followers_url":"https://api.github.com/users/biocore/followers","following_url":"https://api.github.com/users/biocore/following{/other_user}","gists_url":"https://api.github.com/users/biocore/gists{/gist_id}","starred_url":"https://api.github.com/users/biocore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/biocore/subscriptions","organizations_url":"https://api.github.com/users/biocore/orgs","repos_url":"https://api.github.com/users/biocore/repos","events_url":"https://api.github.com/users/biocore/events{/privacy}","received_events_url":"https://api.github.com/users/biocore/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/biocore/american-gut-web","description":"The website for the American Gut Project participant portal","fork":false,"url":"https://api.github.com/repos/biocore/american-gut-web","forks_url":"https://api.github.com/repos/biocore/american-gut-web/forks","keys_url":"https://api.github.com/repos/biocore/american-gut-web/keys{/key_id}","collaborators_url":"https://api.github.com/repos/biocore/american-gut-web/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/biocore/american-gut-web/teams","hooks_url":"https://api.github.com/repos/biocore/american-gut-web/hooks","issue_events_url":"https://api.github.com/repos/biocore/american-gut-web/issues/events{/number}","events_url":"https://api.github.com/repos/biocore/american-gut-web/events","assignees_url":"https://api.github.com/repos/biocore/american-gut-web/assignees{/user}","branches_url":"https://api.github.com/repos/biocore/american-gut-web/branches{/branch}","tags_url":"https://api.github.com/repos/biocore/american-gut-web/tags","blobs_url":"https://api.github.com/repos/biocore/american-gut-web/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/biocore/american-gut-web/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/biocore/american-gut-web/git/refs{/sha}","trees_url":"https://api.github.com/repos/biocore/american-gut-web/git/trees{/sha}","statuses_url":"https://api.github.com/repos/biocore/american-gut-web/statuses/{sha}","languages_url":"https://api.github.com/repos/biocore/american-gut-web/languages","stargazers_url":"https://api.github.com/repos/biocore/american-gut-web/stargazers","contributors_url":"https://api.github.com/repos/biocore/american-gut-web/contributors","subscribers_url":"https://api.github.com/repos/biocore/american-gut-web/subscribers","subscription_url":"https://api.github.com/repos/biocore/american-gut-web/subscription","commits_url":"https://api.github.com/repos/biocore/american-gut-web/commits{/sha}","git_commits_url":"https://api.github.com/repos/biocore/american-gut-web/git/commits{/sha}","comments_url":"https://api.github.com/repos/biocore/american-gut-web/comments{/number}","issue_comment_url":"https://api.github.com/repos/biocore/american-gut-web/issues/comments{/number}","contents_url":"https://api.github.com/repos/biocore/american-gut-web/contents/{+path}","compare_url":"https://api.github.com/repos/biocore/american-gut-web/compare/{base}...{head}","merges_url":"https://api.github.com/repos/biocore/american-gut-web/merges","archive_url":"https://api.github.com/repos/biocore/american-gut-web/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/biocore/american-gut-web/downloads","issues_url":"https://api.github.com/repos/biocore/american-gut-web/issues{/number}","pulls_url":"https://api.github.com/repos/biocore/american-gut-web/pulls{/number}","milestones_url":"https://api.github.com/repos/biocore/american-gut-web/milestones{/number}","notifications_url":"https://api.github.com/repos/biocore/american-gut-web/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/biocore/american-gut-web/labels{/name}","releases_url":"https://api.github.com/repos/biocore/american-gut-web/releases{/id}","created_at":"2014-08-04T21:47:22Z","updated_at":"2015-03-02T15:18:59Z","pushed_at":"2015-03-02T15:18:59Z","git_url":"git://github.com/biocore/american-gut-web.git","ssh_url":"git@github.com:biocore/american-gut-web.git","clone_url":"https://github.com/biocore/american-gut-web.git","svn_url":"https://github.com/biocore/american-gut-web","homepage":null,"size":57698,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":43,"forks":12,"open_issues":43,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/biocore/american-gut-web/pulls/393"},"html":{"href":"https://github.com/biocore/american-gut-web/pull/393"},"issue":{"href":"https://api.github.com/repos/biocore/american-gut-web/issues/393"},"comments":{"href":"https://api.github.com/repos/biocore/american-gut-web/issues/393/comments"},"review_comments":{"href":"https://api.github.com/repos/biocore/american-gut-web/pulls/393/comments"},"review_comment":{"href":"https://api.github.com/repos/biocore/american-gut-web/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/biocore/american-gut-web/pulls/393/commits"},"statuses":{"href":"https://api.github.com/repos/biocore/american-gut-web/statuses/72acdecfbfa52c8784cf3a15fa293b20e74247d4"}}}}