Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #3150 - Send the "moderation in process" message to the public issue #3156

Merged
merged 2 commits into from
Jan 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions tests/unit/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@

import unittest
import requests
import json

from mock import patch
from mock import ANY
karlcow marked this conversation as resolved.
Show resolved Hide resolved
from werkzeug import MultiDict

from webcompat.issues import report_issue
from webcompat.issues import report_private_issue
from webcompat.issues import report_public_issue
from webcompat.issues import moderation_template


class TestIssue(unittest.TestCase):
Expand Down Expand Up @@ -60,3 +64,10 @@ def test_report_private_issue_returns_nothing(self, mockpost):
('username', ''), ])
rv = report_private_issue(form, 'http://public.example.com')
self.assertIsNone(rv)

@patch.object(requests, 'post')
def test_report_public_issue_returns_moderation_template(self, mockpost):
"""Test that we get a moderation template back from a public issue report.""" # noqa
report_public_issue()
data = json.dumps(moderation_template())
mockpost.assert_called_with(ANY, data=data, headers=ANY, params=ANY)
21 changes: 13 additions & 8 deletions webcompat/issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,17 @@
PRIVATE_REPO_URI = app.config['PRIVATE_REPO_URI']


def unmoderated_issue():
def moderation_template():
karlcow marked this conversation as resolved.
Show resolved Hide resolved
"""Gets the placeholder data to send for unmoderated issues."""
# TODO: Replace this with something meaningful.
# See https://github.com/webcompat/webcompat.com/issues/3137
summary = 'Placeholder in-moderation title.'
body = 'Placeholder in-moderation body.'

summary = 'In the moderation queue.'
body = '''<p>This issue has been put in the moderation queue. A human
will review if the message meets our current
<a href="https://www.mozilla.org/en-US/about/legal/acceptable-use/">
acceptable use</a> guidelines.
It will probably take a couple of days depending on the backlog.
Once it has been reviewed, the content will be either made public
or deleted.</p>'''
return {'title': summary, 'body': body}


Expand All @@ -47,13 +52,13 @@ def report_private_issue(form, public_url):
return None


def report_public_issue(form):
def report_public_issue():
"""Report the issue publicly.

Returns a requests.Response object.
"""
path = 'repos/{0}'.format(REPO_URI)
return proxy_request('post', path, data=json.dumps(unmoderated_issue()))
return proxy_request('post', path, data=json.dumps(moderation_template()))


def report_issue(form, proxy=False):
Expand All @@ -62,7 +67,7 @@ def report_issue(form, proxy=False):
path = 'repos/{0}'.format(REPO_URI)
submit_type = form.get('submit_type')
if proxy and submit_type == 'github-proxy-report':
response = report_public_issue(form)
response = report_public_issue()
if (response.status_code == 201):
json_response = response.json()
report_private_issue(form, json_response.get('html_url'))
Expand Down
2 changes: 1 addition & 1 deletion webcompat/static/css/src/issue.css
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
}

.issue-details {
word-break: break-all;
word-break: break-word;
}

.issue-details-nsfw {
Expand Down