{"action":"created","comment":{"url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments/50710327","id":50710327,"diff_hunk":"@@ -1,9 +1,119 @@\n-from django.http import HttpResponse\n+import operator\n \n+from django.shortcuts import render, render_to_response\n+from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger\n+from django.contrib.auth.decorators import login_required\n+from django.core.mail import send_mail\n+from django.views.generic import FormView\n+from django.core.urlresolvers import reverse\n \n+from modularodm import Q\n+from website.project.model import Comment\n+from website.settings import SUPPORT_EMAIL\n+\n+from .serializers import serialize_comment\n+from .forms import EmailForm\n+\n+\n+class EmailFormView(FormView):\n+\n+    form_class = EmailForm\n+    template_name = \"spam/email.html\"\n+    spam_id = None\n+    page = 1\n+\n+    def get(self, request, *args, **kwargs):\n+        spam_id = kwargs.get('spam_id', None)\n+        self.spam_id = spam_id\n+        self.page = request.GET.get('page', 1)\n+        try:\n+            spam = serialize_comment(Comment.load(spam_id))\n+        except:\n+            pass\n+        self.set_initial(spam)\n+        form = self.get_form()\n+        context = {\n+            'comment': spam,\n+            'page_number': request.GET.get('page', 1),\n+            'form': form\n+        }\n+        return render(request, self.template_name, context)\n+\n+    def post(self, request, *args, **kwargs):\n+        spam_id = kwargs.get('spam_id', None)\n+        self.spam_id = spam_id\n+        self.page = request.GET.get('page', 1)\n+        try:\n+            spam = serialize_comment(Comment.load(spam_id))\n+        except:\n+            pass\n+        self.set_initial(spam)\n+        form = self.get_form()\n+        if form.is_valid():\n+            return self.form_valid(form)\n+        else:\n+            return self.form_invalid(form)\n+\n+    def set_initial(self, spam):\n+        self.initial = {\n+            'author': spam['author'].fullname,\n+            'email': [(r, r) for r in spam['author'].emails],\n+            'subject': 'Reports of spam',\n+            'message': render(\n+                None,\n+                'spam/email_template.html',\n+                {'item': spam}\n+            ).content,\n+        }\n+\n+    def form_valid(self, form):\n+        send_mail(","path":"admin/spam/views.py","position":71,"original_position":71,"commit_id":"e0d3221cb521b3cb81f5a5c1af7a7234bc768c4f","original_commit_id":"e0d3221cb521b3cb81f5a5c1af7a7234bc768c4f","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":"What SMTP server is used to send mail? What configuration is necessary to get this to work with our existing Sendgrid setup?","created_at":"2016-01-25T15:46:06Z","updated_at":"2016-01-25T15:46:06Z","html_url":"https://github.com/CenterForOpenScience/osf.io/pull/4860#discussion_r50710327","pull_request_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/4860","_links":{"self":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments/50710327"},"html":{"href":"https://github.com/CenterForOpenScience/osf.io/pull/4860#discussion_r50710327"},"pull_request":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/4860"}}},"pull_request":{"url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/4860","id":55389919,"html_url":"https://github.com/CenterForOpenScience/osf.io/pull/4860","diff_url":"https://github.com/CenterForOpenScience/osf.io/pull/4860.diff","patch_url":"https://github.com/CenterForOpenScience/osf.io/pull/4860.patch","issue_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/4860","number":4860,"state":"open","locked":false,"title":"[Feature] Admin Spam Email","user":{"login":"Ghalko","id":5169088,"avatar_url":"https://avatars.githubusercontent.com/u/5169088?v=3","gravatar_id":"","url":"https://api.github.com/users/Ghalko","html_url":"https://github.com/Ghalko","followers_url":"https://api.github.com/users/Ghalko/followers","following_url":"https://api.github.com/users/Ghalko/following{/other_user}","gists_url":"https://api.github.com/users/Ghalko/gists{/gist_id}","starred_url":"https://api.github.com/users/Ghalko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ghalko/subscriptions","organizations_url":"https://api.github.com/users/Ghalko/orgs","repos_url":"https://api.github.com/users/Ghalko/repos","events_url":"https://api.github.com/users/Ghalko/events{/privacy}","received_events_url":"https://api.github.com/users/Ghalko/received_events","type":"User","site_admin":false},"body":"Originally #4733 \r\n\r\nStatus: WIP","created_at":"2016-01-07T21:02:35Z","updated_at":"2016-01-25T15:46:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"170fd8603bc35e11803618e71239bc7f3e2e3f1b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/4860/commits","review_comments_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/4860/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/4860/comments","statuses_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/statuses/e0d3221cb521b3cb81f5a5c1af7a7234bc768c4f","head":{"label":"Ghalko:feature/admin_spam_email","ref":"feature/admin_spam_email","sha":"e0d3221cb521b3cb81f5a5c1af7a7234bc768c4f","user":{"login":"Ghalko","id":5169088,"avatar_url":"https://avatars.githubusercontent.com/u/5169088?v=3","gravatar_id":"","url":"https://api.github.com/users/Ghalko","html_url":"https://github.com/Ghalko","followers_url":"https://api.github.com/users/Ghalko/followers","following_url":"https://api.github.com/users/Ghalko/following{/other_user}","gists_url":"https://api.github.com/users/Ghalko/gists{/gist_id}","starred_url":"https://api.github.com/users/Ghalko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ghalko/subscriptions","organizations_url":"https://api.github.com/users/Ghalko/orgs","repos_url":"https://api.github.com/users/Ghalko/repos","events_url":"https://api.github.com/users/Ghalko/events{/privacy}","received_events_url":"https://api.github.com/users/Ghalko/received_events","type":"User","site_admin":false},"repo":{"id":31034068,"name":"osf.io","full_name":"Ghalko/osf.io","owner":{"login":"Ghalko","id":5169088,"avatar_url":"https://avatars.githubusercontent.com/u/5169088?v=3","gravatar_id":"","url":"https://api.github.com/users/Ghalko","html_url":"https://github.com/Ghalko","followers_url":"https://api.github.com/users/Ghalko/followers","following_url":"https://api.github.com/users/Ghalko/following{/other_user}","gists_url":"https://api.github.com/users/Ghalko/gists{/gist_id}","starred_url":"https://api.github.com/users/Ghalko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ghalko/subscriptions","organizations_url":"https://api.github.com/users/Ghalko/orgs","repos_url":"https://api.github.com/users/Ghalko/repos","events_url":"https://api.github.com/users/Ghalko/events{/privacy}","received_events_url":"https://api.github.com/users/Ghalko/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Ghalko/osf.io","description":"Facilitating Open Science","fork":true,"url":"https://api.github.com/repos/Ghalko/osf.io","forks_url":"https://api.github.com/repos/Ghalko/osf.io/forks","keys_url":"https://api.github.com/repos/Ghalko/osf.io/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Ghalko/osf.io/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Ghalko/osf.io/teams","hooks_url":"https://api.github.com/repos/Ghalko/osf.io/hooks","issue_events_url":"https://api.github.com/repos/Ghalko/osf.io/issues/events{/number}","events_url":"https://api.github.com/repos/Ghalko/osf.io/events","assignees_url":"https://api.github.com/repos/Ghalko/osf.io/assignees{/user}","branches_url":"https://api.github.com/repos/Ghalko/osf.io/branches{/branch}","tags_url":"https://api.github.com/repos/Ghalko/osf.io/tags","blobs_url":"https://api.github.com/repos/Ghalko/osf.io/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Ghalko/osf.io/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Ghalko/osf.io/git/refs{/sha}","trees_url":"https://api.github.com/repos/Ghalko/osf.io/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Ghalko/osf.io/statuses/{sha}","languages_url":"https://api.github.com/repos/Ghalko/osf.io/languages","stargazers_url":"https://api.github.com/repos/Ghalko/osf.io/stargazers","contributors_url":"https://api.github.com/repos/Ghalko/osf.io/contributors","subscribers_url":"https://api.github.com/repos/Ghalko/osf.io/subscribers","subscription_url":"https://api.github.com/repos/Ghalko/osf.io/subscription","commits_url":"https://api.github.com/repos/Ghalko/osf.io/commits{/sha}","git_commits_url":"https://api.github.com/repos/Ghalko/osf.io/git/commits{/sha}","comments_url":"https://api.github.com/repos/Ghalko/osf.io/comments{/number}","issue_comment_url":"https://api.github.com/repos/Ghalko/osf.io/issues/comments{/number}","contents_url":"https://api.github.com/repos/Ghalko/osf.io/contents/{+path}","compare_url":"https://api.github.com/repos/Ghalko/osf.io/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Ghalko/osf.io/merges","archive_url":"https://api.github.com/repos/Ghalko/osf.io/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Ghalko/osf.io/downloads","issues_url":"https://api.github.com/repos/Ghalko/osf.io/issues{/number}","pulls_url":"https://api.github.com/repos/Ghalko/osf.io/pulls{/number}","milestones_url":"https://api.github.com/repos/Ghalko/osf.io/milestones{/number}","notifications_url":"https://api.github.com/repos/Ghalko/osf.io/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Ghalko/osf.io/labels{/name}","releases_url":"https://api.github.com/repos/Ghalko/osf.io/releases{/id}","deployments_url":"https://api.github.com/repos/Ghalko/osf.io/deployments","created_at":"2015-02-19T20:02:48Z","updated_at":"2015-03-30T13:32:39Z","pushed_at":"2016-01-25T15:41:21Z","git_url":"git://github.com/Ghalko/osf.io.git","ssh_url":"git@github.com:Ghalko/osf.io.git","clone_url":"https://github.com/Ghalko/osf.io.git","svn_url":"https://github.com/Ghalko/osf.io","homepage":"http://osf.io","size":118285,"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":"3d3d2c5cd29762de4937ed0f95f8e75d5cf14965","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-01-25T09:06:19Z","pushed_at":"2016-01-25T15:41:22Z","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":264182,"stargazers_count":180,"watchers_count":180,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":143,"mirror_url":null,"open_issues_count":310,"forks":143,"open_issues":310,"watchers":180,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/4860"},"html":{"href":"https://github.com/CenterForOpenScience/osf.io/pull/4860"},"issue":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/4860"},"comments":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/4860/comments"},"review_comments":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/4860/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/4860/commits"},"statuses":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/statuses/e0d3221cb521b3cb81f5a5c1af7a7234bc768c4f"}}}}