{"action":"created","comment":{"url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments/66640778","id":66640778,"diff_hunk":"@@ -1411,6 +1411,35 @@ def set_node_license(self, license_id, year, copyright_holders, auth, save=False\n         if save:\n             self.save()\n \n+    def subscribe_user_to_notifications(self, user):\n+        \"\"\" Update the notification settings for the creator or contributors\n+\n+        :param user: User to subscribe to notifications\n+        \"\"\"\n+        from website.notifications.utils import to_subscription_key\n+        from website.notifications.utils import get_global_notification_type\n+        from website.notifications.model import NotificationSubscription\n+        from website.notifications.constants import NODE_SUBSCRIPTIONS_AVAILABLE as events\n+\n+        notification_type = 'email_transactional'\n+        target_id = self._id\n+\n+        if user.is_registered:\n+            for event in events:\n+                event_id = to_subscription_key(target_id, event)\n+                global_event_id = to_subscription_key(user._id, 'global_' + event)\n+                global_subscription = NotificationSubscription.load(global_event_id)\n+\n+                subscription = NotificationSubscription.load(event_id)\n+                if not subscription:\n+                    subscription = NotificationSubscription(_id=event_id, owner=self, event_name=event)\n+                if global_subscription:\n+                    global_notification_type = get_global_notification_type(global_subscription, user)\n+                    subscription.add_user_to_subscription(user, global_notification_type)","path":"website/project/model.py","position":28,"original_position":28,"commit_id":"6e449d62a128163a6e9519a5d51ca2ed28ccf503","original_commit_id":"6e449d62a128163a6e9519a5d51ca2ed28ccf503","user":{"login":"sloria","id":2379650,"avatar_url":"https://avatars.githubusercontent.com/u/2379650?v=3","gravatar_id":"","url":"https://api.github.com/users/sloria","html_url":"https://github.com/sloria","followers_url":"https://api.github.com/users/sloria/followers","following_url":"https://api.github.com/users/sloria/following{/other_user}","gists_url":"https://api.github.com/users/sloria/gists{/gist_id}","starred_url":"https://api.github.com/users/sloria/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sloria/subscriptions","organizations_url":"https://api.github.com/users/sloria/orgs","repos_url":"https://api.github.com/users/sloria/repos","events_url":"https://api.github.com/users/sloria/events{/privacy}","received_events_url":"https://api.github.com/users/sloria/received_events","type":"User","site_admin":false},"body":"...unless `add_user_to_subscription` is responsible for handling `none`, which on a quick glance, it does.","created_at":"2016-06-10T16:16:49Z","updated_at":"2016-06-10T16:16:49Z","html_url":"https://github.com/CenterForOpenScience/osf.io/pull/5452#discussion_r66640778","pull_request_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/5452","_links":{"self":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments/66640778"},"html":{"href":"https://github.com/CenterForOpenScience/osf.io/pull/5452#discussion_r66640778"},"pull_request":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/5452"}}},"pull_request":{"url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/5452","id":66064384,"html_url":"https://github.com/CenterForOpenScience/osf.io/pull/5452","diff_url":"https://github.com/CenterForOpenScience/osf.io/pull/5452.diff","patch_url":"https://github.com/CenterForOpenScience/osf.io/pull/5452.patch","issue_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/5452","number":5452,"state":"open","locked":false,"title":"[feature] allow user to select global notification settings [OSF-5748]","user":{"login":"leb2dg","id":7131985,"avatar_url":"https://avatars.githubusercontent.com/u/7131985?v=3","gravatar_id":"","url":"https://api.github.com/users/leb2dg","html_url":"https://github.com/leb2dg","followers_url":"https://api.github.com/users/leb2dg/followers","following_url":"https://api.github.com/users/leb2dg/following{/other_user}","gists_url":"https://api.github.com/users/leb2dg/gists{/gist_id}","starred_url":"https://api.github.com/users/leb2dg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leb2dg/subscriptions","organizations_url":"https://api.github.com/users/leb2dg/orgs","repos_url":"https://api.github.com/users/leb2dg/repos","events_url":"https://api.github.com/users/leb2dg/events{/privacy}","received_events_url":"https://api.github.com/users/leb2dg/received_events","type":"User","site_admin":false},"body":"Note: this PR replaces PR #5377 and is piggy backing off of #5733\r\n\r\n## Purpose\r\n* New Projects get default notifications set as instantly\r\n* Global project notification settings on project page\r\n\r\n![screen shot 2016-06-07 at 12 17 11 pm](https://cloud.githubusercontent.com/assets/7131985/15865733/e10b6db0-2ca9-11e6-8d16-6e365615e86c.png)\r\n![screen shot 2016-06-07 at 12 17 21 pm](https://cloud.githubusercontent.com/assets/7131985/15865732/e10a6c1c-2ca9-11e6-95c9-85fcd626bca4.png)\r\n![screen shot 2016-06-07 at 12 17 27 pm](https://cloud.githubusercontent.com/assets/7131985/15865731/e1086aca-2ca9-11e6-9522-debf89dc8e76.png)\r\n\r\n## Changes\r\nSummary across the three PRs this one incorporates:\r\n\r\n* Add method that subscribes a user to notifications\r\n* Call that method with signals when a node is first saved with the nodes' creator\r\n* Also call that method when a contributor is added with that contributor\r\n* Add a setting that decides if a notification subscription should be automatically created (by default yes)\r\n* Adjust that setting to False in a special case for NotificationSubscription related tests that don't create the subscriptions by default\r\n* Disable automatic subscriptions on tests that benefit from creating them manually\r\n* Alter text on contributor added, invite, forward invite, and public project emails to explain notifications and link to profile settings to update them\r\n* add global subscription types for comments added and files updated to `USER_SUBSCRIPTIONS_AVAILABLE` in `subscribe_user_to_notifications` check for global settings before defaulting to `email_transactional`\r\n* Update settings heading and add tooltip explaining global preferences settings\r\n\r\n## Side effects\r\n* only impacts new project settings\r\n\r\n\r\n## Ticket\r\nhttps://openscience.atlassian.net/browse/OSF-5748\r\n","created_at":"2016-04-11T21:20:01Z","updated_at":"2016-06-10T16:16:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c9d3607553a18ef35559abc85a63a96989b0ece1","assignee":null,"milestone":{"url":"https://api.github.com/repos/CenterForOpenScience/osf.io/milestones/79","html_url":"https://github.com/CenterForOpenScience/osf.io/milestones/0.77.0","labels_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/milestones/79/labels","id":1816942,"number":79,"title":"0.77.0","description":"","creator":{"login":"sloria","id":2379650,"avatar_url":"https://avatars.githubusercontent.com/u/2379650?v=3","gravatar_id":"","url":"https://api.github.com/users/sloria","html_url":"https://github.com/sloria","followers_url":"https://api.github.com/users/sloria/followers","following_url":"https://api.github.com/users/sloria/following{/other_user}","gists_url":"https://api.github.com/users/sloria/gists{/gist_id}","starred_url":"https://api.github.com/users/sloria/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sloria/subscriptions","organizations_url":"https://api.github.com/users/sloria/orgs","repos_url":"https://api.github.com/users/sloria/repos","events_url":"https://api.github.com/users/sloria/events{/privacy}","received_events_url":"https://api.github.com/users/sloria/received_events","type":"User","site_admin":false},"open_issues":4,"closed_issues":3,"state":"open","created_at":"2016-06-09T03:01:24Z","updated_at":"2016-06-10T14:54:27Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/5452/commits","review_comments_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/5452/comments","review_comment_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/5452/comments","statuses_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/statuses/6e449d62a128163a6e9519a5d51ca2ed28ccf503","head":{"label":"leb2dg:feature/global-notification-settings","ref":"feature/global-notification-settings","sha":"6e449d62a128163a6e9519a5d51ca2ed28ccf503","user":{"login":"leb2dg","id":7131985,"avatar_url":"https://avatars.githubusercontent.com/u/7131985?v=3","gravatar_id":"","url":"https://api.github.com/users/leb2dg","html_url":"https://github.com/leb2dg","followers_url":"https://api.github.com/users/leb2dg/followers","following_url":"https://api.github.com/users/leb2dg/following{/other_user}","gists_url":"https://api.github.com/users/leb2dg/gists{/gist_id}","starred_url":"https://api.github.com/users/leb2dg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leb2dg/subscriptions","organizations_url":"https://api.github.com/users/leb2dg/orgs","repos_url":"https://api.github.com/users/leb2dg/repos","events_url":"https://api.github.com/users/leb2dg/events{/privacy}","received_events_url":"https://api.github.com/users/leb2dg/received_events","type":"User","site_admin":false},"repo":{"id":36022297,"name":"osf.io","full_name":"leb2dg/osf.io","owner":{"login":"leb2dg","id":7131985,"avatar_url":"https://avatars.githubusercontent.com/u/7131985?v=3","gravatar_id":"","url":"https://api.github.com/users/leb2dg","html_url":"https://github.com/leb2dg","followers_url":"https://api.github.com/users/leb2dg/followers","following_url":"https://api.github.com/users/leb2dg/following{/other_user}","gists_url":"https://api.github.com/users/leb2dg/gists{/gist_id}","starred_url":"https://api.github.com/users/leb2dg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leb2dg/subscriptions","organizations_url":"https://api.github.com/users/leb2dg/orgs","repos_url":"https://api.github.com/users/leb2dg/repos","events_url":"https://api.github.com/users/leb2dg/events{/privacy}","received_events_url":"https://api.github.com/users/leb2dg/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/leb2dg/osf.io","description":"Facilitating Open Science","fork":true,"url":"https://api.github.com/repos/leb2dg/osf.io","forks_url":"https://api.github.com/repos/leb2dg/osf.io/forks","keys_url":"https://api.github.com/repos/leb2dg/osf.io/keys{/key_id}","collaborators_url":"https://api.github.com/repos/leb2dg/osf.io/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/leb2dg/osf.io/teams","hooks_url":"https://api.github.com/repos/leb2dg/osf.io/hooks","issue_events_url":"https://api.github.com/repos/leb2dg/osf.io/issues/events{/number}","events_url":"https://api.github.com/repos/leb2dg/osf.io/events","assignees_url":"https://api.github.com/repos/leb2dg/osf.io/assignees{/user}","branches_url":"https://api.github.com/repos/leb2dg/osf.io/branches{/branch}","tags_url":"https://api.github.com/repos/leb2dg/osf.io/tags","blobs_url":"https://api.github.com/repos/leb2dg/osf.io/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/leb2dg/osf.io/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/leb2dg/osf.io/git/refs{/sha}","trees_url":"https://api.github.com/repos/leb2dg/osf.io/git/trees{/sha}","statuses_url":"https://api.github.com/repos/leb2dg/osf.io/statuses/{sha}","languages_url":"https://api.github.com/repos/leb2dg/osf.io/languages","stargazers_url":"https://api.github.com/repos/leb2dg/osf.io/stargazers","contributors_url":"https://api.github.com/repos/leb2dg/osf.io/contributors","subscribers_url":"https://api.github.com/repos/leb2dg/osf.io/subscribers","subscription_url":"https://api.github.com/repos/leb2dg/osf.io/subscription","commits_url":"https://api.github.com/repos/leb2dg/osf.io/commits{/sha}","git_commits_url":"https://api.github.com/repos/leb2dg/osf.io/git/commits{/sha}","comments_url":"https://api.github.com/repos/leb2dg/osf.io/comments{/number}","issue_comment_url":"https://api.github.com/repos/leb2dg/osf.io/issues/comments{/number}","contents_url":"https://api.github.com/repos/leb2dg/osf.io/contents/{+path}","compare_url":"https://api.github.com/repos/leb2dg/osf.io/compare/{base}...{head}","merges_url":"https://api.github.com/repos/leb2dg/osf.io/merges","archive_url":"https://api.github.com/repos/leb2dg/osf.io/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/leb2dg/osf.io/downloads","issues_url":"https://api.github.com/repos/leb2dg/osf.io/issues{/number}","pulls_url":"https://api.github.com/repos/leb2dg/osf.io/pulls{/number}","milestones_url":"https://api.github.com/repos/leb2dg/osf.io/milestones{/number}","notifications_url":"https://api.github.com/repos/leb2dg/osf.io/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/leb2dg/osf.io/labels{/name}","releases_url":"https://api.github.com/repos/leb2dg/osf.io/releases{/id}","deployments_url":"https://api.github.com/repos/leb2dg/osf.io/deployments","created_at":"2015-05-21T15:51:35Z","updated_at":"2016-04-05T21:45:08Z","pushed_at":"2016-06-10T14:25:50Z","git_url":"git://github.com/leb2dg/osf.io.git","ssh_url":"git@github.com:leb2dg/osf.io.git","clone_url":"https://github.com/leb2dg/osf.io.git","svn_url":"https://github.com/leb2dg/osf.io","homepage":"http://osf.io","size":133423,"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":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"develop"}},"base":{"label":"CenterForOpenScience:develop","ref":"develop","sha":"17ea847f2f4cca2d1a88f3b7b524bc219a01ed8a","user":{"login":"CenterForOpenScience","id":3344584,"avatar_url":"https://avatars.githubusercontent.com/u/3344584?v=3","gravatar_id":"","url":"https://api.github.com/users/CenterForOpenScience","html_url":"https://github.com/CenterForOpenScience","followers_url":"https://api.github.com/users/CenterForOpenScience/followers","following_url":"https://api.github.com/users/CenterForOpenScience/following{/other_user}","gists_url":"https://api.github.com/users/CenterForOpenScience/gists{/gist_id}","starred_url":"https://api.github.com/users/CenterForOpenScience/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CenterForOpenScience/subscriptions","organizations_url":"https://api.github.com/users/CenterForOpenScience/orgs","repos_url":"https://api.github.com/users/CenterForOpenScience/repos","events_url":"https://api.github.com/users/CenterForOpenScience/events{/privacy}","received_events_url":"https://api.github.com/users/CenterForOpenScience/received_events","type":"Organization","site_admin":false},"repo":{"id":10199599,"name":"osf.io","full_name":"CenterForOpenScience/osf.io","owner":{"login":"CenterForOpenScience","id":3344584,"avatar_url":"https://avatars.githubusercontent.com/u/3344584?v=3","gravatar_id":"","url":"https://api.github.com/users/CenterForOpenScience","html_url":"https://github.com/CenterForOpenScience","followers_url":"https://api.github.com/users/CenterForOpenScience/followers","following_url":"https://api.github.com/users/CenterForOpenScience/following{/other_user}","gists_url":"https://api.github.com/users/CenterForOpenScience/gists{/gist_id}","starred_url":"https://api.github.com/users/CenterForOpenScience/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CenterForOpenScience/subscriptions","organizations_url":"https://api.github.com/users/CenterForOpenScience/orgs","repos_url":"https://api.github.com/users/CenterForOpenScience/repos","events_url":"https://api.github.com/users/CenterForOpenScience/events{/privacy}","received_events_url":"https://api.github.com/users/CenterForOpenScience/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CenterForOpenScience/osf.io","description":"Facilitating Open Science","fork":false,"url":"https://api.github.com/repos/CenterForOpenScience/osf.io","forks_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/forks","keys_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/teams","hooks_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/hooks","issue_events_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/events{/number}","events_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/events","assignees_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/assignees{/user}","branches_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/branches{/branch}","tags_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/tags","blobs_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/git/refs{/sha}","trees_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/statuses/{sha}","languages_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/languages","stargazers_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/stargazers","contributors_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/contributors","subscribers_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/subscribers","subscription_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/subscription","commits_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/commits{/sha}","git_commits_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/git/commits{/sha}","comments_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/comments{/number}","issue_comment_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/comments{/number}","contents_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/contents/{+path}","compare_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/merges","archive_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/downloads","issues_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues{/number}","pulls_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls{/number}","milestones_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/milestones{/number}","notifications_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/labels{/name}","releases_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/releases{/id}","deployments_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/deployments","created_at":"2013-05-21T15:53:37Z","updated_at":"2016-06-08T14:28:38Z","pushed_at":"2016-06-10T16:11:35Z","git_url":"git://github.com/CenterForOpenScience/osf.io.git","ssh_url":"git@github.com:CenterForOpenScience/osf.io.git","clone_url":"https://github.com/CenterForOpenScience/osf.io.git","svn_url":"https://github.com/CenterForOpenScience/osf.io","homepage":"http://osf.io","size":282701,"stargazers_count":223,"watchers_count":223,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":187,"mirror_url":null,"open_issues_count":227,"forks":187,"open_issues":227,"watchers":223,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/5452"},"html":{"href":"https://github.com/CenterForOpenScience/osf.io/pull/5452"},"issue":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/5452"},"comments":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/5452/comments"},"review_comments":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/5452/comments"},"review_comment":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/5452/commits"},"statuses":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/statuses/6e449d62a128163a6e9519a5d51ca2ed28ccf503"}}}}
{"actor":{"display_login":"sloria"}}