{"action":"created","comment":{"url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments/45872079","id":45872079,"diff_hunk":"@@ -0,0 +1,46 @@\n+import httplib as http\n+\n+from framework.exceptions import HTTPError\n+\n+from website import mails\n+\n+VALID_CAMPAIGNS = (\n+    'prereg',\n+)\n+\n+EMAIL_TEMPLATE_MAP = {\n+    'prereg': mails.CONFIRM_EMAIL_PREREG\n+}\n+\n+def email_template_for_campaign(campaign, default=None):\n+    if campaign in VALID_CAMPAIGNS:\n+        try:\n+            return EMAIL_TEMPLATE_MAP[campaign]\n+        except KeyError as e:\n+            if default:\n+                return default\n+            else:\n+                raise e\n+    return default\n+\n+def campaign_for_user(user):\n+    campaigns = [tag for tag in user.system_tags if tag in VALID_CAMPAIGNS]\n+    if campaigns:\n+        # TODO: This is a bit of a one-off to support the Prereg Challenge.\n+        # We should think more about the campaigns architecture and in\n+        # particular define the behavior if the user has more than one\n+        # campagin tag in their system_tags.\n+        return campaigns[0]\n+\n+def campaign_url_for(campaign):\n+    # Defined inside this function to ensure a request context","path":"framework/auth/campaigns.py","position":36,"original_position":36,"commit_id":"94183293b03d46e0b45ee15a9cef82e689b089c8","original_commit_id":"cfe826629846b0c7a9bf4fc6dcbf18a67e334929","user":{"login":"abought","id":2957073,"avatar_url":"https://avatars.githubusercontent.com/u/2957073?v=3","gravatar_id":"","url":"https://api.github.com/users/abought","html_url":"https://github.com/abought","followers_url":"https://api.github.com/users/abought/followers","following_url":"https://api.github.com/users/abought/following{/other_user}","gists_url":"https://api.github.com/users/abought/gists{/gist_id}","starred_url":"https://api.github.com/users/abought/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abought/subscriptions","organizations_url":"https://api.github.com/users/abought/orgs","repos_url":"https://api.github.com/users/abought/repos","events_url":"https://api.github.com/users/abought/events{/privacy}","received_events_url":"https://api.github.com/users/abought/received_events","type":"User","site_admin":false},"body":"Although this references a request context, the actual URL in question is hardcoded. Should it be?\r\n\r\n(as far as I can tell, this function is only used from within the flask application, which means that `web_url_for` should be available)","created_at":"2015-11-25T14:29:25Z","updated_at":"2015-11-25T14:29:25Z","html_url":"https://github.com/CenterForOpenScience/osf.io/pull/4632#discussion_r45872079","pull_request_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/4632","_links":{"self":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments/45872079"},"html":{"href":"https://github.com/CenterForOpenScience/osf.io/pull/4632#discussion_r45872079"},"pull_request":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/4632"}}},"pull_request":{"url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/4632","id":51105800,"html_url":"https://github.com/CenterForOpenScience/osf.io/pull/4632","diff_url":"https://github.com/CenterForOpenScience/osf.io/pull/4632.diff","patch_url":"https://github.com/CenterForOpenScience/osf.io/pull/4632.patch","issue_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/4632","number":4632,"state":"open","locked":false,"title":"[WIP] Prereg Prize","user":{"login":"samchrisinger","id":2207561,"avatar_url":"https://avatars.githubusercontent.com/u/2207561?v=3","gravatar_id":"","url":"https://api.github.com/users/samchrisinger","html_url":"https://github.com/samchrisinger","followers_url":"https://api.github.com/users/samchrisinger/followers","following_url":"https://api.github.com/users/samchrisinger/following{/other_user}","gists_url":"https://api.github.com/users/samchrisinger/gists{/gist_id}","starred_url":"https://api.github.com/users/samchrisinger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samchrisinger/subscriptions","organizations_url":"https://api.github.com/users/samchrisinger/orgs","repos_url":"https://api.github.com/users/samchrisinger/repos","events_url":"https://api.github.com/users/samchrisinger/events{/privacy}","received_events_url":"https://api.github.com/users/samchrisinger/received_events","type":"User","site_admin":false},"body":"Replacing: https://github.com/CenterForOpenScience/osf.io/pull/4602","created_at":"2015-11-18T16:20:30Z","updated_at":"2015-11-25T14:29:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"99082a819939113405d1a2c648308892a3afaef6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/4632/commits","review_comments_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/4632/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/4632/comments","statuses_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/statuses/94183293b03d46e0b45ee15a9cef82e689b089c8","head":{"label":"samchrisinger:feature/prereg/full","ref":"feature/prereg/full","sha":"94183293b03d46e0b45ee15a9cef82e689b089c8","user":{"login":"samchrisinger","id":2207561,"avatar_url":"https://avatars.githubusercontent.com/u/2207561?v=3","gravatar_id":"","url":"https://api.github.com/users/samchrisinger","html_url":"https://github.com/samchrisinger","followers_url":"https://api.github.com/users/samchrisinger/followers","following_url":"https://api.github.com/users/samchrisinger/following{/other_user}","gists_url":"https://api.github.com/users/samchrisinger/gists{/gist_id}","starred_url":"https://api.github.com/users/samchrisinger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samchrisinger/subscriptions","organizations_url":"https://api.github.com/users/samchrisinger/orgs","repos_url":"https://api.github.com/users/samchrisinger/repos","events_url":"https://api.github.com/users/samchrisinger/events{/privacy}","received_events_url":"https://api.github.com/users/samchrisinger/received_events","type":"User","site_admin":false},"repo":{"id":30772672,"name":"osf.io","full_name":"samchrisinger/osf.io","owner":{"login":"samchrisinger","id":2207561,"avatar_url":"https://avatars.githubusercontent.com/u/2207561?v=3","gravatar_id":"","url":"https://api.github.com/users/samchrisinger","html_url":"https://github.com/samchrisinger","followers_url":"https://api.github.com/users/samchrisinger/followers","following_url":"https://api.github.com/users/samchrisinger/following{/other_user}","gists_url":"https://api.github.com/users/samchrisinger/gists{/gist_id}","starred_url":"https://api.github.com/users/samchrisinger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samchrisinger/subscriptions","organizations_url":"https://api.github.com/users/samchrisinger/orgs","repos_url":"https://api.github.com/users/samchrisinger/repos","events_url":"https://api.github.com/users/samchrisinger/events{/privacy}","received_events_url":"https://api.github.com/users/samchrisinger/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/samchrisinger/osf.io","description":"Facilitating Open Science","fork":true,"url":"https://api.github.com/repos/samchrisinger/osf.io","forks_url":"https://api.github.com/repos/samchrisinger/osf.io/forks","keys_url":"https://api.github.com/repos/samchrisinger/osf.io/keys{/key_id}","collaborators_url":"https://api.github.com/repos/samchrisinger/osf.io/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/samchrisinger/osf.io/teams","hooks_url":"https://api.github.com/repos/samchrisinger/osf.io/hooks","issue_events_url":"https://api.github.com/repos/samchrisinger/osf.io/issues/events{/number}","events_url":"https://api.github.com/repos/samchrisinger/osf.io/events","assignees_url":"https://api.github.com/repos/samchrisinger/osf.io/assignees{/user}","branches_url":"https://api.github.com/repos/samchrisinger/osf.io/branches{/branch}","tags_url":"https://api.github.com/repos/samchrisinger/osf.io/tags","blobs_url":"https://api.github.com/repos/samchrisinger/osf.io/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/samchrisinger/osf.io/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/samchrisinger/osf.io/git/refs{/sha}","trees_url":"https://api.github.com/repos/samchrisinger/osf.io/git/trees{/sha}","statuses_url":"https://api.github.com/repos/samchrisinger/osf.io/statuses/{sha}","languages_url":"https://api.github.com/repos/samchrisinger/osf.io/languages","stargazers_url":"https://api.github.com/repos/samchrisinger/osf.io/stargazers","contributors_url":"https://api.github.com/repos/samchrisinger/osf.io/contributors","subscribers_url":"https://api.github.com/repos/samchrisinger/osf.io/subscribers","subscription_url":"https://api.github.com/repos/samchrisinger/osf.io/subscription","commits_url":"https://api.github.com/repos/samchrisinger/osf.io/commits{/sha}","git_commits_url":"https://api.github.com/repos/samchrisinger/osf.io/git/commits{/sha}","comments_url":"https://api.github.com/repos/samchrisinger/osf.io/comments{/number}","issue_comment_url":"https://api.github.com/repos/samchrisinger/osf.io/issues/comments{/number}","contents_url":"https://api.github.com/repos/samchrisinger/osf.io/contents/{+path}","compare_url":"https://api.github.com/repos/samchrisinger/osf.io/compare/{base}...{head}","merges_url":"https://api.github.com/repos/samchrisinger/osf.io/merges","archive_url":"https://api.github.com/repos/samchrisinger/osf.io/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/samchrisinger/osf.io/downloads","issues_url":"https://api.github.com/repos/samchrisinger/osf.io/issues{/number}","pulls_url":"https://api.github.com/repos/samchrisinger/osf.io/pulls{/number}","milestones_url":"https://api.github.com/repos/samchrisinger/osf.io/milestones{/number}","notifications_url":"https://api.github.com/repos/samchrisinger/osf.io/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/samchrisinger/osf.io/labels{/name}","releases_url":"https://api.github.com/repos/samchrisinger/osf.io/releases{/id}","created_at":"2015-02-13T19:40:14Z","updated_at":"2015-02-27T18:03:37Z","pushed_at":"2015-11-25T14:17:00Z","git_url":"git://github.com/samchrisinger/osf.io.git","ssh_url":"git@github.com:samchrisinger/osf.io.git","clone_url":"https://github.com/samchrisinger/osf.io.git","svn_url":"https://github.com/samchrisinger/osf.io","homepage":"http://osf.io","size":111138,"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":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"develop"}},"base":{"label":"CenterForOpenScience:develop","ref":"develop","sha":"1b50f20f03a18e100b9349a3d71ee98eec3f5f86","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-11-24T20:33:51Z","pushed_at":"2015-11-25T14:17:01Z","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":222542,"stargazers_count":163,"watchers_count":163,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":134,"mirror_url":null,"open_issues_count":337,"forks":134,"open_issues":337,"watchers":163,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/4632"},"html":{"href":"https://github.com/CenterForOpenScience/osf.io/pull/4632"},"issue":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/4632"},"comments":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/4632/comments"},"review_comments":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/4632/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/4632/commits"},"statuses":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/statuses/94183293b03d46e0b45ee15a9cef82e689b089c8"}}}}