{"action":"created","comment":{"url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments/30813349","id":30813349,"diff_hunk":"@@ -0,0 +1,64 @@\n+\"\"\"Script for sending OSF emails to all users who contribute to registrations.\"\"\"\n+\n+import datetime\n+import logging\n+\n+from modularodm import Q\n+\n+from website import models\n+from website.app import init_app\n+from website.mails import Mail, send_mail\n+\n+from scripts import utils as script_utils\n+\n+\n+logger = logging.getLogger(__name__)\n+logging.basicConfig(level=logging.INFO)\n+\n+MESSAGE_NAME = 'retraction_and_embargo_addition'\n+MAILER = Mail(\n+    'email_contributors_of_registrations',\n+    'Important Update to Registrations on OSF'\n+)\n+\n+\n+def send_retraction_and_embargo_addition_message(contrib, label, mail, dry_run=True):\n+    if label in contrib.security_messages:\n+        return\n+    if not dry_run:\n+        send_mail(contrib.username, mail, user=contrib)\n+        contrib.security_messages[MESSAGE_NAME] = datetime.datetime.utcnow()\n+        contrib.save()\n+\n+\n+def get_registration_contributors():\n+    \"\"\"Returns set of users that contribute to registrations.\"\"\"\n+    registrations = models.Node.find(Q('is_registration', 'eq', True))\n+    contributors = []\n+\n+    def has_received_message(contrib):\n+        query = (Q('_id', 'eq', contrib._id) & Q('security_messages.{0}'.format(MESSAGE_NAME), 'exists', False))\n+        return False if len(models.User.find(query)) > 0 else True\n+\n+    for node in registrations:\n+        contributors.extend([contrib for contrib in node.contributors if contrib not in contributors and not has_received_message(contrib)])\n+","path":"scripts/email_registration_contributors.py","position":45,"original_position":45,"commit_id":"19b4dda8880ac7d605a53390242c3753ec846970","original_commit_id":"19b4dda8880ac7d605a53390242c3753ec846970","user":{"login":"HarryRybacki","id":2614670,"avatar_url":"https://avatars.githubusercontent.com/u/2614670?v=3","gravatar_id":"","url":"https://api.github.com/users/HarryRybacki","html_url":"https://github.com/HarryRybacki","followers_url":"https://api.github.com/users/HarryRybacki/followers","following_url":"https://api.github.com/users/HarryRybacki/following{/other_user}","gists_url":"https://api.github.com/users/HarryRybacki/gists{/gist_id}","starred_url":"https://api.github.com/users/HarryRybacki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HarryRybacki/subscriptions","organizations_url":"https://api.github.com/users/HarryRybacki/orgs","repos_url":"https://api.github.com/users/HarryRybacki/repos","events_url":"https://api.github.com/users/HarryRybacki/events{/privacy}","received_events_url":"https://api.github.com/users/HarryRybacki/received_events","type":"User","site_admin":false},"body":"done","created_at":"2015-05-21T15:25:08Z","updated_at":"2015-05-21T15:25:08Z","html_url":"https://github.com/CenterForOpenScience/osf.io/pull/2740#discussion_r30813349","pull_request_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/2740","_links":{"self":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments/30813349"},"html":{"href":"https://github.com/CenterForOpenScience/osf.io/pull/2740#discussion_r30813349"},"pull_request":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/2740"}}},"pull_request":{"url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/2740","id":35591830,"html_url":"https://github.com/CenterForOpenScience/osf.io/pull/2740","diff_url":"https://github.com/CenterForOpenScience/osf.io/pull/2740.diff","patch_url":"https://github.com/CenterForOpenScience/osf.io/pull/2740.patch","issue_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/2740","number":2740,"state":"open","locked":false,"title":"[hotfix][hold] alert users of pending registration changes","user":{"login":"HarryRybacki","id":2614670,"avatar_url":"https://avatars.githubusercontent.com/u/2614670?v=3","gravatar_id":"","url":"https://api.github.com/users/HarryRybacki","html_url":"https://github.com/HarryRybacki","followers_url":"https://api.github.com/users/HarryRybacki/followers","following_url":"https://api.github.com/users/HarryRybacki/following{/other_user}","gists_url":"https://api.github.com/users/HarryRybacki/gists{/gist_id}","starred_url":"https://api.github.com/users/HarryRybacki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HarryRybacki/subscriptions","organizations_url":"https://api.github.com/users/HarryRybacki/orgs","repos_url":"https://api.github.com/users/HarryRybacki/repos","events_url":"https://api.github.com/users/HarryRybacki/events{/privacy}","received_events_url":"https://api.github.com/users/HarryRybacki/received_events","type":"User","site_admin":false},"body":"## Purpose\r\nWith registration retractions and embargoes going into production on the 29th of this month, users need notification regarding the pending behavior changes of registrations.\r\n\r\n## Changes\r\nUsers that contribute to registrations will be emailed the template (needs revision @bnosek @saradbowman) regarding the future changes.\r\n\r\nUsers that wish to create a new registration will be warned of upcoming changes:\r\n![screen shot 2015-05-18 at 8 44 01 am](https://cloud.githubusercontent.com/assets/2614670/7681039/4221f7d6-fd3a-11e4-9ceb-09d31240b65f.png)\r\n\r\nUsers that wish to make existing registrations public will also be warned of upcoming changes:\r\n![screen shot 2015-05-18 at 8 45 09 am](https://cloud.githubusercontent.com/assets/2614670/7681041/4874ddf6-fd3a-11e4-9604-28224dfc02d4.png)\r\n\r\nAll contributors to registrations will receive an email akin to what Mr. Pew would see below:\r\n![screen shot 2015-05-18 at 9 31 11 am](https://cloud.githubusercontent.com/assets/2614670/7681777/e43daa5a-fd40-11e4-947d-68039ed625c0.png)\r\n\r\n## Side Effects\r\nNone\r\n\r\n## Notes\r\nThe action labels will need to revised or removed once retractions and embargoes are in production.\r\n\r\n@sloria @JeffSpies -- Retractions/Embargoes are set to get merged into production on the 29th. This hotfix and respective email should be merged and issued out as close to tomorrow morning as possible. Changes are as small as I could make them to help facilitate Steve's review.","created_at":"2015-05-17T19:22:27Z","updated_at":"2015-05-21T15:25:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9bd75a4c61b474552c293970750c02f28521394f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/2740/commits","review_comments_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/2740/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/2740/comments","statuses_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/statuses/19b4dda8880ac7d605a53390242c3753ec846970","head":{"label":"HarryRybacki:hotfix/alert_users_of_pending_registration_changes","ref":"hotfix/alert_users_of_pending_registration_changes","sha":"19b4dda8880ac7d605a53390242c3753ec846970","user":{"login":"HarryRybacki","id":2614670,"avatar_url":"https://avatars.githubusercontent.com/u/2614670?v=3","gravatar_id":"","url":"https://api.github.com/users/HarryRybacki","html_url":"https://github.com/HarryRybacki","followers_url":"https://api.github.com/users/HarryRybacki/followers","following_url":"https://api.github.com/users/HarryRybacki/following{/other_user}","gists_url":"https://api.github.com/users/HarryRybacki/gists{/gist_id}","starred_url":"https://api.github.com/users/HarryRybacki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HarryRybacki/subscriptions","organizations_url":"https://api.github.com/users/HarryRybacki/orgs","repos_url":"https://api.github.com/users/HarryRybacki/repos","events_url":"https://api.github.com/users/HarryRybacki/events{/privacy}","received_events_url":"https://api.github.com/users/HarryRybacki/received_events","type":"User","site_admin":false},"repo":{"id":30415497,"name":"osf.io","full_name":"HarryRybacki/osf.io","owner":{"login":"HarryRybacki","id":2614670,"avatar_url":"https://avatars.githubusercontent.com/u/2614670?v=3","gravatar_id":"","url":"https://api.github.com/users/HarryRybacki","html_url":"https://github.com/HarryRybacki","followers_url":"https://api.github.com/users/HarryRybacki/followers","following_url":"https://api.github.com/users/HarryRybacki/following{/other_user}","gists_url":"https://api.github.com/users/HarryRybacki/gists{/gist_id}","starred_url":"https://api.github.com/users/HarryRybacki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HarryRybacki/subscriptions","organizations_url":"https://api.github.com/users/HarryRybacki/orgs","repos_url":"https://api.github.com/users/HarryRybacki/repos","events_url":"https://api.github.com/users/HarryRybacki/events{/privacy}","received_events_url":"https://api.github.com/users/HarryRybacki/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/HarryRybacki/osf.io","description":"Facilitating Open Science","fork":true,"url":"https://api.github.com/repos/HarryRybacki/osf.io","forks_url":"https://api.github.com/repos/HarryRybacki/osf.io/forks","keys_url":"https://api.github.com/repos/HarryRybacki/osf.io/keys{/key_id}","collaborators_url":"https://api.github.com/repos/HarryRybacki/osf.io/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/HarryRybacki/osf.io/teams","hooks_url":"https://api.github.com/repos/HarryRybacki/osf.io/hooks","issue_events_url":"https://api.github.com/repos/HarryRybacki/osf.io/issues/events{/number}","events_url":"https://api.github.com/repos/HarryRybacki/osf.io/events","assignees_url":"https://api.github.com/repos/HarryRybacki/osf.io/assignees{/user}","branches_url":"https://api.github.com/repos/HarryRybacki/osf.io/branches{/branch}","tags_url":"https://api.github.com/repos/HarryRybacki/osf.io/tags","blobs_url":"https://api.github.com/repos/HarryRybacki/osf.io/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/HarryRybacki/osf.io/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/HarryRybacki/osf.io/git/refs{/sha}","trees_url":"https://api.github.com/repos/HarryRybacki/osf.io/git/trees{/sha}","statuses_url":"https://api.github.com/repos/HarryRybacki/osf.io/statuses/{sha}","languages_url":"https://api.github.com/repos/HarryRybacki/osf.io/languages","stargazers_url":"https://api.github.com/repos/HarryRybacki/osf.io/stargazers","contributors_url":"https://api.github.com/repos/HarryRybacki/osf.io/contributors","subscribers_url":"https://api.github.com/repos/HarryRybacki/osf.io/subscribers","subscription_url":"https://api.github.com/repos/HarryRybacki/osf.io/subscription","commits_url":"https://api.github.com/repos/HarryRybacki/osf.io/commits{/sha}","git_commits_url":"https://api.github.com/repos/HarryRybacki/osf.io/git/commits{/sha}","comments_url":"https://api.github.com/repos/HarryRybacki/osf.io/comments{/number}","issue_comment_url":"https://api.github.com/repos/HarryRybacki/osf.io/issues/comments{/number}","contents_url":"https://api.github.com/repos/HarryRybacki/osf.io/contents/{+path}","compare_url":"https://api.github.com/repos/HarryRybacki/osf.io/compare/{base}...{head}","merges_url":"https://api.github.com/repos/HarryRybacki/osf.io/merges","archive_url":"https://api.github.com/repos/HarryRybacki/osf.io/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/HarryRybacki/osf.io/downloads","issues_url":"https://api.github.com/repos/HarryRybacki/osf.io/issues{/number}","pulls_url":"https://api.github.com/repos/HarryRybacki/osf.io/pulls{/number}","milestones_url":"https://api.github.com/repos/HarryRybacki/osf.io/milestones{/number}","notifications_url":"https://api.github.com/repos/HarryRybacki/osf.io/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/HarryRybacki/osf.io/labels{/name}","releases_url":"https://api.github.com/repos/HarryRybacki/osf.io/releases{/id}","created_at":"2015-02-06T14:18:39Z","updated_at":"2015-04-20T13:52:21Z","pushed_at":"2015-05-20T19:44:40Z","git_url":"git://github.com/HarryRybacki/osf.io.git","ssh_url":"git@github.com:HarryRybacki/osf.io.git","clone_url":"https://github.com/HarryRybacki/osf.io.git","svn_url":"https://github.com/HarryRybacki/osf.io","homepage":"http://osf.io","size":87598,"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:master","ref":"master","sha":"2761d15b956333a20272c0c80a3ef1ebb6b725ae","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}","created_at":"2013-05-21T15:53:37Z","updated_at":"2015-05-20T22:52:47Z","pushed_at":"2015-05-21T15:18:34Z","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":209665,"stargazers_count":103,"watchers_count":103,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":87,"mirror_url":null,"open_issues_count":407,"forks":87,"open_issues":407,"watchers":103,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/2740"},"html":{"href":"https://github.com/CenterForOpenScience/osf.io/pull/2740"},"issue":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/2740"},"comments":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/2740/comments"},"review_comments":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/2740/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/2740/commits"},"statuses":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/statuses/19b4dda8880ac7d605a53390242c3753ec846970"}}}}