{"action":"created","comment":{"url":"https://api.github.com/repos/SkillfulCactus/OpenElect/pulls/comments/29088499","id":29088499,"diff_hunk":"@@ -10,40 +10,57 @@ var uuid = require('uuid');\n \n var ballots = {\n \tcreate: function(req, res) {\n-      //grab the ballot from the request\n-      var receivedBallot = req.body.ballot;\n+    //grab the ballot from the request\n+    var receivedBallot = req.body.ballot;\n+    var receivedResponse = req.body.response;\n+\n+    if (receivedBallot){\n       //first, check that the election is still open.\n       Election.forge({id: receivedBallot.election_id})\n-              .fetch()\n-              .then(function(election){\n-                if (!election) res.send(400, 'Error: election not found.');\n-                //TODO: re-enable check for accepting votes\n-                // if (!election.get('accepting_votes')) res.send(403, 'This election is no longer accepting votes.');\n-                //the election exists and is accepting votes, so let's enter this ballot\n-                Ballot.forge({election_id: receivedBallot.election_id, user_id: receivedBallot.user_id})\n-                      .fetch()\n-                      .then(function(ballot){\n-                        //check to make sure the user hasn't already voted\n-                        // if (ballot) res.send(403, 'You have already voted in this election.'); //TODO: need to re-enable\n-                        Ballot.forge(\n-                          {\n-                            id: uuid.v4(),\n-                            election_id: receivedBallot.election_id,\n-                            user_id: receivedBallot.user_id,\n-                            choices: receivedBallot.response\n-                          }).save({},{method: insert})\n-                            .then(function(ballot){\n-                              //todo: hash ballot\n-                              var hash = 'kj23qlkjasdf';\n-                              var response = { ballot_id: ballot.get('id'),\n-                                                 receipt: hash,\n-                                                 election_id: ballot.get('election_id'),\n-                                                 created_at: ballot.get('created_at') };\n-                              res.send(201, response);\n-                            });// save ballot\n-                      });//fetch ballot\n-              });//fetch election\n+        .fetch()\n+        .then(function(election){\n+          if (!election) res.send(400, 'Error: election not found.');\n+          //TODO: re-enable check for accepting votes\n+          // if (!election.get('accepting_votes')) res.send(403, 'This election is no longer accepting votes.');","path":"server/controllers/api/ballots.js","position":46,"original_position":46,"commit_id":"8e47614a842c5425bfe60a8fc36452ecd8ebf46e","original_commit_id":"8e47614a842c5425bfe60a8fc36452ecd8ebf46e","user":{"login":"ryyann","id":2137634,"avatar_url":"https://avatars.githubusercontent.com/u/2137634?v=3","gravatar_id":"","url":"https://api.github.com/users/ryyann","html_url":"https://github.com/ryyann","followers_url":"https://api.github.com/users/ryyann/followers","following_url":"https://api.github.com/users/ryyann/following{/other_user}","gists_url":"https://api.github.com/users/ryyann/gists{/gist_id}","starred_url":"https://api.github.com/users/ryyann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryyann/subscriptions","organizations_url":"https://api.github.com/users/ryyann/orgs","repos_url":"https://api.github.com/users/ryyann/repos","events_url":"https://api.github.com/users/ryyann/events{/privacy}","received_events_url":"https://api.github.com/users/ryyann/received_events","type":"User","site_admin":false},"body":"Might as well re-enable this first before merging","created_at":"2015-04-24T21:45:23Z","updated_at":"2015-04-24T21:45:23Z","html_url":"https://github.com/SkillfulCactus/OpenElect/pull/174#discussion_r29088499","pull_request_url":"https://api.github.com/repos/SkillfulCactus/OpenElect/pulls/174","_links":{"self":{"href":"https://api.github.com/repos/SkillfulCactus/OpenElect/pulls/comments/29088499"},"html":{"href":"https://github.com/SkillfulCactus/OpenElect/pull/174#discussion_r29088499"},"pull_request":{"href":"https://api.github.com/repos/SkillfulCactus/OpenElect/pulls/174"}}},"pull_request":{"url":"https://api.github.com/repos/SkillfulCactus/OpenElect/pulls/174","id":34088853,"html_url":"https://github.com/SkillfulCactus/OpenElect/pull/174","diff_url":"https://github.com/SkillfulCactus/OpenElect/pull/174.diff","patch_url":"https://github.com/SkillfulCactus/OpenElect/pull/174.patch","issue_url":"https://api.github.com/repos/SkillfulCactus/OpenElect/issues/174","number":174,"state":"open","locked":false,"title":"Fix Ballot creation bug, closes #163. ","user":{"login":"brianpchsu","id":8574617,"avatar_url":"https://avatars.githubusercontent.com/u/8574617?v=3","gravatar_id":"","url":"https://api.github.com/users/brianpchsu","html_url":"https://github.com/brianpchsu","followers_url":"https://api.github.com/users/brianpchsu/followers","following_url":"https://api.github.com/users/brianpchsu/following{/other_user}","gists_url":"https://api.github.com/users/brianpchsu/gists{/gist_id}","starred_url":"https://api.github.com/users/brianpchsu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brianpchsu/subscriptions","organizations_url":"https://api.github.com/users/brianpchsu/orgs","repos_url":"https://api.github.com/users/brianpchsu/repos","events_url":"https://api.github.com/users/brianpchsu/events{/privacy}","received_events_url":"https://api.github.com/users/brianpchsu/received_events","type":"User","site_admin":false},"body":"Ballot creation:\r\n![screen shot 2015-04-24 at 2 38 56 pm](https://cloud.githubusercontent.com/assets/8574617/7329076/5e6b2f64-ea90-11e4-8514-1e089e942ccc.png)\r\n","created_at":"2015-04-24T21:44:16Z","updated_at":"2015-04-24T21:45:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2480337a787ea590a4bc5db170c3aba4a527eba2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/SkillfulCactus/OpenElect/pulls/174/commits","review_comments_url":"https://api.github.com/repos/SkillfulCactus/OpenElect/pulls/174/comments","review_comment_url":"https://api.github.com/repos/SkillfulCactus/OpenElect/pulls/comments{/number}","comments_url":"https://api.github.com/repos/SkillfulCactus/OpenElect/issues/174/comments","statuses_url":"https://api.github.com/repos/SkillfulCactus/OpenElect/statuses/8e47614a842c5425bfe60a8fc36452ecd8ebf46e","head":{"label":"brianpchsu:bug/ballotRoute-#163","ref":"bug/ballotRoute-#163","sha":"8e47614a842c5425bfe60a8fc36452ecd8ebf46e","user":{"login":"brianpchsu","id":8574617,"avatar_url":"https://avatars.githubusercontent.com/u/8574617?v=3","gravatar_id":"","url":"https://api.github.com/users/brianpchsu","html_url":"https://github.com/brianpchsu","followers_url":"https://api.github.com/users/brianpchsu/followers","following_url":"https://api.github.com/users/brianpchsu/following{/other_user}","gists_url":"https://api.github.com/users/brianpchsu/gists{/gist_id}","starred_url":"https://api.github.com/users/brianpchsu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brianpchsu/subscriptions","organizations_url":"https://api.github.com/users/brianpchsu/orgs","repos_url":"https://api.github.com/users/brianpchsu/repos","events_url":"https://api.github.com/users/brianpchsu/events{/privacy}","received_events_url":"https://api.github.com/users/brianpchsu/received_events","type":"User","site_admin":false},"repo":{"id":33417371,"name":"OpenElect","full_name":"brianpchsu/OpenElect","owner":{"login":"brianpchsu","id":8574617,"avatar_url":"https://avatars.githubusercontent.com/u/8574617?v=3","gravatar_id":"","url":"https://api.github.com/users/brianpchsu","html_url":"https://github.com/brianpchsu","followers_url":"https://api.github.com/users/brianpchsu/followers","following_url":"https://api.github.com/users/brianpchsu/following{/other_user}","gists_url":"https://api.github.com/users/brianpchsu/gists{/gist_id}","starred_url":"https://api.github.com/users/brianpchsu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brianpchsu/subscriptions","organizations_url":"https://api.github.com/users/brianpchsu/orgs","repos_url":"https://api.github.com/users/brianpchsu/repos","events_url":"https://api.github.com/users/brianpchsu/events{/privacy}","received_events_url":"https://api.github.com/users/brianpchsu/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/brianpchsu/OpenElect","description":"A platform for holding secure, verifiable elections.","fork":true,"url":"https://api.github.com/repos/brianpchsu/OpenElect","forks_url":"https://api.github.com/repos/brianpchsu/OpenElect/forks","keys_url":"https://api.github.com/repos/brianpchsu/OpenElect/keys{/key_id}","collaborators_url":"https://api.github.com/repos/brianpchsu/OpenElect/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/brianpchsu/OpenElect/teams","hooks_url":"https://api.github.com/repos/brianpchsu/OpenElect/hooks","issue_events_url":"https://api.github.com/repos/brianpchsu/OpenElect/issues/events{/number}","events_url":"https://api.github.com/repos/brianpchsu/OpenElect/events","assignees_url":"https://api.github.com/repos/brianpchsu/OpenElect/assignees{/user}","branches_url":"https://api.github.com/repos/brianpchsu/OpenElect/branches{/branch}","tags_url":"https://api.github.com/repos/brianpchsu/OpenElect/tags","blobs_url":"https://api.github.com/repos/brianpchsu/OpenElect/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/brianpchsu/OpenElect/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/brianpchsu/OpenElect/git/refs{/sha}","trees_url":"https://api.github.com/repos/brianpchsu/OpenElect/git/trees{/sha}","statuses_url":"https://api.github.com/repos/brianpchsu/OpenElect/statuses/{sha}","languages_url":"https://api.github.com/repos/brianpchsu/OpenElect/languages","stargazers_url":"https://api.github.com/repos/brianpchsu/OpenElect/stargazers","contributors_url":"https://api.github.com/repos/brianpchsu/OpenElect/contributors","subscribers_url":"https://api.github.com/repos/brianpchsu/OpenElect/subscribers","subscription_url":"https://api.github.com/repos/brianpchsu/OpenElect/subscription","commits_url":"https://api.github.com/repos/brianpchsu/OpenElect/commits{/sha}","git_commits_url":"https://api.github.com/repos/brianpchsu/OpenElect/git/commits{/sha}","comments_url":"https://api.github.com/repos/brianpchsu/OpenElect/comments{/number}","issue_comment_url":"https://api.github.com/repos/brianpchsu/OpenElect/issues/comments{/number}","contents_url":"https://api.github.com/repos/brianpchsu/OpenElect/contents/{+path}","compare_url":"https://api.github.com/repos/brianpchsu/OpenElect/compare/{base}...{head}","merges_url":"https://api.github.com/repos/brianpchsu/OpenElect/merges","archive_url":"https://api.github.com/repos/brianpchsu/OpenElect/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/brianpchsu/OpenElect/downloads","issues_url":"https://api.github.com/repos/brianpchsu/OpenElect/issues{/number}","pulls_url":"https://api.github.com/repos/brianpchsu/OpenElect/pulls{/number}","milestones_url":"https://api.github.com/repos/brianpchsu/OpenElect/milestones{/number}","notifications_url":"https://api.github.com/repos/brianpchsu/OpenElect/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/brianpchsu/OpenElect/labels{/name}","releases_url":"https://api.github.com/repos/brianpchsu/OpenElect/releases{/id}","created_at":"2015-04-04T19:30:55Z","updated_at":"2015-04-09T19:00:37Z","pushed_at":"2015-04-24T21:42:17Z","git_url":"git://github.com/brianpchsu/OpenElect.git","ssh_url":"git@github.com:brianpchsu/OpenElect.git","clone_url":"https://github.com/brianpchsu/OpenElect.git","svn_url":"https://github.com/brianpchsu/OpenElect","homepage":null,"size":3551,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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":"SkillfulCactus:master","ref":"master","sha":"fa1d55a52669d1738e9c189ececd1078b1f0c67f","user":{"login":"SkillfulCactus","id":11742517,"avatar_url":"https://avatars.githubusercontent.com/u/11742517?v=3","gravatar_id":"","url":"https://api.github.com/users/SkillfulCactus","html_url":"https://github.com/SkillfulCactus","followers_url":"https://api.github.com/users/SkillfulCactus/followers","following_url":"https://api.github.com/users/SkillfulCactus/following{/other_user}","gists_url":"https://api.github.com/users/SkillfulCactus/gists{/gist_id}","starred_url":"https://api.github.com/users/SkillfulCactus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SkillfulCactus/subscriptions","organizations_url":"https://api.github.com/users/SkillfulCactus/orgs","repos_url":"https://api.github.com/users/SkillfulCactus/repos","events_url":"https://api.github.com/users/SkillfulCactus/events{/privacy}","received_events_url":"https://api.github.com/users/SkillfulCactus/received_events","type":"Organization","site_admin":false},"repo":{"id":33416867,"name":"OpenElect","full_name":"SkillfulCactus/OpenElect","owner":{"login":"SkillfulCactus","id":11742517,"avatar_url":"https://avatars.githubusercontent.com/u/11742517?v=3","gravatar_id":"","url":"https://api.github.com/users/SkillfulCactus","html_url":"https://github.com/SkillfulCactus","followers_url":"https://api.github.com/users/SkillfulCactus/followers","following_url":"https://api.github.com/users/SkillfulCactus/following{/other_user}","gists_url":"https://api.github.com/users/SkillfulCactus/gists{/gist_id}","starred_url":"https://api.github.com/users/SkillfulCactus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SkillfulCactus/subscriptions","organizations_url":"https://api.github.com/users/SkillfulCactus/orgs","repos_url":"https://api.github.com/users/SkillfulCactus/repos","events_url":"https://api.github.com/users/SkillfulCactus/events{/privacy}","received_events_url":"https://api.github.com/users/SkillfulCactus/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SkillfulCactus/OpenElect","description":"A platform for holding secure, verifiable elections.","fork":false,"url":"https://api.github.com/repos/SkillfulCactus/OpenElect","forks_url":"https://api.github.com/repos/SkillfulCactus/OpenElect/forks","keys_url":"https://api.github.com/repos/SkillfulCactus/OpenElect/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SkillfulCactus/OpenElect/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SkillfulCactus/OpenElect/teams","hooks_url":"https://api.github.com/repos/SkillfulCactus/OpenElect/hooks","issue_events_url":"https://api.github.com/repos/SkillfulCactus/OpenElect/issues/events{/number}","events_url":"https://api.github.com/repos/SkillfulCactus/OpenElect/events","assignees_url":"https://api.github.com/repos/SkillfulCactus/OpenElect/assignees{/user}","branches_url":"https://api.github.com/repos/SkillfulCactus/OpenElect/branches{/branch}","tags_url":"https://api.github.com/repos/SkillfulCactus/OpenElect/tags","blobs_url":"https://api.github.com/repos/SkillfulCactus/OpenElect/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SkillfulCactus/OpenElect/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SkillfulCactus/OpenElect/git/refs{/sha}","trees_url":"https://api.github.com/repos/SkillfulCactus/OpenElect/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SkillfulCactus/OpenElect/statuses/{sha}","languages_url":"https://api.github.com/repos/SkillfulCactus/OpenElect/languages","stargazers_url":"https://api.github.com/repos/SkillfulCactus/OpenElect/stargazers","contributors_url":"https://api.github.com/repos/SkillfulCactus/OpenElect/contributors","subscribers_url":"https://api.github.com/repos/SkillfulCactus/OpenElect/subscribers","subscription_url":"https://api.github.com/repos/SkillfulCactus/OpenElect/subscription","commits_url":"https://api.github.com/repos/SkillfulCactus/OpenElect/commits{/sha}","git_commits_url":"https://api.github.com/repos/SkillfulCactus/OpenElect/git/commits{/sha}","comments_url":"https://api.github.com/repos/SkillfulCactus/OpenElect/comments{/number}","issue_comment_url":"https://api.github.com/repos/SkillfulCactus/OpenElect/issues/comments{/number}","contents_url":"https://api.github.com/repos/SkillfulCactus/OpenElect/contents/{+path}","compare_url":"https://api.github.com/repos/SkillfulCactus/OpenElect/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SkillfulCactus/OpenElect/merges","archive_url":"https://api.github.com/repos/SkillfulCactus/OpenElect/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SkillfulCactus/OpenElect/downloads","issues_url":"https://api.github.com/repos/SkillfulCactus/OpenElect/issues{/number}","pulls_url":"https://api.github.com/repos/SkillfulCactus/OpenElect/pulls{/number}","milestones_url":"https://api.github.com/repos/SkillfulCactus/OpenElect/milestones{/number}","notifications_url":"https://api.github.com/repos/SkillfulCactus/OpenElect/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SkillfulCactus/OpenElect/labels{/name}","releases_url":"https://api.github.com/repos/SkillfulCactus/OpenElect/releases{/id}","created_at":"2015-04-04T19:12:15Z","updated_at":"2015-04-24T20:36:56Z","pushed_at":"2015-04-24T21:44:16Z","git_url":"git://github.com/SkillfulCactus/OpenElect.git","ssh_url":"git@github.com:SkillfulCactus/OpenElect.git","clone_url":"https://github.com/SkillfulCactus/OpenElect.git","svn_url":"https://github.com/SkillfulCactus/OpenElect","homepage":null,"size":4385,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":38,"forks":4,"open_issues":38,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/SkillfulCactus/OpenElect/pulls/174"},"html":{"href":"https://github.com/SkillfulCactus/OpenElect/pull/174"},"issue":{"href":"https://api.github.com/repos/SkillfulCactus/OpenElect/issues/174"},"comments":{"href":"https://api.github.com/repos/SkillfulCactus/OpenElect/issues/174/comments"},"review_comments":{"href":"https://api.github.com/repos/SkillfulCactus/OpenElect/pulls/174/comments"},"review_comment":{"href":"https://api.github.com/repos/SkillfulCactus/OpenElect/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/SkillfulCactus/OpenElect/pulls/174/commits"},"statuses":{"href":"https://api.github.com/repos/SkillfulCactus/OpenElect/statuses/8e47614a842c5425bfe60a8fc36452ecd8ebf46e"}}}}