{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/kuma/pulls/comments/56237666","id":56237666,"diff_hunk":"@@ -2,21 +2,170 @@\n from pyquery import PyQuery as pq\n \n from constance.test import override_config\n+from django.contrib.admin import AdminSite\n+from django.test import RequestFactory\n import requests_mock\n from waffle.models import Flag\n \n from kuma.core.urlresolvers import reverse\n from kuma.core.utils import urlparams\n from kuma.spam.akismet import Akismet\n-from kuma.spam.constants import SPAM_SUBMISSIONS_FLAG, SPAM_URL, VERIFY_URL\n+from kuma.spam.constants import HAM_URL, SPAM_SUBMISSIONS_FLAG, SPAM_URL, VERIFY_URL\n from kuma.users.tests import UserTestCase\n from kuma.users.models import User\n-from kuma.wiki.models import RevisionAkismetSubmission\n+from kuma.wiki.admin import DocumentSpamAttemptAdmin\n+from kuma.wiki.models import DocumentSpamAttempt, RevisionAkismetSubmission\n+\n+\n+@pytest.mark.spam\n+class DocumentSpamAttemptAdminTestCase(UserTestCase):\n+    fixtures = UserTestCase.fixtures + ['wiki/documents.json']\n+    sample_data = \"\"\"{\n+        \"blog_lang\": \"en_us\",\n+        \"comment_type\": \"wiki-revision\",\n+        \"referrer\": \"https://developer.mozilla.org/en-US/docs/new?slug=Web/CSS\",\n+        \"user_ip\": \"192.168.10.1\",\n+        \"blog_charset\": \"UTF-8\",\n+        \"user_agent\": \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3)\",\n+        \"comment_content\": \"Web_CSS\\\\nWeb_CSS\\\\n\\\\n<p>spam</p>\\\\nComment\\\\n\\\\n\",\n+        \"comment_author\": \"viagra-test-123\",\n+        \"comment_author_email\": \"viagra-test-123@example.com\"\n+    }\"\"\"\n+\n+    class FakeMessageStorage(object):\n+        def __init__(self):\n+            self.storage = []\n+\n+        def add(self, level, message, extra_tags):\n+            self.storage.append((level, message, extra_tags))","path":"kuma/wiki/tests/test_admin.py","position":41,"original_position":41,"commit_id":"69ee88444d73decdaece0006dfc2a1f19fc4a510","original_commit_id":"69ee88444d73decdaece0006dfc2a1f19fc4a510","user":{"login":"jwhitlock","id":286017,"avatar_url":"https://avatars.githubusercontent.com/u/286017?v=3","gravatar_id":"","url":"https://api.github.com/users/jwhitlock","html_url":"https://github.com/jwhitlock","followers_url":"https://api.github.com/users/jwhitlock/followers","following_url":"https://api.github.com/users/jwhitlock/following{/other_user}","gists_url":"https://api.github.com/users/jwhitlock/gists{/gist_id}","starred_url":"https://api.github.com/users/jwhitlock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jwhitlock/subscriptions","organizations_url":"https://api.github.com/users/jwhitlock/orgs","repos_url":"https://api.github.com/users/jwhitlock/repos","events_url":"https://api.github.com/users/jwhitlock/events{/privacy}","received_events_url":"https://api.github.com/users/jwhitlock/received_events","type":"User","site_admin":false},"body":"and ``UserTestCase`` is derived from that, so I'll use that instead of yet another test class.","created_at":"2016-03-15T20:47:12Z","updated_at":"2016-03-15T20:47:12Z","html_url":"https://github.com/mozilla/kuma/pull/3816#discussion_r56237666","pull_request_url":"https://api.github.com/repos/mozilla/kuma/pulls/3816","_links":{"self":{"href":"https://api.github.com/repos/mozilla/kuma/pulls/comments/56237666"},"html":{"href":"https://github.com/mozilla/kuma/pull/3816#discussion_r56237666"},"pull_request":{"href":"https://api.github.com/repos/mozilla/kuma/pulls/3816"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/kuma/pulls/3816","id":62968011,"html_url":"https://github.com/mozilla/kuma/pull/3816","diff_url":"https://github.com/mozilla/kuma/pull/3816.diff","patch_url":"https://github.com/mozilla/kuma/pull/3816.patch","issue_url":"https://api.github.com/repos/mozilla/kuma/issues/3816","number":3816,"state":"open","locked":false,"title":"bug 1255609 - Enable training on false positives","user":{"login":"jwhitlock","id":286017,"avatar_url":"https://avatars.githubusercontent.com/u/286017?v=3","gravatar_id":"","url":"https://api.github.com/users/jwhitlock","html_url":"https://github.com/jwhitlock","followers_url":"https://api.github.com/users/jwhitlock/followers","following_url":"https://api.github.com/users/jwhitlock/following{/other_user}","gists_url":"https://api.github.com/users/jwhitlock/gists{/gist_id}","starred_url":"https://api.github.com/users/jwhitlock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jwhitlock/subscriptions","organizations_url":"https://api.github.com/users/jwhitlock/orgs","repos_url":"https://api.github.com/users/jwhitlock/repos","events_url":"https://api.github.com/users/jwhitlock/events{/privacy}","received_events_url":"https://api.github.com/users/jwhitlock/received_events","type":"User","site_admin":false},"body":"Add additional data to wiki's DocumentSpamAttempt:\r\n* data - JSON-serialized data sent to Akismet\r\n* review - Staff review status (default 'Needs Review')\r\n* reviewer - Staff reviewer\r\n* reviewed - Review date\r\n\r\nOld DocumentSpamAttempts do not have this additional data, so their status is set to \"Review Unavailable\".\r\n\r\nUpdate the Django admin for DocumentSpamAttempt so that it works better as a dashboard for second-guessing Akismet:\r\n* Limit the length of title and slug on the list display\r\n* Allow filtering by \"Needs Review\", to treat the admin as a review backlog.\r\n* Add an editable dropdown to quickly review multiple edits from known users\r\n* When a review of \"Spam\" is chosen, it confims Akismet's choice, and no futher API call is needed.\r\n* When a review of \"Ham / False Positive\" is chosen, submit the original data to Akismet's submit_ham API endpoint. On failure, revert to unreviewed status so it can be tried again.\r\n\r\nAdd a management command and task to drop submission data for old records, saving database resources and removing unneeded PII.\r\n\r\nUpdate the anonymization scripts to drop submission data.\r\n\r\nIt can be hard to test this locally. If you want to, it helps to create a user 'viagra-test-123', which will always be counted as spam:\r\n\r\n![spam dashboard](https://cloud.githubusercontent.com/assets/286017/13792236/e6d76e06-eabe-11e5-863a-6ee2106b2924.png)","created_at":"2016-03-15T20:03:30Z","updated_at":"2016-03-15T20:47:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c2fba9af38cef79766170e789f294283d7aaca8c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mozilla/kuma/pulls/3816/commits","review_comments_url":"https://api.github.com/repos/mozilla/kuma/pulls/3816/comments","review_comment_url":"https://api.github.com/repos/mozilla/kuma/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla/kuma/issues/3816/comments","statuses_url":"https://api.github.com/repos/mozilla/kuma/statuses/69ee88444d73decdaece0006dfc2a1f19fc4a510","head":{"label":"mozilla:spam_dashboard_1255609","ref":"spam_dashboard_1255609","sha":"69ee88444d73decdaece0006dfc2a1f19fc4a510","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":1352520,"name":"kuma","full_name":"mozilla/kuma","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/kuma","description":"The project that powers MDN.","fork":false,"url":"https://api.github.com/repos/mozilla/kuma","forks_url":"https://api.github.com/repos/mozilla/kuma/forks","keys_url":"https://api.github.com/repos/mozilla/kuma/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/kuma/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/kuma/teams","hooks_url":"https://api.github.com/repos/mozilla/kuma/hooks","issue_events_url":"https://api.github.com/repos/mozilla/kuma/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/kuma/events","assignees_url":"https://api.github.com/repos/mozilla/kuma/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/kuma/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/kuma/tags","blobs_url":"https://api.github.com/repos/mozilla/kuma/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/kuma/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/kuma/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/kuma/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/kuma/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/kuma/languages","stargazers_url":"https://api.github.com/repos/mozilla/kuma/stargazers","contributors_url":"https://api.github.com/repos/mozilla/kuma/contributors","subscribers_url":"https://api.github.com/repos/mozilla/kuma/subscribers","subscription_url":"https://api.github.com/repos/mozilla/kuma/subscription","commits_url":"https://api.github.com/repos/mozilla/kuma/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/kuma/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/kuma/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/kuma/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/kuma/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/kuma/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/kuma/merges","archive_url":"https://api.github.com/repos/mozilla/kuma/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/kuma/downloads","issues_url":"https://api.github.com/repos/mozilla/kuma/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/kuma/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/kuma/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/kuma/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/kuma/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/kuma/releases{/id}","deployments_url":"https://api.github.com/repos/mozilla/kuma/deployments","created_at":"2011-02-10T21:48:06Z","updated_at":"2016-03-15T15:12:55Z","pushed_at":"2016-03-15T20:24:34Z","git_url":"git://github.com/mozilla/kuma.git","ssh_url":"git@github.com:mozilla/kuma.git","clone_url":"https://github.com/mozilla/kuma.git","svn_url":"https://github.com/mozilla/kuma","homepage":"https://developer.mozilla.org","size":157862,"stargazers_count":770,"watchers_count":770,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":472,"mirror_url":null,"open_issues_count":12,"forks":472,"open_issues":12,"watchers":770,"default_branch":"master"}},"base":{"label":"mozilla:master","ref":"master","sha":"0be36a8e39929466d55f13c9de050b7c14b57b23","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":1352520,"name":"kuma","full_name":"mozilla/kuma","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/kuma","description":"The project that powers MDN.","fork":false,"url":"https://api.github.com/repos/mozilla/kuma","forks_url":"https://api.github.com/repos/mozilla/kuma/forks","keys_url":"https://api.github.com/repos/mozilla/kuma/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/kuma/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/kuma/teams","hooks_url":"https://api.github.com/repos/mozilla/kuma/hooks","issue_events_url":"https://api.github.com/repos/mozilla/kuma/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/kuma/events","assignees_url":"https://api.github.com/repos/mozilla/kuma/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/kuma/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/kuma/tags","blobs_url":"https://api.github.com/repos/mozilla/kuma/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/kuma/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/kuma/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/kuma/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/kuma/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/kuma/languages","stargazers_url":"https://api.github.com/repos/mozilla/kuma/stargazers","contributors_url":"https://api.github.com/repos/mozilla/kuma/contributors","subscribers_url":"https://api.github.com/repos/mozilla/kuma/subscribers","subscription_url":"https://api.github.com/repos/mozilla/kuma/subscription","commits_url":"https://api.github.com/repos/mozilla/kuma/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/kuma/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/kuma/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/kuma/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/kuma/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/kuma/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/kuma/merges","archive_url":"https://api.github.com/repos/mozilla/kuma/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/kuma/downloads","issues_url":"https://api.github.com/repos/mozilla/kuma/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/kuma/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/kuma/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/kuma/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/kuma/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/kuma/releases{/id}","deployments_url":"https://api.github.com/repos/mozilla/kuma/deployments","created_at":"2011-02-10T21:48:06Z","updated_at":"2016-03-15T15:12:55Z","pushed_at":"2016-03-15T20:24:34Z","git_url":"git://github.com/mozilla/kuma.git","ssh_url":"git@github.com:mozilla/kuma.git","clone_url":"https://github.com/mozilla/kuma.git","svn_url":"https://github.com/mozilla/kuma","homepage":"https://developer.mozilla.org","size":157862,"stargazers_count":770,"watchers_count":770,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":472,"mirror_url":null,"open_issues_count":12,"forks":472,"open_issues":12,"watchers":770,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/kuma/pulls/3816"},"html":{"href":"https://github.com/mozilla/kuma/pull/3816"},"issue":{"href":"https://api.github.com/repos/mozilla/kuma/issues/3816"},"comments":{"href":"https://api.github.com/repos/mozilla/kuma/issues/3816/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/kuma/pulls/3816/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/kuma/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla/kuma/pulls/3816/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/kuma/statuses/69ee88444d73decdaece0006dfc2a1f19fc4a510"}}}}