{"action":"created","comment":{"url":"https://api.github.com/repos/rosedu/events/pulls/comments/28526247","id":28526247,"diff_hunk":"@@ -11,12 +13,40 @@ exports.index = function(req, res) {\n   }\n }\n \n+exports.one = function(req, res) {\n+  activityId = mongoose.Types.ObjectId.fromString(req.params.activity)\n+  Activity.findOne({'_id': activityId}).exec(gotActivity)\n+\n+  function gotActivity(err, one) {\n+      res.render('activity', {\n+        'activity': one\n+      })\n+  }\n+}\n+\n exports.add = function(req, res) {\n   var new_activity = {\n-    name:      req.body.name,\n-    description: req.body.description\n+    'name'        : req.body.name,\n+    'description' : req.body.description\n   }\n \n   new Activity(new_activity).save()\n   res.redirect('/activities')\n }\n+\n+exports.add_edition = function(req, res) {\n+  start = req.body.start_date\n+  end = req.body.end_date\n+  var new_edition = {\n+    'name'        : req.body.name,\n+    'start'       : new Date(start.substring(7,11), start.substring(3,5), start.substring(0,2)),\n+    'end'         : new Date(end.substring(7,11), end.substring(3,5), end.substring(0,2))\n+  }\n+\n+  find = {'_id': mongoose.Types.ObjectId.fromString(req.params.activity)}\n+  update = {$push: {'edition': new Edition(new_edition)}}\n+  Activity.update(find, update).exec()\n+\n+  new Edition(new_edition).save()","path":"routes/activities.js","position":47,"original_position":47,"commit_id":"5f41e1a26c732ff2a2d99598a4b9d1fe253639e8","original_commit_id":"5f41e1a26c732ff2a2d99598a4b9d1fe253639e8","user":{"login":"maria","id":1681405,"avatar_url":"https://avatars.githubusercontent.com/u/1681405?v=3","gravatar_id":"","url":"https://api.github.com/users/maria","html_url":"https://github.com/maria","followers_url":"https://api.github.com/users/maria/followers","following_url":"https://api.github.com/users/maria/following{/other_user}","gists_url":"https://api.github.com/users/maria/gists{/gist_id}","starred_url":"https://api.github.com/users/maria/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maria/subscriptions","organizations_url":"https://api.github.com/users/maria/orgs","repos_url":"https://api.github.com/users/maria/repos","events_url":"https://api.github.com/users/maria/events{/privacy}","received_events_url":"https://api.github.com/users/maria/received_events","type":"User","site_admin":false},"body":"Again, I would first save the edition and then update the activity. Also, just use one object of type `new Edition()`","created_at":"2015-04-16T16:36:06Z","updated_at":"2015-04-16T16:36:06Z","html_url":"https://github.com/rosedu/events/pull/45#discussion_r28526247","pull_request_url":"https://api.github.com/repos/rosedu/events/pulls/45","_links":{"self":{"href":"https://api.github.com/repos/rosedu/events/pulls/comments/28526247"},"html":{"href":"https://github.com/rosedu/events/pull/45#discussion_r28526247"},"pull_request":{"href":"https://api.github.com/repos/rosedu/events/pulls/45"}}},"pull_request":{"url":"https://api.github.com/repos/rosedu/events/pulls/45","id":33436665,"html_url":"https://github.com/rosedu/events/pull/45","diff_url":"https://github.com/rosedu/events/pull/45.diff","patch_url":"https://github.com/rosedu/events/pull/45.patch","issue_url":"https://api.github.com/repos/rosedu/events/issues/45","number":45,"state":"open","locked":false,"title":"Merge editions into activities","user":{"login":"mariuscoto","id":1830744,"avatar_url":"https://avatars.githubusercontent.com/u/1830744?v=3","gravatar_id":"","url":"https://api.github.com/users/mariuscoto","html_url":"https://github.com/mariuscoto","followers_url":"https://api.github.com/users/mariuscoto/followers","following_url":"https://api.github.com/users/mariuscoto/following{/other_user}","gists_url":"https://api.github.com/users/mariuscoto/gists{/gist_id}","starred_url":"https://api.github.com/users/mariuscoto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mariuscoto/subscriptions","organizations_url":"https://api.github.com/users/mariuscoto/orgs","repos_url":"https://api.github.com/users/mariuscoto/repos","events_url":"https://api.github.com/users/mariuscoto/events{/privacy}","received_events_url":"https://api.github.com/users/mariuscoto/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-04-16T10:18:04Z","updated_at":"2015-04-16T16:36:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"01ace5a5a689c236c5f0156239e6d1404ba2f43b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/rosedu/events/pulls/45/commits","review_comments_url":"https://api.github.com/repos/rosedu/events/pulls/45/comments","review_comment_url":"https://api.github.com/repos/rosedu/events/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rosedu/events/issues/45/comments","statuses_url":"https://api.github.com/repos/rosedu/events/statuses/5f41e1a26c732ff2a2d99598a4b9d1fe253639e8","head":{"label":"rosedu:39-model-database","ref":"39-model-database","sha":"5f41e1a26c732ff2a2d99598a4b9d1fe253639e8","user":{"login":"rosedu","id":1232963,"avatar_url":"https://avatars.githubusercontent.com/u/1232963?v=3","gravatar_id":"","url":"https://api.github.com/users/rosedu","html_url":"https://github.com/rosedu","followers_url":"https://api.github.com/users/rosedu/followers","following_url":"https://api.github.com/users/rosedu/following{/other_user}","gists_url":"https://api.github.com/users/rosedu/gists{/gist_id}","starred_url":"https://api.github.com/users/rosedu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rosedu/subscriptions","organizations_url":"https://api.github.com/users/rosedu/orgs","repos_url":"https://api.github.com/users/rosedu/repos","events_url":"https://api.github.com/users/rosedu/events{/privacy}","received_events_url":"https://api.github.com/users/rosedu/received_events","type":"Organization","site_admin":false},"repo":{"id":27079833,"name":"events","full_name":"rosedu/events","owner":{"login":"rosedu","id":1232963,"avatar_url":"https://avatars.githubusercontent.com/u/1232963?v=3","gravatar_id":"","url":"https://api.github.com/users/rosedu","html_url":"https://github.com/rosedu","followers_url":"https://api.github.com/users/rosedu/followers","following_url":"https://api.github.com/users/rosedu/following{/other_user}","gists_url":"https://api.github.com/users/rosedu/gists{/gist_id}","starred_url":"https://api.github.com/users/rosedu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rosedu/subscriptions","organizations_url":"https://api.github.com/users/rosedu/orgs","repos_url":"https://api.github.com/users/rosedu/repos","events_url":"https://api.github.com/users/rosedu/events{/privacy}","received_events_url":"https://api.github.com/users/rosedu/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rosedu/events","description":"","fork":false,"url":"https://api.github.com/repos/rosedu/events","forks_url":"https://api.github.com/repos/rosedu/events/forks","keys_url":"https://api.github.com/repos/rosedu/events/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rosedu/events/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rosedu/events/teams","hooks_url":"https://api.github.com/repos/rosedu/events/hooks","issue_events_url":"https://api.github.com/repos/rosedu/events/issues/events{/number}","events_url":"https://api.github.com/repos/rosedu/events/events","assignees_url":"https://api.github.com/repos/rosedu/events/assignees{/user}","branches_url":"https://api.github.com/repos/rosedu/events/branches{/branch}","tags_url":"https://api.github.com/repos/rosedu/events/tags","blobs_url":"https://api.github.com/repos/rosedu/events/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rosedu/events/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rosedu/events/git/refs{/sha}","trees_url":"https://api.github.com/repos/rosedu/events/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rosedu/events/statuses/{sha}","languages_url":"https://api.github.com/repos/rosedu/events/languages","stargazers_url":"https://api.github.com/repos/rosedu/events/stargazers","contributors_url":"https://api.github.com/repos/rosedu/events/contributors","subscribers_url":"https://api.github.com/repos/rosedu/events/subscribers","subscription_url":"https://api.github.com/repos/rosedu/events/subscription","commits_url":"https://api.github.com/repos/rosedu/events/commits{/sha}","git_commits_url":"https://api.github.com/repos/rosedu/events/git/commits{/sha}","comments_url":"https://api.github.com/repos/rosedu/events/comments{/number}","issue_comment_url":"https://api.github.com/repos/rosedu/events/issues/comments{/number}","contents_url":"https://api.github.com/repos/rosedu/events/contents/{+path}","compare_url":"https://api.github.com/repos/rosedu/events/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rosedu/events/merges","archive_url":"https://api.github.com/repos/rosedu/events/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rosedu/events/downloads","issues_url":"https://api.github.com/repos/rosedu/events/issues{/number}","pulls_url":"https://api.github.com/repos/rosedu/events/pulls{/number}","milestones_url":"https://api.github.com/repos/rosedu/events/milestones{/number}","notifications_url":"https://api.github.com/repos/rosedu/events/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rosedu/events/labels{/name}","releases_url":"https://api.github.com/repos/rosedu/events/releases{/id}","created_at":"2014-11-24T14:46:13Z","updated_at":"2015-04-16T08:46:17Z","pushed_at":"2015-04-16T10:18:05Z","git_url":"git://github.com/rosedu/events.git","ssh_url":"git@github.com:rosedu/events.git","clone_url":"https://github.com/rosedu/events.git","svn_url":"https://github.com/rosedu/events","homepage":"http://events.rosedu.org","size":2159,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":15,"forks":3,"open_issues":15,"watchers":1,"default_branch":"master"}},"base":{"label":"rosedu:master","ref":"master","sha":"fc5bbbba91069987c0755c7cebc1379aa3918551","user":{"login":"rosedu","id":1232963,"avatar_url":"https://avatars.githubusercontent.com/u/1232963?v=3","gravatar_id":"","url":"https://api.github.com/users/rosedu","html_url":"https://github.com/rosedu","followers_url":"https://api.github.com/users/rosedu/followers","following_url":"https://api.github.com/users/rosedu/following{/other_user}","gists_url":"https://api.github.com/users/rosedu/gists{/gist_id}","starred_url":"https://api.github.com/users/rosedu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rosedu/subscriptions","organizations_url":"https://api.github.com/users/rosedu/orgs","repos_url":"https://api.github.com/users/rosedu/repos","events_url":"https://api.github.com/users/rosedu/events{/privacy}","received_events_url":"https://api.github.com/users/rosedu/received_events","type":"Organization","site_admin":false},"repo":{"id":27079833,"name":"events","full_name":"rosedu/events","owner":{"login":"rosedu","id":1232963,"avatar_url":"https://avatars.githubusercontent.com/u/1232963?v=3","gravatar_id":"","url":"https://api.github.com/users/rosedu","html_url":"https://github.com/rosedu","followers_url":"https://api.github.com/users/rosedu/followers","following_url":"https://api.github.com/users/rosedu/following{/other_user}","gists_url":"https://api.github.com/users/rosedu/gists{/gist_id}","starred_url":"https://api.github.com/users/rosedu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rosedu/subscriptions","organizations_url":"https://api.github.com/users/rosedu/orgs","repos_url":"https://api.github.com/users/rosedu/repos","events_url":"https://api.github.com/users/rosedu/events{/privacy}","received_events_url":"https://api.github.com/users/rosedu/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rosedu/events","description":"","fork":false,"url":"https://api.github.com/repos/rosedu/events","forks_url":"https://api.github.com/repos/rosedu/events/forks","keys_url":"https://api.github.com/repos/rosedu/events/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rosedu/events/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rosedu/events/teams","hooks_url":"https://api.github.com/repos/rosedu/events/hooks","issue_events_url":"https://api.github.com/repos/rosedu/events/issues/events{/number}","events_url":"https://api.github.com/repos/rosedu/events/events","assignees_url":"https://api.github.com/repos/rosedu/events/assignees{/user}","branches_url":"https://api.github.com/repos/rosedu/events/branches{/branch}","tags_url":"https://api.github.com/repos/rosedu/events/tags","blobs_url":"https://api.github.com/repos/rosedu/events/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rosedu/events/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rosedu/events/git/refs{/sha}","trees_url":"https://api.github.com/repos/rosedu/events/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rosedu/events/statuses/{sha}","languages_url":"https://api.github.com/repos/rosedu/events/languages","stargazers_url":"https://api.github.com/repos/rosedu/events/stargazers","contributors_url":"https://api.github.com/repos/rosedu/events/contributors","subscribers_url":"https://api.github.com/repos/rosedu/events/subscribers","subscription_url":"https://api.github.com/repos/rosedu/events/subscription","commits_url":"https://api.github.com/repos/rosedu/events/commits{/sha}","git_commits_url":"https://api.github.com/repos/rosedu/events/git/commits{/sha}","comments_url":"https://api.github.com/repos/rosedu/events/comments{/number}","issue_comment_url":"https://api.github.com/repos/rosedu/events/issues/comments{/number}","contents_url":"https://api.github.com/repos/rosedu/events/contents/{+path}","compare_url":"https://api.github.com/repos/rosedu/events/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rosedu/events/merges","archive_url":"https://api.github.com/repos/rosedu/events/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rosedu/events/downloads","issues_url":"https://api.github.com/repos/rosedu/events/issues{/number}","pulls_url":"https://api.github.com/repos/rosedu/events/pulls{/number}","milestones_url":"https://api.github.com/repos/rosedu/events/milestones{/number}","notifications_url":"https://api.github.com/repos/rosedu/events/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rosedu/events/labels{/name}","releases_url":"https://api.github.com/repos/rosedu/events/releases{/id}","created_at":"2014-11-24T14:46:13Z","updated_at":"2015-04-16T08:46:17Z","pushed_at":"2015-04-16T10:18:05Z","git_url":"git://github.com/rosedu/events.git","ssh_url":"git@github.com:rosedu/events.git","clone_url":"https://github.com/rosedu/events.git","svn_url":"https://github.com/rosedu/events","homepage":"http://events.rosedu.org","size":2159,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":15,"forks":3,"open_issues":15,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rosedu/events/pulls/45"},"html":{"href":"https://github.com/rosedu/events/pull/45"},"issue":{"href":"https://api.github.com/repos/rosedu/events/issues/45"},"comments":{"href":"https://api.github.com/repos/rosedu/events/issues/45/comments"},"review_comments":{"href":"https://api.github.com/repos/rosedu/events/pulls/45/comments"},"review_comment":{"href":"https://api.github.com/repos/rosedu/events/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rosedu/events/pulls/45/commits"},"statuses":{"href":"https://api.github.com/repos/rosedu/events/statuses/5f41e1a26c732ff2a2d99598a4b9d1fe253639e8"}}}}